diff --git a/Jakefile.js b/Jakefile.js index 7024ad2afdf..7b85aacaa89 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -169,7 +169,9 @@ var librarySourceMap = [ { target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], }, { target: "lib.d.ts", sources: ["header.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, { target: "lib.core.es6.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts"]}, - { target: "lib.es6.d.ts", sources: ["header.d.ts", "es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] } + { target: "lib.es6.d.ts", sources: ["header.d.ts", "es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }, + { target: "lib.core.es7.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts", "es7.d.ts"]}, + { target: "lib.es7.d.ts", sources: ["header.d.ts", "es6.d.ts", "es7.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] } ]; var libraryTargets = librarySourceMap.map(function (f) { diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index 50fd8a8e495..145564d7044 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -14,7 +14,6 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// /// ECMAScript APIs ///////////////////////////// diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index 0470c4827cd..753c3bbf65f 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -14,7 +14,6 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -5121,15 +5120,15 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: Iterable>): Promise; /** diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 155d864619e..5b2c53c7cc1 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -14,7 +14,6 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -5296,7 +5295,7 @@ interface Console { select(element: Element): void; time(timerName?: string): void; timeEnd(timerName?: string): void; - trace(): void; + trace(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; } @@ -5555,9 +5554,9 @@ interface DataTransferItemList { length: number; add(data: File): DataTransferItem; clear(): void; - item(index: number): File; + item(index: number): DataTransferItem; remove(index: number): void; - [index: number]: File; + [index: number]: DataTransferItem; } declare var DataTransferItemList: { @@ -6610,6 +6609,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param content The text and HTML tags to write. */ writeln(...content: string[]): void; + createElement(tagName: "picture"): HTMLPictureElement; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -7022,6 +7023,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitRequestFullscreen(): void; getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -7811,6 +7813,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. */ toDataURL(type?: string, ...args: any[]): string; + toBlob(): Blob; } declare var HTMLCanvasElement: { @@ -10965,7 +10968,7 @@ interface IDBDatabase extends EventTarget { objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; - version: string; + version: number; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; @@ -11681,7 +11684,7 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: number; + readyState: string; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; endOfStream(error?: number): void; @@ -14410,17 +14413,16 @@ declare var Storage: { } interface StorageEvent extends Event { - key: string; - newValue: any; - oldValue: any; - storageArea: Storage; url: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; } declare var StorageEvent: { prototype: StorageEvent; - new(): StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; } interface StyleMedia { @@ -16018,7 +16020,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window msMatchMedia(mediaQuery: string): MediaQueryList; msRequestAnimationFrame(callback: FrameRequestCallback): number; msWriteProfilerMark(profilerMarkName: string): void; - open(url?: string, target?: string, features?: string, replace?: boolean): any; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; postMessage(message: any, targetOrigin: string, ports?: any): void; print(): void; prompt(message?: string, _default?: string): string; @@ -16620,6 +16622,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + interface IDBObjectStoreParameters { keyPath?: string | string[]; autoIncrement?: boolean; @@ -16674,6 +16684,14 @@ declare var HTMLTemplateElement: { new(): HTMLTemplateElement; } +interface HTMLPictureElement extends HTMLElement { +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -16870,7 +16888,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void; declare function msMatchMedia(mediaQuery: string): MediaQueryList; declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): any; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; declare function postMessage(message: any, targetOrigin: string, ports?: any): void; declare function print(): void; declare function prompt(message?: string, _default?: string): string; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index b2ad2c73df6..542149d7719 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -1472,7 +1472,7 @@ interface Console { select(element: Element): void; time(timerName?: string): void; timeEnd(timerName?: string): void; - trace(): void; + trace(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; } @@ -1731,9 +1731,9 @@ interface DataTransferItemList { length: number; add(data: File): DataTransferItem; clear(): void; - item(index: number): File; + item(index: number): DataTransferItem; remove(index: number): void; - [index: number]: File; + [index: number]: DataTransferItem; } declare var DataTransferItemList: { @@ -2786,6 +2786,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param content The text and HTML tags to write. */ writeln(...content: string[]): void; + createElement(tagName: "picture"): HTMLPictureElement; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3198,6 +3200,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitRequestFullscreen(): void; getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3987,6 +3990,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. */ toDataURL(type?: string, ...args: any[]): string; + toBlob(): Blob; } declare var HTMLCanvasElement: { @@ -7141,7 +7145,7 @@ interface IDBDatabase extends EventTarget { objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; - version: string; + version: number; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; @@ -7857,7 +7861,7 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: number; + readyState: string; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; endOfStream(error?: number): void; @@ -10586,17 +10590,16 @@ declare var Storage: { } interface StorageEvent extends Event { - key: string; - newValue: any; - oldValue: any; - storageArea: Storage; url: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; } declare var StorageEvent: { prototype: StorageEvent; - new(): StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; } interface StyleMedia { @@ -12194,7 +12197,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window msMatchMedia(mediaQuery: string): MediaQueryList; msRequestAnimationFrame(callback: FrameRequestCallback): number; msWriteProfilerMark(profilerMarkName: string): void; - open(url?: string, target?: string, features?: string, replace?: boolean): any; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; postMessage(message: any, targetOrigin: string, ports?: any): void; print(): void; prompt(message?: string, _default?: string): string; @@ -12796,6 +12799,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + interface IDBObjectStoreParameters { keyPath?: string | string[]; autoIncrement?: boolean; @@ -12850,6 +12861,14 @@ declare var HTMLTemplateElement: { new(): HTMLTemplateElement; } +interface HTMLPictureElement extends HTMLElement { +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -13046,7 +13065,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void; declare function msMatchMedia(mediaQuery: string): MediaQueryList; declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): any; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; declare function postMessage(message: any, targetOrigin: string, ports?: any): void; declare function print(): void; declare function prompt(message?: string, _default?: string): string; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index ef3399ba804..70f464ad48e 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -13,6 +13,7 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +/// declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1296,15 +1297,15 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: Iterable>): Promise; /** @@ -1346,8 +1347,6 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; -/// - ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -6629,7 +6628,7 @@ interface Console { select(element: Element): void; time(timerName?: string): void; timeEnd(timerName?: string): void; - trace(): void; + trace(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; } @@ -6888,9 +6887,9 @@ interface DataTransferItemList { length: number; add(data: File): DataTransferItem; clear(): void; - item(index: number): File; + item(index: number): DataTransferItem; remove(index: number): void; - [index: number]: File; + [index: number]: DataTransferItem; } declare var DataTransferItemList: { @@ -7943,6 +7942,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param content The text and HTML tags to write. */ writeln(...content: string[]): void; + createElement(tagName: "picture"): HTMLPictureElement; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -8355,6 +8356,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitRequestFullscreen(): void; getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -9144,6 +9146,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. */ toDataURL(type?: string, ...args: any[]): string; + toBlob(): Blob; } declare var HTMLCanvasElement: { @@ -12298,7 +12301,7 @@ interface IDBDatabase extends EventTarget { objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; - version: string; + version: number; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; @@ -13014,7 +13017,7 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: number; + readyState: string; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; endOfStream(error?: number): void; @@ -15743,17 +15746,16 @@ declare var Storage: { } interface StorageEvent extends Event { - key: string; - newValue: any; - oldValue: any; - storageArea: Storage; url: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; } declare var StorageEvent: { prototype: StorageEvent; - new(): StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; } interface StyleMedia { @@ -17351,7 +17353,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window msMatchMedia(mediaQuery: string): MediaQueryList; msRequestAnimationFrame(callback: FrameRequestCallback): number; msWriteProfilerMark(profilerMarkName: string): void; - open(url?: string, target?: string, features?: string, replace?: boolean): any; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; postMessage(message: any, targetOrigin: string, ports?: any): void; print(): void; prompt(message?: string, _default?: string): string; @@ -17953,6 +17955,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + interface IDBObjectStoreParameters { keyPath?: string | string[]; autoIncrement?: boolean; @@ -18007,6 +18017,14 @@ declare var HTMLTemplateElement: { new(): HTMLTemplateElement; } +interface HTMLPictureElement extends HTMLElement { +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -18203,7 +18221,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void; declare function msMatchMedia(mediaQuery: string): MediaQueryList; declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): any; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; declare function postMessage(message: any, targetOrigin: string, ports?: any): void; declare function print(): void; declare function prompt(message?: string, _default?: string): string; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 1138538a1b8..33e0d0f9ded 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -286,7 +286,7 @@ interface Console { select(element: any): void; time(timerName?: string): void; timeEnd(timerName?: string): void; - trace(): void; + trace(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; } @@ -526,7 +526,7 @@ interface IDBDatabase extends EventTarget { objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; - version: string; + version: number; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; diff --git a/lib/tsc.js b/lib/tsc.js index 543deadb433..2208201fef0 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -19,7 +19,7 @@ var ts; function OperationCanceledException() { } return OperationCanceledException; - })(); + }()); ts.OperationCanceledException = OperationCanceledException; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; @@ -636,7 +636,8 @@ var ts; if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { directoryComponents.length--; } - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + var joinStartIndex; + for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } @@ -773,6 +774,12 @@ var ts; return copiedList; } ts.copyListRemovingItem = copyListRemovingItem; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; })(ts || (ts = {})); var ts; (function (ts) { @@ -911,7 +918,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); - function createWatchedFileSet(interval, chunkSize) { + function createPollingWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } var watchedFiles = []; @@ -925,13 +932,13 @@ var ts; if (!watchedFile) { return; } - _fs.stat(watchedFile.fileName, function (err, stats) { + _fs.stat(watchedFile.filePath, function (err, stats) { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.filePath); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + watchedFile.mtime = getModifiedTime(watchedFile.filePath); + watchedFile.callback(watchedFile.filePath, watchedFile.mtime.getTime() === 0); } }); } @@ -954,11 +961,11 @@ var ts; nextFileToCheck = nextToCheck; }, interval); } - function addFile(fileName, callback) { + function addFile(filePath, callback) { var file = { - fileName: fileName, + filePath: filePath, callback: callback, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(filePath) }; watchedFiles.push(file); if (watchedFiles.length === 1) { @@ -977,7 +984,77 @@ var ts; removeFile: removeFile }; } + function createWatchedFileSet() { + var dirWatchers = ts.createFileMap(); + var fileWatcherCallbacks = ts.createFileMap(); + return { addFile: addFile, removeFile: removeFile }; + function reduceDirWatcherRefCountForFile(filePath) { + var dirPath = ts.getDirectoryPath(filePath); + if (dirWatchers.contains(dirPath)) { + var watcher = dirWatchers.get(dirPath); + watcher.referenceCount -= 1; + if (watcher.referenceCount <= 0) { + watcher.close(); + dirWatchers.remove(dirPath); + } + } + } + function addDirWatcher(dirPath) { + if (dirWatchers.contains(dirPath)) { + var watcher_1 = dirWatchers.get(dirPath); + watcher_1.referenceCount += 1; + return; + } + var watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher.referenceCount = 1; + dirWatchers.set(dirPath, watcher); + return; + } + function addFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + fileWatcherCallbacks.get(filePath).push(callback); + } + else { + fileWatcherCallbacks.set(filePath, [callback]); + } + } + function addFile(filePath, callback) { + addFileWatcherCallback(filePath, callback); + addDirWatcher(ts.getDirectoryPath(filePath)); + return { filePath: filePath, callback: callback }; + } + function removeFile(watchedFile) { + removeFileWatcherCallback(watchedFile.filePath, watchedFile.callback); + reduceDirWatcherRefCountForFile(watchedFile.filePath); + } + function removeFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + var newCallbacks = ts.copyListRemovingItem(callback, fileWatcherCallbacks.get(filePath)); + if (newCallbacks.length === 0) { + fileWatcherCallbacks.remove(filePath); + } + else { + fileWatcherCallbacks.set(filePath, newCallbacks); + } + } + } + function fileEventHandler(eventName, relativeFileName, baseDirPath) { + var filePath = typeof relativeFileName !== "string" + ? undefined + : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); + if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { + var fileCallback = _a[_i]; + fileCallback(filePath); + } + } + } + } + var pollingWatchedFileSet = createPollingWatchedFileSet(); var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -1019,7 +1096,7 @@ var ts; } } function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; + return useCaseSensitiveFileNames ? path : path.toLowerCase(); } function readDirectory(path, extension, exclude) { var result = []; @@ -1059,14 +1136,22 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { - var watchedFile = watchedFileSet.addFile(fileName, callback); + watchFile: function (filePath, callback) { + var watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet; + var watchedFile = watchSet.addFile(filePath, callback); return { - close: function () { return watchedFileSet.removeFile(watchedFile); } + close: function () { return watchSet.removeFile(watchedFile); } }; }, watchDirectory: function (path, callback, recursive) { - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + var options; + if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + options = { persistent: true, recursive: !!recursive }; + } + else { + options = { persistent: true }; + } + return _fs.watch(path, options, function (eventName, relativeFileName) { if (eventName === "rename") { callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); } @@ -1325,7 +1410,6 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -1561,7 +1645,6 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, - A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods: { code: 2519, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_r_2519", message: "A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, @@ -1590,6 +1673,16 @@ var ts; Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, + Cannot_re_export_name_that_is_not_defined_in_the_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_re_export_name_that_is_not_defined_in_the_module_2661", message: "Cannot re-export name that is not defined in the module." }, + 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." }, + Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope_2665", message: "Module augmentation cannot introduce new names in the top level scope." }, + 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." }, + Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, + Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, 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}'." }, @@ -1754,6 +1847,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, 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'." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, 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." }, 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." }, @@ -1849,6 +1943,7 @@ var ts; "protected": 111, "public": 112, "require": 127, + "global": 134, "return": 94, "set": 129, "static": 113, @@ -1869,7 +1964,7 @@ var ts; "yield": 114, "async": 118, "await": 119, - "of": 134, + "of": 135, "{": 15, "}": 16, "(": 17, @@ -3130,7 +3225,7 @@ var ts; break; } } - return token = 238; + return token = 239; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -3296,7 +3391,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 250) { + while (node && node.kind !== 251) { node = node.parent; } return node; @@ -3380,6 +3475,28 @@ var ts; isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isAmbientModule(node) { + return node && node.kind === 221 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 2097152); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 251: + return isExternalModule(node.parent); + case 222: + return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function getEnclosingBlockScopeContainer(node) { var current = node.parent; while (current) { @@ -3387,15 +3504,15 @@ var ts; return current; } switch (current.kind) { - case 250: - case 222: - case 246: - case 220: - case 201: + case 251: + case 223: + case 247: + case 221: case 202: case 203: + case 204: return current; - case 194: + case 195: if (!isFunctionLike(current.parent)) { return current; } @@ -3406,9 +3523,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 213 && + declaration.kind === 214 && declaration.parent && - declaration.parent.kind === 246; + declaration.parent.kind === 247; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3444,23 +3561,24 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 250: + case 251: 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 213: - case 165: - case 216: - case 188: + case 214: + case 166: case 217: + case 189: + case 218: + case 221: case 220: + case 250: + case 216: + case 176: + case 144: case 219: - case 249: - case 215: - case 175: - case 143: errorNode = node.name; break; } @@ -3486,11 +3604,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 219 && isConst(node); + return node.kind === 220 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 165 || isBindingPattern(node))) { + while (node && (node.kind === 166 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3498,14 +3616,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 213) { + if (node.kind === 214) { node = node.parent; } - if (node && node.kind === 214) { + if (node && node.kind === 215) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 195) { + if (node && node.kind === 196) { flags |= node.flags; } return flags; @@ -3520,7 +3638,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 197 && node.expression.kind === 9; + return node.kind === 198 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -3536,7 +3654,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 138 || node.kind === 137) ? + var commentRanges = (node.kind === 139 || node.kind === 138) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -3550,7 +3668,7 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (150 <= node.kind && node.kind <= 162) { + if (151 <= node.kind && node.kind <= 163) { return true; } switch (node.kind) { @@ -3561,56 +3679,56 @@ var ts; case 131: return true; case 103: - return node.parent.kind !== 179; - case 190: + return node.parent.kind !== 180; + case 191: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 69: - if (node.parent.kind === 135 && node.parent.right === node) { + if (node.parent.kind === 136 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 168 && node.parent.name === node) { + else if (node.parent.kind === 169 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 168, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135: - case 168: + ts.Debug.assert(node.kind === 69 || node.kind === 136 || node.kind === 169, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 136: + case 169: case 97: var parent_1 = node.parent; - if (parent_1.kind === 154) { + if (parent_1.kind === 155) { return false; } - if (150 <= parent_1.kind && parent_1.kind <= 162) { + if (151 <= parent_1.kind && parent_1.kind <= 163) { return true; } switch (parent_1.kind) { - case 190: + case 191: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137: - return node === parent_1.constraint; - case 141: - case 140: case 138: - case 213: + return node === parent_1.constraint; + case 142: + case 141: + case 139: + case 214: return node === parent_1.type; - case 215: - case 175: + case 216: case 176: + case 177: + case 145: case 144: case 143: - case 142: - case 145: case 146: - return node === parent_1.type; case 147: + return node === parent_1.type; case 148: case 149: + case 150: return node === parent_1.type; - case 173: + case 174: return node === parent_1.type; - case 170: case 171: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 172: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 173: return false; } } @@ -3621,23 +3739,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 206: + case 207: return visitor(node); - case 222: - case 194: - case 198: + case 223: + case 195: case 199: case 200: case 201: case 202: case 203: - case 207: + case 204: case 208: - case 243: - case 244: case 209: - case 211: - case 246: + case 244: + case 245: + case 210: + case 212: + case 247: return ts.forEachChild(node, traverse); } } @@ -3647,23 +3765,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186: + case 187: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 219: - case 217: case 220: case 218: - case 216: - case 188: + case 221: + case 219: + case 217: + case 189: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 136) { + if (name_5 && name_5.kind === 137) { traverse(name_5.expression); return; } @@ -3678,14 +3796,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 165: - case 249: - case 138: - case 247: - case 141: - case 140: + case 166: + case 250: + case 139: case 248: - case 213: + case 142: + case 141: + case 249: + case 214: return true; } } @@ -3693,11 +3811,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 145 || node.kind === 146); + return node && (node.kind === 146 || node.kind === 147); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 216 || node.kind === 188); + return node && (node.kind === 217 || node.kind === 189); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -3706,32 +3824,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 144: - case 175: - case 215: - case 176: - case 143: - case 142: case 145: + case 176: + case 216: + case 177: + case 144: + case 143: case 146: case 147: case 148: case 149: - case 152: + case 150: case 153: + case 154: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 215: - case 175: + case 147: + case 216: + case 176: return true; } return false; @@ -3739,24 +3857,24 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 201: case 202: case 203: - case 199: + case 204: case 200: + case 201: return true; - case 209: + case 210: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 194 && isFunctionLike(node.parent); + return node && node.kind === 195 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 143 && node.parent.kind === 167; + return node && node.kind === 144 && node.parent.kind === 168; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { @@ -3788,39 +3906,39 @@ var ts; return undefined; } switch (node.kind) { - case 136: + case 137: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + case 140: + if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 176: + case 177: if (!includeArrowFunctions) { continue; } - case 215: - case 175: - case 220: - case 141: - case 140: - case 143: + case 216: + case 176: + case 221: case 142: + case 141: case 144: + case 143: case 145: case 146: case 147: case 148: case 149: - case 219: - case 250: + case 150: + case 220: + case 251: return node; } } @@ -3833,25 +3951,25 @@ var ts; return node; } switch (node.kind) { - case 136: + case 137: node = node.parent; break; - case 215: - case 175: + case 216: case 176: + case 177: if (!stopOnFunctions) { continue; } - case 141: - case 140: - case 143: case 142: + case 141: case 144: + case 143: case 145: case 146: + case 147: return node; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + case 140: + if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -3865,12 +3983,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 151: + case 152: return node.typeName; - case 190: + case 191: return node.expression; case 69: - case 135: + case 136: return node; } } @@ -3878,7 +3996,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 172) { + if (node.kind === 173) { return node.tag; } return node.expression; @@ -3886,54 +4004,36 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 216: + case 217: return true; - case 141: - return node.parent.kind === 216; - case 138: - return node.parent.body && node.parent.parent.kind === 216; - case 145: + case 142: + return node.parent.kind === 217; case 146: - case 143: - return node.body && node.parent.kind === 216; + case 147: + case 144: + return node.body !== undefined + && node.parent.kind === 217; + case 139: + return node.parent.body !== undefined + && (node.parent.kind === 145 + || node.parent.kind === 144 + || node.parent.kind === 147) + && node.parent.parent.kind === 217; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { - switch (node.kind) { - case 216: - if (node.decorators) { - return true; - } - return false; - case 141: - case 138: - if (node.decorators) { - return true; - } - return false; - case 145: - if (node.body && node.decorators) { - return true; - } - return false; - case 143: - case 146: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; + return node.decorators !== undefined + && nodeCanBeDecorated(node); } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 168; + return node.kind === 169; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 169; + return node.kind === 170; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -3943,42 +4043,42 @@ var ts; case 99: case 84: case 10: - case 166: case 167: case 168: case 169: case 170: case 171: case 172: - case 191: case 173: + case 192: case 174: case 175: - case 188: case 176: - case 179: + case 189: case 177: + case 180: case 178: - case 181: + case 179: case 182: case 183: case 184: - case 187: case 185: - case 11: - case 189: - case 235: - case 236: + case 188: case 186: - case 180: + case 11: + case 190: + case 236: + case 237: + case 187: + case 181: return true; - case 135: - while (node.parent.kind === 135) { + case 136: + while (node.parent.kind === 136) { node = node.parent; } - return node.parent.kind === 154; + return node.parent.kind === 155; case 69: - if (node.parent.kind === 154) { + if (node.parent.kind === 155) { return true; } case 8: @@ -3986,47 +4086,47 @@ var ts; case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 213: - case 138: + case 214: + case 139: + case 142: case 141: - case 140: - case 249: - case 247: - case 165: + case 250: + case 248: + case 166: return parent_2.initializer === node; - case 197: case 198: case 199: case 200: - case 206: + case 201: case 207: case 208: - case 243: - case 210: - case 208: + case 209: + case 244: + case 211: + case 209: return parent_2.expression === node; - case 201: + case 202: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 214) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 215) || forStatement.condition === node || forStatement.incrementor === node; - case 202: case 203: + case 204: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 214) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215) || forInStatement.expression === node; - case 173: - case 191: - return node === parent_2.expression; + case 174: case 192: return node === parent_2.expression; - case 136: + case 193: return node === parent_2.expression; - case 139: + case 137: + return node === parent_2.expression; + case 140: + case 243: case 242: - case 241: return true; - case 190: + case 191: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4048,7 +4148,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 && node.moduleReference.kind === 234; + return node.kind === 224 && node.moduleReference.kind === 235; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4057,7 +4157,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 && node.moduleReference.kind !== 234; + return node.kind === 224 && node.moduleReference.kind !== 235; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -4069,7 +4169,7 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression) { - return expression.kind === 170 && + return expression.kind === 171 && expression.expression.kind === 69 && expression.expression.text === "require" && expression.arguments.length === 1 && @@ -4077,11 +4177,11 @@ var ts; } ts.isRequireCall = isRequireCall; function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 183) { + if (expression.kind !== 184) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 168) { + if (expr.operatorToken.kind !== 56 || expr.left.kind !== 169) { return 0; } var lhs = expr.left; @@ -4097,7 +4197,7 @@ var ts; else if (lhs.expression.kind === 97) { return 4; } - else if (lhs.expression.kind === 168) { + else if (lhs.expression.kind === 169) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 && innerPropertyAccess.name.text === "prototype") { return 3; @@ -4107,30 +4207,33 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 224) { + if (node.kind === 225) { return node.moduleSpecifier; } - if (node.kind === 223) { + if (node.kind === 224) { var reference = node.moduleReference; - if (reference.kind === 234) { + if (reference.kind === 235) { return reference.expression; } } - if (node.kind === 230) { + if (node.kind === 231) { return node.moduleSpecifier; } + if (node.kind === 221 && node.name.kind === 9) { + return node.name; + } } ts.getExternalModuleName = getExternalModuleName; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 138: + case 139: + case 144: case 143: - case 142: + case 249: case 248: - case 247: + case 142: case 141: - case 140: return node.questionToken !== undefined; } } @@ -4138,9 +4241,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 263 && + return node.kind === 264 && node.parameters.length > 0 && - node.parameters[0].type.kind === 265; + node.parameters[0].type.kind === 266; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4154,15 +4257,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 271); + return getJSDocTag(node, 272); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 270); + return getJSDocTag(node, 271); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 272); + return getJSDocTag(node, 273); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -4171,7 +4274,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 269) { + if (t.kind === 270) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4190,12 +4293,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 264) { + if (node.type && node.type.kind === 265) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 264; + return paramTag.typeExpression.type.kind === 265; } } return node.dotDotDotToken !== undefined; @@ -4216,7 +4319,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 164 || node.kind === 163); + return !!node && (node.kind === 165 || node.kind === 164); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -4240,34 +4343,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 176: - case 165: - case 216: - case 188: - case 144: - case 219: - case 249: - case 232: - case 215: - case 175: - case 145: - case 225: - case 223: - case 228: + case 177: + case 166: case 217: - case 143: - case 142: + case 189: + case 145: case 220: - case 226: - case 138: - case 247: - case 141: - case 140: + case 250: + case 233: + case 216: + case 176: case 146: - case 248: + case 226: + case 224: + case 229: case 218: - case 137: - case 213: + case 144: + case 143: + case 221: + case 227: + case 139: + case 248: + case 142: + case 141: + case 147: + case 249: + case 219: + case 138: + case 214: return true; } return false; @@ -4275,25 +4378,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 205: - case 204: - case 212: - case 199: - case 197: - case 196: - case 202: - case 203: - case 201: - case 198: - case 209: case 206: - case 208: - case 210: - case 211: - case 195: + case 205: + case 213: case 200: + case 198: + case 197: + case 203: + case 204: + case 202: + case 199: + case 210: case 207: - case 229: + case 209: + case 211: + case 212: + case 196: + case 201: + case 208: + case 230: return true; default: return false; @@ -4302,13 +4405,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 144: - case 141: - case 143: case 145: - case 146: case 142: - case 149: + case 144: + case 146: + case 147: + case 143: + case 150: return true; default: return false; @@ -4320,7 +4423,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 228 || parent.kind === 232) { + if (parent.kind === 229 || parent.kind === 233) { if (parent.propertyName) { return true; } @@ -4334,40 +4437,40 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 141: - case 140: - case 143: case 142: - case 145: + case 141: + case 144: + case 143: case 146: - case 249: - case 247: - case 168: + case 147: + case 250: + case 248: + case 169: return parent.name === node; - case 135: + case 136: if (parent.right === node) { - while (parent.kind === 135) { + while (parent.kind === 136) { parent = parent.parent; } - return parent.kind === 154; + return parent.kind === 155; } return false; - case 165: - case 228: + case 166: + case 229: return parent.propertyName === node; - case 232: + case 233: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 223 || - node.kind === 225 && !!node.name || - node.kind === 226 || - node.kind === 228 || - node.kind === 232 || - node.kind === 229 && node.expression.kind === 69; + return node.kind === 224 || + node.kind === 226 && !!node.name || + node.kind === 227 || + node.kind === 229 || + node.kind === 233 || + node.kind === 230 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4449,7 +4552,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 134; + return 70 <= token && token <= 135; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4469,7 +4572,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 136 && + return name.kind === 137 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -4482,7 +4585,7 @@ var ts; if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 136) { + if (name.kind === 137) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4519,18 +4622,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 138; + return root.kind === 139; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 165) { + while (node.kind === 166) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 220 || n.kind === 250; + return isFunctionLike(n) || n.kind === 221 || n.kind === 251; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneNode(node, location, flags, parent) { @@ -4563,7 +4666,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 135; + return node.kind === 136; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -4876,7 +4979,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 144 && nodeIsPresent(member.body)) { + if (member.kind === 145 && nodeIsPresent(member.body)) { return member; } }); @@ -4893,10 +4996,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 145) { + if (accessor.kind === 146) { getAccessor = accessor; } - else if (accessor.kind === 146) { + else if (accessor.kind === 147) { setAccessor = accessor; } else { @@ -4905,7 +5008,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 145 || member.kind === 146) + if ((member.kind === 146 || member.kind === 147) && (member.flags & 64) === (accessor.flags & 64)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4916,10 +5019,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 145 && !getAccessor) { + if (member.kind === 146 && !getAccessor) { getAccessor = member; } - if (member.kind === 146 && !setAccessor) { + if (member.kind === 147 && !setAccessor) { setAccessor = member; } } @@ -5085,24 +5188,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 168: case 169: - case 171: case 170: - case 235: - case 236: case 172: - case 166: - case 174: + case 171: + case 236: + case 237: + case 173: case 167: - case 188: case 175: + case 168: + case 189: + case 176: case 69: case 10: case 8: case 9: case 11: - case 185: + case 186: case 84: case 93: case 97: @@ -5119,7 +5222,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 190 && + return node.kind === 191 && node.parent.token === 83 && isClassLike(node.parent.parent); } @@ -5140,16 +5243,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 && node.parent.right === node) || - (node.parent.kind === 168 && node.parent.name === node); + return (node.parent.kind === 136 && node.parent.right === node) || + (node.parent.kind === 169 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 167) { + if (kind === 168) { return expression.properties.length === 0; } - if (kind === 166) { + if (kind === 167) { return expression.elements.length === 0; } return false; @@ -5393,9 +5496,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 137) { + if (d && d.kind === 138) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 217) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218) { return current; } } @@ -5403,7 +5506,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 && node.parent.kind === 144 && ts.isClassLike(node.parent.parent); + return node.flags & 56 && node.parent.kind === 145 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -5413,7 +5516,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 250) { + if (kind === 251) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -5449,26 +5552,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 135: + case 136: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 137: + case 138: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 248: + case 249: 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 138: + case 139: + case 142: case 141: - case 140: - case 247: - case 213: - case 165: + case 248: + case 214: + case 166: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5477,24 +5580,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152: case 153: - case 147: + case 154: case 148: case 149: + case 150: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 175: - case 215: + case 147: case 176: + case 216: + case 177: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5505,160 +5608,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 151: + case 152: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 150: + case 151: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 154: - return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 156: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 157: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 158: + return visitNodes(cbNodes, node.elementTypes); case 159: - return visitNodes(cbNodes, node.types); case 160: + return visitNodes(cbNodes, node.types); + case 161: return visitNode(cbNode, node.type); - case 163: case 164: - return visitNodes(cbNodes, node.elements); - case 166: + case 165: return visitNodes(cbNodes, node.elements); case 167: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 168: + return visitNodes(cbNodes, node.properties); + case 169: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 169: + case 170: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 170: case 171: + case 172: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 172: + case 173: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 173: + case 174: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 174: - return visitNode(cbNode, node.expression); - case 177: + case 175: return visitNode(cbNode, node.expression); case 178: return visitNode(cbNode, node.expression); case 179: return visitNode(cbNode, node.expression); - case 181: - return visitNode(cbNode, node.operand); - case 186: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 180: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.operand); + case 187: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 181: + return visitNode(cbNode, node.expression); case 183: + return visitNode(cbNode, node.operand); + case 184: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 191: + case 192: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 184: + case 185: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 187: + case 188: return visitNode(cbNode, node.expression); - case 194: - case 221: + case 195: + case 222: return visitNodes(cbNodes, node.statements); - case 250: + case 251: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 195: + case 196: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 214: + case 215: return visitNodes(cbNodes, node.declarations); - case 197: - return visitNode(cbNode, node.expression); case 198: + return visitNode(cbNode, node.expression); + case 199: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 199: + case 200: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 200: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 201: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 202: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 203: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 204: - case 205: - return visitNode(cbNode, node.label); - case 206: - return visitNode(cbNode, node.expression); - case 207: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 205: + case 206: + return visitNode(cbNode, node.label); + case 207: + return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 222: + case 223: return visitNodes(cbNodes, node.clauses); - case 243: + case 244: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 244: + case 245: return visitNodes(cbNodes, node.statements); - case 209: + case 210: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 210: - return visitNode(cbNode, node.expression); case 211: + return visitNode(cbNode, node.expression); + case 212: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 246: + case 247: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 139: + case 140: return visitNode(cbNode, node.expression); - case 216: - case 188: - 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 217: + case 189: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5670,125 +5766,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 249: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 220: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 250: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 223: + case 224: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 225: + case 226: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 226: - return visitNode(cbNode, node.name); case 227: - case 231: + return visitNode(cbNode, node.name); + case 228: + case 232: return visitNodes(cbNodes, node.elements); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 228: - case 232: + case 229: + case 233: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 185: + case 186: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 192: + case 193: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 245: + case 246: return visitNodes(cbNodes, node.types); - case 190: + case 191: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 234: - return visitNode(cbNode, node.expression); - case 233: - return visitNodes(cbNodes, node.decorators); case 235: + return visitNode(cbNode, node.expression); + case 234: + return visitNodes(cbNodes, node.decorators); + case 236: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 236: case 237: + case 238: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 240: + case 241: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 241: - return visitNode(cbNode, node.expression); case 242: return visitNode(cbNode, node.expression); - case 239: + case 243: + return visitNode(cbNode, node.expression); + case 240: return visitNode(cbNode, node.tagName); - case 251: + case 252: return visitNode(cbNode, node.type); - case 255: - return visitNodes(cbNodes, node.types); case 256: return visitNodes(cbNodes, node.types); - case 254: + case 257: + return visitNodes(cbNodes, node.types); + case 255: return visitNode(cbNode, node.elementType); + case 259: + return visitNode(cbNode, node.type); case 258: return visitNode(cbNode, node.type); - case 257: - return visitNode(cbNode, node.type); - case 259: + case 260: return visitNodes(cbNodes, node.members); - case 261: + case 262: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 262: - return visitNode(cbNode, node.type); case 263: + return visitNode(cbNode, node.type); + case 264: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 264: - return visitNode(cbNode, node.type); case 265: return visitNode(cbNode, node.type); case 266: return visitNode(cbNode, node.type); - case 260: + case 267: + return visitNode(cbNode, node.type); + case 261: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 267: + case 268: return visitNodes(cbNodes, node.tags); - case 269: + case 270: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 270: - return visitNode(cbNode, node.typeExpression); case 271: return visitNode(cbNode, node.typeExpression); case 272: + return visitNode(cbNode, node.typeExpression); + case 273: return visitNodes(cbNodes, node.typeParameters); } } @@ -5895,9 +5998,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 195: - case 215: - case 138: + case 196: + case 216: + case 139: addJSDocComment(node); } forEachChild(node, visit); @@ -5931,7 +6034,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = new SourceFileConstructor(250, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(251, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -6222,7 +6325,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(136); + var node = createNode(137); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6521,14 +6624,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 144: - case 149: case 145: + case 150: case 146: - case 141: - case 193: + case 147: + case 142: + case 194: return true; - case 143: + case 144: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 69 && methodDeclaration.name.originalKeywordKind === 121; @@ -6540,8 +6643,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 243: case 244: + case 245: return true; } } @@ -6550,65 +6653,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 215: + case 216: + case 196: case 195: - case 194: + case 199: case 198: - case 197: - case 210: + case 211: + case 207: + case 209: case 206: - case 208: case 205: + case 203: case 204: case 202: - case 203: case 201: - case 200: - case 207: - case 196: - case 211: - case 209: - case 199: + case 208: + case 197: case 212: + case 210: + case 200: + case 213: + case 225: case 224: - case 223: + case 231: case 230: - case 229: - case 220: - case 216: + case 221: case 217: - case 219: case 218: + case 220: + case 219: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 249; + return node.kind === 250; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 148: - case 142: case 149: - case 140: - case 147: + case 143: + case 150: + case 141: + case 148: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 213) { + if (node.kind !== 214) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 138) { + if (node.kind !== 139) { return false; } var parameter = node; @@ -6708,7 +6811,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(135, entity.pos); + var node = createNode(136, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6725,7 +6828,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(185); + var template = createNode(186); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6738,7 +6841,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(192); + var span = createNode(193); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6752,7 +6855,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(162, true); + return parseLiteralLikeNode(163, true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -6780,12 +6883,9 @@ var ts; } return node; } - function parseTypeReferenceOrTypePredicate() { + function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(typeName); - } - var node = createNode(151, typeName.pos); + var node = createNode(152, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -6794,24 +6894,24 @@ var ts; } function parseTypePredicate(lhs) { nextToken(); - var node = createNode(150, lhs.pos); + var node = createNode(151, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(161); + var node = createNode(162); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(154); + var node = createNode(155); parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(137); + var node = createNode(138); node.name = parseIdentifier(); if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6844,7 +6944,7 @@ var ts; } } function parseParameter() { - var node = createNode(138); + var node = createNode(139); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -6869,10 +6969,10 @@ var ts; signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } else if (parseOptional(returnToken)) { - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { @@ -6899,7 +6999,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 148) { + if (kind === 149) { parseExpected(92); } fillSignature(54, false, false, false, node); @@ -6939,7 +7039,7 @@ var ts; return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149, fullStart); + var node = createNode(150, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -6952,7 +7052,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(142, fullStart); + var method = createNode(143, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(54, false, false, false, method); @@ -6960,7 +7060,7 @@ var ts; return finishNode(method); } else { - var property = createNode(140, fullStart); + var property = createNode(141, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7005,14 +7105,14 @@ var ts; switch (token) { case 17: case 25: - return parseSignatureMember(147); + return parseSignatureMember(148); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148); + return parseSignatureMember(149); } case 9: case 8: @@ -7042,7 +7142,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(155); + var node = createNode(156); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7058,12 +7158,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(157); + var node = createNode(158); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(160); + var node = createNode(161); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7071,7 +7171,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(92); } fillSignature(34, false, false, false, node); @@ -7089,7 +7189,7 @@ var ts; case 120: case 131: var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); + return node || parseTypeReference(); case 9: return parseStringLiteralTypeNode(); case 103: @@ -7112,7 +7212,7 @@ var ts; case 17: return parseParenthesizedType(); default: - return parseTypeReferenceOrTypePredicate(); + return parseTypeReference(); } } function isStartOfType() { @@ -7145,7 +7245,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(156, type.pos); + var node = createNode(157, type.pos); node.elementType = type; type = finishNode(node); } @@ -7167,10 +7267,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(160, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(159, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7199,15 +7299,35 @@ var ts; } return false; } + function parseTypeOrTypePredicate() { + var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); + var type = parseType(); + if (typePredicateVariable) { + var node = createNode(151, typePredicateVariable.pos); + node.parameterName = typePredicateVariable; + node.type = type; + return finishNode(node); + } + else { + return type; + } + } + function parseTypePredicatePrefix() { + var id = parseIdentifier(); + if (token === 124 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + return id; + } + } function parseType() { return doOutsideOfContext(10, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152); + return parseFunctionOrConstructorType(153); } if (token === 92) { - return parseFunctionOrConstructorType(153); + return parseFunctionOrConstructorType(154); } return parseUnionTypeOrHigher(); } @@ -7326,7 +7446,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(186); + var node = createNode(187); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7340,8 +7460,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(176, identifier.pos); - var parameter = createNode(138, identifier.pos); + var node = createNode(177, identifier.pos); + var parameter = createNode(139, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7452,7 +7572,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(176); + var node = createNode(177); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); @@ -7484,7 +7604,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(184, leftOperand.pos); + var node = createNode(185, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -7497,7 +7617,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 134; + return t === 90 || t === 135; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7575,43 +7695,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(183, left.pos); + var node = createNode(184, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(191, left.pos); + var node = createNode(192, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(181); + var node = createNode(182); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(177); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(178); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(179); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(180); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token === 119) { if (inAwaitContext()) { @@ -7622,7 +7742,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(180); + var node = createNode(181); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -7641,7 +7761,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 173) { + if (simpleUnaryExpression.kind === 174) { 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 { @@ -7689,7 +7809,7 @@ var ts; } function parseIncrementExpression() { if (token === 41 || token === 42) { - var node = createNode(181); + var node = createNode(182); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -7701,7 +7821,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(182, expression.pos); + var node = createNode(183, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7724,7 +7844,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(168, expression.pos); + var node = createNode(169, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7743,8 +7863,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 237) { - var node = createNode(235, opening.pos); + if (opening.kind === 238) { + var node = createNode(236, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -7754,14 +7874,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 236); + ts.Debug.assert(opening.kind === 237); result = opening; } if (inExpressionContext && token === 25) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(183, result.pos); + var badNode = createNode(184, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -7773,13 +7893,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(238, scanner.getStartPos()); + var node = createNode(239, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 238: + case 239: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7815,7 +7935,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(237, fullStart); + node = createNode(238, fullStart); scanJsxText(); } else { @@ -7827,7 +7947,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(236, fullStart); + node = createNode(237, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7838,7 +7958,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(135, elementName.pos); + var node = createNode(136, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7846,7 +7966,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(242); + var node = createNode(243); parseExpected(15); if (token !== 16) { node.expression = parseAssignmentExpressionOrHigher(); @@ -7865,7 +7985,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(240); + var node = createNode(241); node.name = parseIdentifierName(); if (parseOptional(56)) { switch (token) { @@ -7880,7 +8000,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(241); + var node = createNode(242); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -7888,7 +8008,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(239); + var node = createNode(240); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -7901,7 +8021,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(173); + var node = createNode(174); parseExpected(25); node.type = parseType(); parseExpected(27); @@ -7912,7 +8032,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(168, expression.pos); + var propertyAccess = createNode(169, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7920,7 +8040,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(169, expression.pos); + var indexedAccess = createNode(170, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7934,7 +8054,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(172, expression.pos); + var tagExpression = createNode(173, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -7953,7 +8073,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(170, expression.pos); + var callExpr = createNode(171, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7961,7 +8081,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(170, expression.pos); + var callExpr = createNode(171, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8056,28 +8176,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(174); + var node = createNode(175); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(187); + var node = createNode(188); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(189) : + token === 24 ? createNode(190) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(166); + var node = createNode(167); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 1024; @@ -8087,10 +8207,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123)) { - return parseAccessorDeclaration(145, fullStart, decorators, modifiers); + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } else if (parseContextualModifier(129)) { - return parseAccessorDeclaration(146, fullStart, decorators, modifiers); + return parseAccessorDeclaration(147, fullStart, decorators, modifiers); } return undefined; } @@ -8111,7 +8231,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(248, fullStart); + var shorthandDeclaration = createNode(249, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56); @@ -8122,7 +8242,7 @@ var ts; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(247, fullStart); + var propertyAssignment = createNode(248, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -8132,7 +8252,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(167); + var node = createNode(168); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 1024; @@ -8146,7 +8266,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(175); + var node = createNode(176); setModifiers(node, parseModifiers()); parseExpected(87); node.asteriskToken = parseOptionalToken(37); @@ -8168,7 +8288,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(171); + var node = createNode(172); parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -8178,7 +8298,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(194); + var node = createNode(195); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8206,12 +8326,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(198); + var node = createNode(199); parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8221,7 +8341,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(199); + var node = createNode(200); parseExpected(79); node.statement = parseStatement(); parseExpected(104); @@ -8232,7 +8352,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(200); + var node = createNode(201); parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8255,21 +8375,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90)) { - var forInStatement = createNode(202, pos); + var forInStatement = createNode(203, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(134)) { - var forOfStatement = createNode(203, pos); + else if (parseOptional(135)) { + var forOfStatement = createNode(204, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(201, pos); + var forStatement = createNode(202, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8287,7 +8407,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 205 ? 70 : 75); + parseExpected(kind === 206 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8295,7 +8415,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -8304,7 +8424,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8313,7 +8433,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(243); + var node = createNode(244); parseExpected(71); node.expression = allowInAnd(parseExpression); parseExpected(54); @@ -8321,7 +8441,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(244); + var node = createNode(245); parseExpected(77); parseExpected(54); node.statements = parseList(3, parseStatement); @@ -8331,12 +8451,12 @@ var ts; return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(222, scanner.getStartPos()); + var caseBlock = createNode(223, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8344,14 +8464,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(100); node.tryBlock = parseBlock(false); node.catchClause = token === 72 ? parseCatchClause() : undefined; @@ -8362,7 +8482,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(246); + var result = createNode(247); parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); @@ -8372,7 +8492,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(212); + var node = createNode(213); parseExpected(76); parseSemicolon(); return finishNode(node); @@ -8381,13 +8501,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(209, fullStart); + var labeledStatement = createNode(210, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(197, fullStart); + var expressionStatement = createNode(198, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -8432,6 +8552,8 @@ var ts; return false; } continue; + case 134: + return nextToken() === 15; case 89: nextToken(); return token === 9 || token === 37 || @@ -8489,6 +8611,7 @@ var ts; case 125: case 126: case 132: + case 134: return true; case 112: case 110: @@ -8532,9 +8655,9 @@ var ts; case 86: return parseForOrForInOrForOfStatement(); case 75: - return parseBreakOrContinueStatement(204); - case 70: return parseBreakOrContinueStatement(205); + case 70: + return parseBreakOrContinueStatement(206); case 94: return parseReturnStatement(); case 105: @@ -8566,6 +8689,7 @@ var ts; case 112: case 115: case 113: + case 134: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8592,6 +8716,7 @@ var ts; return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); + case 134: case 125: case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -8604,7 +8729,7 @@ var ts; parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(233, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(234, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8625,16 +8750,16 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(189); + return createNode(190); } - var node = createNode(165); + var node = createNode(166); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(165); + var node = createNode(166); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54) { @@ -8649,14 +8774,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(163); + var node = createNode(164); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(164); + var node = createNode(165); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8675,7 +8800,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(213); + var node = createNode(214); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8684,7 +8809,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(214); + var node = createNode(215); switch (token) { case 102: break; @@ -8698,7 +8823,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 135 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8713,7 +8838,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(195, fullStart); + var node = createNode(196, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8721,7 +8846,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87); @@ -8734,7 +8859,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144, pos); + var node = createNode(145, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121); @@ -8743,7 +8868,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143, fullStart); + var method = createNode(144, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8756,7 +8881,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141, fullStart); + var property = createNode(142, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8852,7 +8977,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(139, decoratorStart); + var decorator = createNode(140, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8908,7 +9033,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(193); + var result = createNode(194); nextToken(); return finishNode(result); } @@ -8939,10 +9064,10 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 188); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 189); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 216); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -8977,7 +9102,7 @@ var ts; } function parseHeritageClause() { if (token === 83 || token === 106) { - var node = createNode(245); + var node = createNode(246); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8986,7 +9111,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(190); + var node = createNode(191); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9000,7 +9125,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107); @@ -9011,7 +9136,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); + var node = createNode(219, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(132); @@ -9023,13 +9148,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(249, scanner.getStartPos()); + var node = createNode(250, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219, fullStart); + var node = createNode(220, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81); @@ -9044,7 +9169,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(221, scanner.getStartPos()); + var node = createNode(222, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9055,7 +9180,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); var namespaceFlag = flags & 65536; node.decorators = decorators; setModifiers(node, modifiers); @@ -9067,16 +9192,25 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + if (token === 134) { + node.name = parseIdentifier(); + node.flags |= 2097152; + } + else { + node.name = parseLiteralNode(true); + } node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126)) { + if (token === 134) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + else if (parseOptional(126)) { flags |= 65536; } else { @@ -9104,7 +9238,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token !== 24 && token !== 133) { - var importEqualsDeclaration = createNode(223, fullStart); + var importEqualsDeclaration = createNode(224, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -9114,7 +9248,7 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(224, fullStart); + var importDeclaration = createNode(225, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || @@ -9128,13 +9262,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(225, fullStart); + var importClause = createNode(226, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(227); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(228); } return finishNode(importClause); } @@ -9144,7 +9278,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(234); + var node = createNode(235); parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); @@ -9162,7 +9296,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(226); + var namespaceImport = createNode(227); parseExpected(37); parseExpected(116); namespaceImport.name = parseIdentifier(); @@ -9170,14 +9304,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 227 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 228 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(232); + return parseImportOrExportSpecifier(233); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(229); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9196,13 +9330,13 @@ var ts; else { node.name = identifierName; } - if (kind === 228 && checkIdentifierIsKeyword) { + if (kind === 229 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { @@ -9210,7 +9344,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(231); + node.exportClause = parseNamedImportsOrExports(232); if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); @@ -9220,7 +9354,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56)) { @@ -9292,10 +9426,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 2 - || node.kind === 223 && node.moduleReference.kind === 234 - || node.kind === 224 - || node.kind === 229 + || node.kind === 224 && node.moduleReference.kind === 235 + || node.kind === 225 || node.kind === 230 + || node.kind === 231 ? node : undefined; }); @@ -9330,7 +9464,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(251); + var result = createNode(252); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9341,12 +9475,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47) { - var unionType = createNode(255, type.pos); + var unionType = createNode(256, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56) { - var optionalType = createNode(262, type.pos); + var optionalType = createNode(263, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9357,20 +9491,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(254, type.pos); + var arrayType = createNode(255, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } else if (token === 53) { - var nullableType = createNode(257, type.pos); + var nullableType = createNode(258, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49) { - var nonNullableType = createNode(258, type.pos); + var nonNullableType = createNode(259, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9414,27 +9548,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(266); + var result = createNode(267); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(265); + var result = createNode(266); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(264); + var result = createNode(265); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(263); + var result = createNode(264); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); @@ -9447,12 +9581,12 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(138); + var parameter = createNode(139); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(261); + var result = createNode(262); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9481,13 +9615,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(135, left.pos); + var result = createNode(136, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9495,7 +9629,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(260); + var result = createNode(261); result.name = parseSimplePropertyName(); if (token === 54) { nextToken(); @@ -9504,13 +9638,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(258); + var result = createNode(259); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(256); + var result = createNode(257); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9524,7 +9658,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(255); + var result = createNode(256); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9542,7 +9676,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(252); + var result = createNode(253); nextToken(); return finishNode(result); } @@ -9555,11 +9689,11 @@ var ts; token === 27 || token === 56 || token === 47) { - var result = createNode(253, pos); + var result = createNode(254, pos); return finishNode(result); } else { - var result = createNode(257, pos); + var result = createNode(258, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9630,7 +9764,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(267, start); + var result = createNode(268, start); result.tags = tags; return finishNode(result, end); } @@ -9667,7 +9801,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(268, atToken.pos); + var result = createNode(269, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9718,7 +9852,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(269, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9728,16 +9862,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(270, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 271; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9747,10 +9871,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 272; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(272, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 273; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9761,7 +9895,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(137, name_8.pos); + var typeParameter = createNode(138, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9772,7 +9906,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(272, atToken.pos); + var result = createNode(273, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -10094,16 +10228,16 @@ var ts; : 4; } function getModuleInstanceState(node) { - if (node.kind === 217 || node.kind === 218) { + if (node.kind === 218 || node.kind === 219) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 224 || node.kind === 223) && !(node.flags & 2)) { + else if ((node.kind === 225 || node.kind === 224) && !(node.flags & 2)) { return 0; } - else if (node.kind === 221) { + else if (node.kind === 222) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -10119,7 +10253,7 @@ var ts; }); return state; } - else if (node.kind === 220) { + else if (node.kind === 221) { return getModuleInstanceState(node.body); } else { @@ -10147,6 +10281,10 @@ var ts; var labelStack; var labelIndexMap; var implicitLabels; + var hasClassExtends; + var hasAsyncFunctions; + var hasDecorators; + var hasParameterDecorators; var inStrictMode; var symbolCount = 0; var Symbol; @@ -10173,6 +10311,10 @@ var ts; labelStack = undefined; labelIndexMap = undefined; implicitLabels = undefined; + hasClassExtends = false; + hasAsyncFunctions = false; + hasDecorators = false; + hasParameterDecorators = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -10195,17 +10337,17 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 220)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221)) { symbol.valueDeclaration = node; } } } function getDeclarationName(node) { if (node.name) { - if (node.kind === 220 && node.name.kind === 9) { - return "\"" + node.name.text + "\""; + if (ts.isAmbientModule(node)) { + return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 136) { + if (node.name.kind === 137) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -10216,21 +10358,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 144: + case 145: return "__constructor"; - case 152: - case 147: - return "__call"; case 153: case 148: - return "__new"; + return "__call"; + case 154: case 149: + return "__new"; + case 150: return "__index"; - case 230: + case 231: return "__export"; - case 229: + case 230: return node.isExportEquals ? "export=" : "default"; - case 183: + case 184: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -10242,8 +10384,8 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 215: case 216: + case 217: return node.flags & 512 ? "default" : undefined; } } @@ -10291,7 +10433,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; if (symbolFlags & 8388608) { - if (node.kind === 232 || (node.kind === 223 && hasExportModifier)) { + if (node.kind === 233 || (node.kind === 224 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10299,7 +10441,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 131072) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072)) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -10338,10 +10480,11 @@ var ts; var kind = node.kind; var flags = node.flags; flags &= ~1572864; - if (kind === 217) { + flags &= ~62914560; + if (kind === 218) { seenThisKeyword = false; } - var saveState = kind === 250 || kind === 221 || ts.isFunctionLikeKind(kind); + var saveState = kind === 251 || kind === 222 || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -10359,9 +10502,23 @@ var ts; flags |= 1048576; } } - if (kind === 217) { + if (kind === 218) { flags = seenThisKeyword ? flags | 262144 : flags & ~262144; } + if (kind === 251) { + if (hasClassExtends) { + flags |= 4194304; + } + if (hasDecorators) { + flags |= 8388608; + } + if (hasParameterDecorators) { + flags |= 16777216; + } + if (hasAsyncFunctions) { + flags |= 33554432; + } + } node.flags = flags; if (saveState) { hasExplicitReturn = savedHasExplicitReturn; @@ -10380,40 +10537,40 @@ var ts; return; } switch (node.kind) { - case 200: + case 201: bindWhileStatement(node); break; - case 199: + case 200: bindDoStatement(node); break; - case 201: + case 202: bindForStatement(node); break; - case 202: case 203: + case 204: bindForInOrForOfStatement(node); break; - case 198: + case 199: bindIfStatement(node); break; - case 206: - case 210: + case 207: + case 211: bindReturnOrThrow(node); break; + case 206: case 205: - case 204: bindBreakOrContinueStatement(node); break; - case 211: + case 212: bindTryStatement(node); break; - case 208: + case 209: bindSwitchStatement(node); break; - case 222: + case 223: bindCaseBlock(node); break; - case 209: + case 210: bindLabeledStatement(node); break; default: @@ -10475,14 +10632,14 @@ var ts; } function bindReturnOrThrow(n) { bind(n.expression); - if (n.kind === 206) { + if (n.kind === 207) { hasExplicitReturn = true; } currentReachabilityState = 4; } function bindBreakOrContinueStatement(n) { bind(n.label); - var isValidJump = jumpToLabel(n.label, n.kind === 205 ? currentReachabilityState : 4); + var isValidJump = jumpToLabel(n.label, n.kind === 206 ? currentReachabilityState : 4); if (isValidJump) { currentReachabilityState = 4; } @@ -10503,7 +10660,7 @@ var ts; var postSwitchLabel = pushImplicitLabel(); bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 244; }); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245; }); var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); } @@ -10528,37 +10685,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 188: - case 216: + case 189: case 217: - case 219: - case 155: - case 167: + case 218: + case 220: + case 156: + case 168: return 1; - case 147: case 148: case 149: - case 143: - case 142: - case 215: + case 150: case 144: + case 143: + case 216: case 145: case 146: - case 152: + case 147: case 153: - case 175: + case 154: case 176: - case 220: - case 250: - case 218: + case 177: + case 221: + case 251: + case 219: return 5; - case 246: - case 201: + case 247: case 202: case 203: - case 222: + case 204: + case 223: return 2; - case 194: + case 195: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10574,33 +10731,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 220: + case 221: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 250: + case 251: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 188: - case 216: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 219: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155: - case 167: + case 189: case 217: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 220: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 156: + case 168: + case 218: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 152: case 153: - case 147: + case 154: case 148: case 149: - case 143: - case 142: + case 150: case 144: + case 143: case 145: case 146: - case 215: - case 175: + case 147: + case 216: case 176: - case 218: + case 177: + case 219: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10615,11 +10772,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 250 ? node : node.body; - if (body.kind === 250 || body.kind === 221) { + var body = node.kind === 251 ? node : node.body; + if (body.kind === 251 || body.kind === 222) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 230 || stat.kind === 229) { + if (stat.kind === 231 || stat.kind === 230) { return true; } } @@ -10636,7 +10793,10 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 9) { + if (ts.isAmbientModule(node)) { + if (node.flags & 2) { + errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); + } declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -10678,7 +10838,7 @@ var ts; continue; } var identifier = prop.name; - var currentKind = prop.kind === 247 || prop.kind === 248 || prop.kind === 143 + var currentKind = prop.kind === 248 || prop.kind === 249 || prop.kind === 144 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10700,10 +10860,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 220: + case 221: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 250: + case 251: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10825,17 +10985,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 250: - case 221: + case 251: + case 222: updateStrictModeStatementList(node.statements); return; - case 194: + case 195: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 216: - case 188: + case 217: + case 189: inStrictMode = true; return; } @@ -10860,7 +11020,7 @@ var ts; switch (node.kind) { case 69: return checkStrictModeIdentifier(node); - case 183: + case 184: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -10883,94 +11043,91 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 246: + case 247: return checkStrictModeCatchClause(node); - case 177: + case 178: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 182: + case 183: return checkStrictModePostfixUnaryExpression(node); - case 181: + case 182: return checkStrictModePrefixUnaryExpression(node); - case 207: + case 208: return checkStrictModeWithStatement(node); - case 161: + case 162: seenThisKeyword = true; return; - case 150: + case 151: return checkTypePredicate(node); - case 137: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); case 138: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 139: return bindParameter(node); - case 213: - case 165: + case 214: + case 166: return bindVariableDeclarationOrBindingElement(node); + case 142: case 141: - case 140: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 247: case 248: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 249: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 250: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 147: case 148: case 149: + case 150: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 143: - case 142: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 215: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16, 106927); case 144: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 143: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 216: + return bindFunctionDeclaration(node); case 145: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 146: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 147: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 152: case 153: + case 154: return bindFunctionOrConstructorType(node); - case 155: + case 156: return bindAnonymousDeclaration(node, 2048, "__type"); - case 167: + case 168: return bindObjectLiteralExpression(node); - case 175: case 176: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16, bindingName); - case 170: + case 177: + return bindFunctionExpression(node); + case 171: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 188: - case 216: - return bindClassLikeDeclaration(node); + case 189: case 217: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 218: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 219: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 220: + return bindEnumDeclaration(node); + case 221: return bindModuleDeclaration(node); - case 223: - case 226: - case 228: - case 232: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 225: - return bindImportClause(node); - case 230: - return bindExportDeclaration(node); + case 224: + case 227: case 229: + case 233: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 226: + return bindImportClause(node); + case 231: + return bindExportDeclaration(node); + case 230: return bindExportAssignment(node); - case 250: + case 251: return bindSourceFileIfExternalModule(); } } @@ -10979,7 +11136,7 @@ var ts; if (parameterName && parameterName.kind === 69) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 161) { + if (parameterName && parameterName.kind === 162) { seenThisKeyword = true; } bind(type); @@ -10994,7 +11151,7 @@ var ts; bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 229 ? node.expression : node.right; + var boundExpression = node.kind === 230 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } @@ -11033,7 +11190,7 @@ var ts; bindExportAssignment(node); } function bindThisPropertyAssignment(node) { - if (container.kind === 175 || container.kind === 215) { + if (container.kind === 176 || container.kind === 216) { container.symbol.members = container.symbol.members || {}; declareSymbol(container.symbol.members, container.symbol, node, 4, 107455); } @@ -11055,7 +11212,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 216) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { + hasClassExtends = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } + if (node.kind === 217) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -11098,6 +11263,12 @@ var ts; } } function bindParameter(node) { + if (!ts.isDeclarationFile(file) && + !ts.isInAmbientContext(node) && + ts.nodeIsDecorated(node)) { + hasDecorators = true; + hasParameterDecorators = true; + } if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } @@ -11112,7 +11283,34 @@ var ts; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } } + function bindFunctionDeclaration(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + } + function bindFunctionExpression(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16, bindingName); + } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -11172,15 +11370,15 @@ var ts; function checkUnreachable(node) { switch (currentReachabilityState) { case 4: - var reportError = (ts.isStatement(node) && node.kind !== 196) || - node.kind === 216 || - (node.kind === 220 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 219 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatement(node) && node.kind !== 197) || + node.kind === 217 || + (node.kind === 221 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 220 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 195 || + (node.kind !== 196 || ts.getCombinedNodeFlags(node.declarationList) & 24576 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -11254,6 +11452,7 @@ var ts; getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, @@ -11268,6 +11467,7 @@ var ts; getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, @@ -11341,11 +11541,6 @@ var ts; var unionTypes = {}; var intersectionTypes = {}; var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -11478,7 +11673,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 220 && source.valueDeclaration.kind !== 220))) { + (target.valueDeclaration.kind === 221 && source.valueDeclaration.kind !== 221))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -11532,6 +11727,24 @@ var ts; } } } + function mergeModuleAugmentation(moduleName) { + var moduleAugmentation = moduleName.parent; + if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { + ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); + return; + } + if (ts.isGlobalScopeAugmentation(moduleAugmentation)) { + mergeSymbolTable(globals, moduleAugmentation.symbol.exports); + } + else { + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); + if (!mainModule) { + return; + } + mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + } function addToSymbolTable(target, source, message) { for (var id in source) { if (ts.hasProperty(source, id)) { @@ -11557,17 +11770,8 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } - function getSourceFile(node) { - return ts.getAncestor(node, 250); - } function isGlobalSourceFile(node) { - return node.kind === 250 && !ts.isExternalOrCommonJsModule(node); - } - function isPrimitiveApparentType(type) { - return type === globalStringType || - type === globalNumberType || - type === globalBooleanType || - type === globalESSymbolType; + return node.kind === 251 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -11605,18 +11809,18 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 213 || + return declaration.kind !== 214 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 195 || - declaration.parent.parent.kind === 201) { + if (declaration.parent.parent.kind === 196 || + declaration.parent.parent.kind === 202) { return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 203 || - declaration.parent.parent.kind === 202) { + else if (declaration.parent.parent.kind === 204 || + declaration.parent.parent.kind === 203) { var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); } @@ -11632,7 +11836,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 && + current.parent.kind === 142 && (current.parent.flags & 64) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -11657,15 +11861,15 @@ var ts; if (meaning & result.flags & 793056) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 138 || - lastLocation.kind === 137 + lastLocation.kind === 139 || + lastLocation.kind === 138 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 138 || + lastLocation.kind === 139 || (lastLocation === location.type && - result.valueDeclaration.kind === 138); + result.valueDeclaration.kind === 139); } } if (useResult) { @@ -11677,13 +11881,12 @@ var ts; } } switch (location.kind) { - case 250: + case 251: if (!ts.isExternalOrCommonJsModule(location)) break; - case 220: + case 221: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 250 || - (location.kind === 220 && location.name.kind === 9)) { + if (location.kind === 251 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -11693,7 +11896,7 @@ var ts; } if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 232)) { + ts.getDeclarationOfKind(moduleExports[name], 233)) { break; } } @@ -11701,13 +11904,13 @@ var ts; break loop; } break; - case 219: + case 220: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 142: case 141: - case 140: if (ts.isClassLike(location.parent) && !(location.flags & 64)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -11717,9 +11920,9 @@ var ts; } } break; - case 216: - case 188: case 217: + case 189: + case 218: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 64) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -11727,7 +11930,7 @@ var ts; } break loop; } - if (location.kind === 188 && meaning & 32) { + if (location.kind === 189 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -11735,28 +11938,28 @@ var ts; } } break; - case 136: + case 137: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 217) { + if (ts.isClassLike(grandparent) || grandparent.kind === 218) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 215: - case 176: + case 147: + case 216: + case 177: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 175: + case 176: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -11769,8 +11972,8 @@ var ts; } } break; - case 139: - if (location.parent && location.parent.kind === 138) { + case 140: + if (location.parent && location.parent.kind === 139) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -11786,7 +11989,9 @@ var ts; } if (!result) { if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } } return undefined; } @@ -11805,11 +12010,40 @@ var ts; } return result; } + function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { + if (!errorLocation || (errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + return false; + } + var container = ts.getThisContainer(errorLocation, true); + var location = container; + while (location) { + if (ts.isClassLike(location.parent)) { + var classSymbol = getSymbolOfNode(location.parent); + if (!classSymbol) { + break; + } + var constructorType = getTypeOfSymbol(classSymbol); + if (getPropertyOfType(constructorType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg), symbolToString(classSymbol)); + return true; + } + if (location === container && !(location.flags & 64)) { + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + if (getPropertyOfType(instanceType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return true; + } + } + } + location = location.parent; + } + return false; + } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 213), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -11826,10 +12060,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 223) { + if (node.kind === 224) { return node; } - while (node && node.kind !== 224) { + while (node && node.kind !== 225) { node = node.parent; } return node; @@ -11839,7 +12073,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 234) { + if (node.moduleReference.kind === 235) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11923,17 +12157,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 223: + case 224: return getTargetOfImportEqualsDeclaration(node); - case 225: - return getTargetOfImportClause(node); case 226: + return getTargetOfImportClause(node); + case 227: return getTargetOfNamespaceImport(node); - case 228: - return getTargetOfImportSpecifier(node); - case 232: - return getTargetOfExportSpecifier(node); case 229: + return getTargetOfImportSpecifier(node); + case 233: + return getTargetOfExportSpecifier(node); + case 230: return getTargetOfExportAssignment(node); } } @@ -11975,10 +12209,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 229) { + if (node.kind === 230) { checkExpressionCached(node.expression); } - else if (node.kind === 232) { + else if (node.kind === 233) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11988,17 +12222,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 223); + importDeclaration = ts.getAncestor(entityName, 224); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 135) { + if (entityName.kind === 69 || entityName.parent.kind === 136) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 223); + ts.Debug.assert(entityName.parent.kind === 224); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -12017,9 +12251,9 @@ var ts; return undefined; } } - else if (name.kind === 135 || name.kind === 168) { - var left = name.kind === 135 ? name.left : name.expression; - var right = name.kind === 135 ? name.right : name.name; + else if (name.kind === 136 || name.kind === 169) { + var left = name.kind === 136 ? name.left : name.expression; + var right = name.kind === 136 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12039,6 +12273,9 @@ var ts; return symbol.flags & meaning ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { + return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); + } + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { if (moduleReferenceExpression.kind !== 9) { return; } @@ -12051,19 +12288,24 @@ var ts; if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { - return symbol; + return getMergedSymbol(symbol); } } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReferenceLiteral.text); var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { - return sourceFile.symbol; + return getMergedSymbol(sourceFile.symbol); } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; + if (moduleNotFoundError) { + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + } + return undefined; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + if (moduleNotFoundError) { + error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + } + return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; @@ -12174,7 +12416,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 === 144 && ts.nodeIsPresent(member.body)) { + if (member.kind === 145 && ts.nodeIsPresent(member.body)) { return member; } } @@ -12240,17 +12482,17 @@ var ts; } } switch (location_1.kind) { - case 250: + case 251: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 220: + case 221: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 216: case 217: + case 218: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12283,7 +12525,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 232)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -12312,7 +12554,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 232)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -12367,8 +12609,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 220 && declaration.name.kind === 9) || - (declaration.kind === 250 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 251 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12400,11 +12641,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { meaning = 107455 | 1048576; } - else if (entityName.kind === 135 || entityName.kind === 168 || - entityName.parent.kind === 223) { + else if (entityName.kind === 136 || entityName.kind === 169 || + entityName.parent.kind === 224) { meaning = 1536; } else { @@ -12455,15 +12696,20 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent; } - if (node.kind === 218) { + if (node.kind === 219) { return getSymbolOfNode(node); } } return undefined; } + function isTopLevelInExternalModuleAugmentation(node) { + return node && node.parent && + node.parent.kind === 222 && + ts.isExternalModuleAugmentation(node.parent.parent); + } function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -12472,10 +12718,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 188: + case 189: return "(Anonymous class)"; - case 175: case 176: + case 177: return "(Anonymous function)"; } } @@ -12689,7 +12935,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 250 || declaration.parent.kind === 221; + return declaration.parent.kind === 251 || declaration.parent.kind === 222; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -12943,60 +13189,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 165: + case 166: return isDeclarationVisible(node.parent.parent); - case 213: + case 214: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 220: - case 216: + case 221: case 217: case 218: - case 215: case 219: - case 223: + case 216: + case 220: + case 224: + if (ts.isExternalModuleAugmentation(node)) { + return true; + } var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 2) && - !(node.kind !== 223 && parent_4.kind !== 250 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 224 && parent_4.kind !== 251 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 141: - case 140: - case 145: - case 146: - case 143: case 142: + case 141: + case 146: + case 147: + case 144: + case 143: if (node.flags & (16 | 32)) { return false; } - case 144: - case 148: - case 147: + case 145: case 149: - case 138: - case 221: - case 152: + case 148: + case 150: + case 139: + case 222: case 153: - case 155: - case 151: + case 154: case 156: + case 152: case 157: case 158: case 159: case 160: + case 161: return isDeclarationVisible(node.parent); - case 225: case 226: - case 228: - return false; - case 137: - case 250: - return true; + case 227: case 229: return false; + case 138: + case 251: + return true; + case 230: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -13004,10 +13253,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 229) { + if (node.parent && node.parent.kind === 230) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 232) { + else if (node.parent.kind === 233) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -13029,7 +13278,9 @@ var ts; var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); + if (importSymbol) { + buildVisibleNodeList(importSymbol.declarations); + } } }); } @@ -13082,10 +13333,10 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 213 ? node.parent.parent.parent : node.parent; + return node.kind === 214 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(prototype.parent); + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } function getTypeOfPropertyOfType(type, name) { @@ -13106,7 +13357,7 @@ var ts; case 9: case 8: return name.text; - case 136: + case 137: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -13114,7 +13365,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 136 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 137 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -13129,7 +13380,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 163) { + if (pattern.kind === 164) { var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { return anyType; @@ -13167,10 +13418,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 202) { - return anyType; - } if (declaration.parent.parent.kind === 203) { + return stringType; + } + if (declaration.parent.parent.kind === 204) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -13179,10 +13430,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138) { + if (declaration.kind === 139) { var func = declaration.parent; - if (func.kind === 146 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); + if (func.kind === 147 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13195,7 +13446,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 248) { + if (declaration.kind === 249) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -13242,7 +13493,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 189 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 190 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -13251,7 +13502,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 163 + return pattern.kind === 164 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -13261,10 +13512,10 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 247) { + if (declaration.kind === 248) { return type; } - if (type.flags & 134217728 && (declaration.kind === 141 || declaration.kind === 140)) { + if (type.flags & 134217728 && (declaration.kind === 142 || declaration.kind === 141)) { return type; } return getWidenedType(type); @@ -13272,7 +13523,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 139 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13285,17 +13536,17 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 246) { + if (declaration.parent.kind === 247) { return links.type = anyType; } - if (declaration.kind === 229) { + if (declaration.kind === 230) { return links.type = checkExpression(declaration.expression); } - if (declaration.kind === 183) { + if (declaration.kind === 184) { return links.type = checkExpression(declaration.right); } - if (declaration.kind === 168) { - if (declaration.parent.kind === 183) { + if (declaration.kind === 169) { + if (declaration.parent.kind === 184) { return links.type = checkExpressionCached(declaration.parent.right); } } @@ -13321,7 +13572,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 145) { + if (accessor.kind === 146) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13337,8 +13588,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 145); - var setter = ts.getDeclarationOfKind(symbol, 146); + var getter = ts.getDeclarationOfKind(symbol, 146); + var setter = ts.getDeclarationOfKind(symbol, 147); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -13364,7 +13615,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145); + var getter_1 = ts.getDeclarationOfKind(symbol, 146); 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)); } } @@ -13453,9 +13704,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 216 || node.kind === 188 || - node.kind === 215 || node.kind === 175 || - node.kind === 143 || node.kind === 176) { + if (node.kind === 217 || node.kind === 189 || + node.kind === 216 || node.kind === 176 || + node.kind === 144 || node.kind === 177) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -13464,15 +13715,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 217); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 218); 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 === 217 || node.kind === 216 || - node.kind === 188 || node.kind === 218) { + if (node.kind === 218 || node.kind === 217 || + node.kind === 189 || node.kind === 219) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -13595,7 +13846,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 218 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -13624,7 +13875,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217) { + if (declaration.kind === 218) { if (declaration.flags & 262144) { return false; } @@ -13673,7 +13924,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 218); + var declaration = ts.getDeclarationOfKind(symbol, 219); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -13704,7 +13955,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137).constraint) { + if (!ts.getDeclarationOfKind(symbol, 138).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -13756,11 +14007,11 @@ var ts; case 120: case 131: case 103: - case 162: + case 163: return true; - case 156: + case 157: return isIndependentType(node.elementType); - case 151: + case 152: return isIndependentTypeReference(node); } return false; @@ -13769,7 +14020,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 145 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -13785,12 +14036,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 141: - case 140: - return isIndependentVariableLikeDeclaration(declaration); - case 143: case 142: + case 141: + return isIndependentVariableLikeDeclaration(declaration); case 144: + case 143: + case 145: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -14303,7 +14554,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 144 ? + var classType = declaration.kind === 145 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : @@ -14319,7 +14570,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 162) { + if (param.type && param.type.kind === 163) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -14342,8 +14593,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146); + if (declaration.kind === 146 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 147); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -14361,19 +14612,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 152: case 153: - case 215: - case 143: - case 142: + case 154: + case 216: case 144: - case 147: + case 143: + case 145: case 148: case 149: - case 145: + case 150: case 146: - case 175: + case 147: case 176: + case 177: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -14453,7 +14704,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; + var isConstructor = signature.declaration.kind === 145 || signature.declaration.kind === 149; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -14490,7 +14741,7 @@ var ts; : undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 137).constraint; + return ts.getDeclarationOfKind(type.symbol, 138).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -14523,7 +14774,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138).parent); } function getTypeListId(types) { if (types) { @@ -14609,7 +14860,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 151 ? node.typeName : + var typeNameOrExpression = node.kind === 152 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -14635,9 +14886,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 216: case 217: - case 219: + case 218: + case 220: return declaration; } } @@ -14853,9 +15104,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 217)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 218)) { if (!(container.flags & 64) && - (container.kind !== 144 || ts.isNodeDescendentOf(node, container.body))) { + (container.kind !== 145 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -14899,34 +15150,34 @@ var ts; return esSymbolType; case 103: return voidType; - case 161: - return getTypeFromThisTypeNode(node); case 162: + return getTypeFromThisTypeNode(node); + case 163: return getTypeFromStringLiteralTypeNode(node); - case 151: - return getTypeFromTypeReference(node); - case 150: - return getTypeFromPredicateTypeNode(node); - case 190: - return getTypeFromTypeReference(node); - case 154: - return getTypeFromTypeQueryNode(node); - case 156: - return getTypeFromArrayTypeNode(node); - case 157: - return getTypeFromTupleTypeNode(node); - case 158: - return getTypeFromUnionTypeNode(node); - case 159: - return getTypeFromIntersectionTypeNode(node); - case 160: - return getTypeFromTypeNode(node.type); case 152: - case 153: + return getTypeFromTypeReference(node); + case 151: + return getTypeFromPredicateTypeNode(node); + case 191: + return getTypeFromTypeReference(node); case 155: + return getTypeFromTypeQueryNode(node); + case 157: + return getTypeFromArrayTypeNode(node); + case 158: + return getTypeFromTupleTypeNode(node); + case 159: + return getTypeFromUnionTypeNode(node); + case 160: + return getTypeFromIntersectionTypeNode(node); + case 161: + return getTypeFromTypeNode(node.type); + case 153: + case 154: + case 156: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 69: - case 135: + case 136: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15106,27 +15357,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 175: case 176: + case 177: return isContextSensitiveFunctionLikeDeclaration(node); - case 167: + case 168: return ts.forEach(node.properties, isContextSensitive); - case 166: + case 167: return ts.forEach(node.elements, isContextSensitive); - case 184: + case 185: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 183: + case 184: return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 247: + case 248: return isContextSensitive(node.initializer); + case 144: case 143: - case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 174: + case 175: return isContextSensitive(node.expression); } return false; @@ -15154,6 +15405,9 @@ var ts; function compareTypesIdentical(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 : 0; } + function compareTypesAssignable(source, target) { + return checkTypeRelatedTo(source, target, assignableRelation, undefined) ? -1 : 0; + } function isTypeSubtypeOf(source, target) { return checkTypeSubtypeOf(source, target, undefined); } @@ -15167,39 +15421,52 @@ var ts; return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { + return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + } + function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { if (source === target) { - return true; + return -1; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return 0; } source = getErasedSignature(source); target = getErasedSignature(target); + var result = -1; var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); + var sourceParams = source.parameters; + var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var related = isTypeAssignableTo(t, s) || isTypeAssignableTo(s, t); + var s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target); + var related = compareTypes(t, s, false) || compareTypes(s, t, reportErrors); if (!related) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); + } + return 0; } + result &= related; } if (!ignoreReturnTypes) { var targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) { - return true; + return result; } var sourceReturnType = getReturnTypeOfSignature(source); if (targetReturnType.flags & 134217728 && targetReturnType.predicate.kind === 1) { if (!(sourceReturnType.flags & 134217728)) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; } } - return isTypeAssignableTo(sourceReturnType, targetReturnType); + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); } - return true; + return result; } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); @@ -15242,18 +15509,12 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; - var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + var result = isRelatedTo(source, target, !!errorNode, headMessage); if (overflow) { error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } else if (errorInfo) { - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); } @@ -15261,6 +15522,7 @@ var ts; } return result !== 0; function reportError(message, arg0, arg1, arg2) { + ts.Debug.assert(!!errorNode); errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } function reportRelationError(message, source, target) { @@ -15381,10 +15643,10 @@ var ts; return result; } } - var apparentType = getApparentType(source); - if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + var apparentSource = getApparentType(source); + if (apparentSource.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 16777726); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } @@ -15439,6 +15701,7 @@ var ts; var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { if (reportErrors) { + ts.Debug.assert(!!errorNode); errorNode = prop.valueDeclaration; reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } @@ -15531,7 +15794,7 @@ var ts; var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { - if (elaborateErrors && related === 2) { + if (reportErrors && related === 2) { relation[id] = 3; } else { @@ -15725,7 +15988,7 @@ var ts; shouldElaborateErrors = false; } } - if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind)); } return 0; @@ -15734,65 +15997,7 @@ var ts; return result; } function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) { - return result; - } - var sourceReturnType = getReturnTypeOfSignature(source); - if (targetReturnType.flags & 134217728 && targetReturnType.predicate.kind === 1) { - if (!(sourceReturnType.flags & 134217728)) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0; - } - } - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -16155,22 +16360,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 142: case 141: - case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 138: + case 139: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 215: + case 216: + case 144: case 143: - case 142: - case 145: case 146: - case 175: + case 147: case 176: + case 177: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16459,10 +16664,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 154: + case 155: return true; case 69: - case 135: + case 136: node = node.parent; continue; default: @@ -16503,55 +16708,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 183: + case 184: return isAssignedInBinaryExpression(node); - case 213: - case 165: - return isAssignedInVariableDeclaration(node); - case 163: - case 164: + case 214: case 166: + return isAssignedInVariableDeclaration(node); + case 164: + case 165: case 167: case 168: case 169: case 170: case 171: - case 173: - case 191: + case 172: case 174: - case 181: - case 177: - case 180: - case 178: - case 179: + case 192: + case 175: case 182: - case 186: - case 184: + case 178: + case 181: + case 179: + case 180: + case 183: case 187: - case 194: + case 185: + case 188: case 195: - case 197: + case 196: case 198: case 199: case 200: case 201: case 202: case 203: - case 206: + case 204: case 207: case 208: - case 243: - case 244: case 209: + case 244: + case 245: case 210: case 211: - case 246: - case 235: + case 212: + case 247: case 236: - case 240: - case 241: case 237: + case 241: case 242: + case 238: + case 243: return ts.forEachChild(node, isAssignedIn); } return false; @@ -16561,7 +16766,7 @@ var ts; var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -16569,13 +16774,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 198: + case 199: + case 185: case 184: - case 183: nodeStack.push({ node: node, child: child }); break; - case 250: - case 220: + case 251: + case 221: break loop; } if (node === top_1) { @@ -16586,17 +16791,17 @@ var ts; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 198: + case 199: if (child !== node_1.expression) { type = narrowType(type, node_1.expression, child === node_1.thenStatement); } break; - case 184: + case 185: if (child !== node_1.condition) { type = narrowType(type, node_1.condition, child === node_1.whenTrue); } break; - case 183: + case 184: if (child === node_1.right) { if (node_1.operatorToken.kind === 51) { type = narrowType(type, node_1.left, true); @@ -16620,7 +16825,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 178 || expr.right.kind !== 9) { + if (expr.left.kind !== 179 || expr.right.kind !== 9) { return type; } var left = expr.left; @@ -16635,9 +16840,6 @@ var ts; if (typeInfo && typeInfo.type === undefinedType) { return type; } - if (!!(type.flags & 1) && typeInfo && assumeTrue) { - return typeInfo.type; - } var flags; if (typeInfo) { flags = typeInfo.flags; @@ -16647,6 +16849,9 @@ var ts; flags = 132 | 258 | 16777216 | 8; } if (!(type.flags & 16384)) { + if (assumeTrue && typeInfo && isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } return filterUnion(type) ? type : emptyUnionType; } return getUnionType(ts.filter(type.types, filterUnion), true); @@ -16761,7 +16966,7 @@ var ts; return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); } function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 169 || expression.kind === 168) { + if (expression.kind === 170 || expression.kind === 169) { var accessExpression = expression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { @@ -16774,18 +16979,18 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69: - case 168: - case 135: + case 169: + case 136: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 170: + case 171: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 174: + case 175: return narrowType(type, expr.expression, assumeTrue); - case 183: + case 184: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -16800,20 +17005,20 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 181: + case 182: if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; + case 170: case 169: - case 168: return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 174) { + while (expression.kind === 175) { expression = expression.expression; } return expression; @@ -16822,7 +17027,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 176) { + if (container.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -16853,7 +17058,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 246) { + symbol.valueDeclaration.parent.kind === 247) { return; } var container; @@ -16862,11 +17067,11 @@ var ts; } else { container = symbol.valueDeclaration; - while (container.kind !== 214) { + while (container.kind !== 215) { container = container.parent; } container = container.parent; - if (container.kind === 195) { + if (container.kind === 196) { container = container.parent; } } @@ -16885,7 +17090,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 141 || container.kind === 144) { + if (container.kind === 142 || container.kind === 145) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -16896,29 +17101,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 176) { + if (container.kind === 177) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 220: + case 221: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 219: + case 220: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 144: + case 145: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 142: case 141: - case 140: if (container.flags & 64) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 136: + case 137: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -16929,7 +17134,7 @@ var ts; var symbol = getSymbolOfNode(container.parent); return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } - if (ts.isInJavaScriptFile(node) && container.kind === 175) { + if (ts.isInJavaScriptFile(node) && container.kind === 176) { if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -16945,18 +17150,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138) { + if (n.kind === 139) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 170 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 171 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 176) { + while (container && container.kind === 177) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -16965,16 +17170,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 136) { + while (current && current !== container && current.kind !== 137) { current = current.parent; } - if (current && current.kind === 136) { + if (current && current.kind === 137) { 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 === 167)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -16992,7 +17197,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 167) { + if (container.parent.kind === 168) { 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; @@ -17010,7 +17215,7 @@ var ts; } return unknownType; } - if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 145 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -17022,24 +17227,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 144; + return container.kind === 145; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 167) { + if (ts.isClassLike(container.parent) || container.parent.kind === 168) { if (container.flags & 64) { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || - container.kind === 146; + return container.kind === 144 || + container.kind === 143 || + container.kind === 146 || + container.kind === 147; } else { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || + return container.kind === 144 || + container.kind === 143 || container.kind === 146 || + container.kind === 147 || + container.kind === 142 || container.kind === 141 || - container.kind === 140 || - container.kind === 144; + container.kind === 145; } } } @@ -17074,7 +17279,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138) { + if (declaration.kind === 139) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17107,7 +17312,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 && node.parent.initializer === node) { + if (node.parent.kind === 139 && node.parent.initializer === node) { return true; } node = node.parent; @@ -17116,8 +17321,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 144 || - functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { + functionDecl.kind === 145 || + functionDecl.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -17136,7 +17341,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 172) { + if (template.parent.kind === 173) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17247,13 +17452,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 240) { + if (attribute.kind === 241) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 241) { + else if (attribute.kind === 242) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -17271,40 +17476,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 213: - case 138: + case 214: + case 139: + case 142: case 141: - case 140: - case 165: - return getContextualTypeForInitializerExpression(node); - case 176: - case 206: - return getContextualTypeForReturnExpression(node); - case 186: - return getContextualTypeForYieldOperand(parent); - case 170: - case 171: - return getContextualTypeForArgument(parent, node); - case 173: - case 191: - return getTypeFromTypeNode(parent.type); - case 183: - return getContextualTypeForBinaryOperand(node); - case 247: - return getContextualTypeForObjectLiteralElement(parent); case 166: - return getContextualTypeForElementExpression(node); - case 184: - return getContextualTypeForConditionalOperand(node); - case 192: - ts.Debug.assert(parent.parent.kind === 185); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 177: + case 207: + return getContextualTypeForReturnExpression(node); + case 187: + return getContextualTypeForYieldOperand(parent); + case 171: + case 172: + return getContextualTypeForArgument(parent, node); case 174: + case 192: + return getTypeFromTypeNode(parent.type); + case 184: + return getContextualTypeForBinaryOperand(node); + case 248: + return getContextualTypeForObjectLiteralElement(parent); + case 167: + return getContextualTypeForElementExpression(node); + case 185: + return getContextualTypeForConditionalOperand(node); + case 193: + ts.Debug.assert(parent.parent.kind === 186); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 175: return getContextualType(parent); - case 242: + case 243: return getContextualType(parent); - case 240: case 241: + case 242: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -17319,7 +17524,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 175 || node.kind === 176; + return node.kind === 176 || node.kind === 177; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -17327,7 +17532,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -17367,13 +17572,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 183 && parent.operatorToken.kind === 56 && parent.left === node) { + if (parent.kind === 184 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 247) { + if (parent.kind === 248) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 166) { + if (parent.kind === 167) { return isAssignmentTarget(parent); } return false; @@ -17383,8 +17588,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 165 && !!node.initializer) || - (node.kind === 183 && node.operatorToken.kind === 56); + return (node.kind === 166 && !!node.initializer) || + (node.kind === 184 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -17393,7 +17598,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 187) { + if (inDestructuringPattern && e.kind === 188) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -17405,7 +17610,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 187; + hasSpreadElement = hasSpreadElement || e.kind === 188; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -17416,7 +17621,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 164 || pattern.kind === 166)) { + if (pattern && (pattern.kind === 165 || pattern.kind === 167)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -17424,7 +17629,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 189) { + if (patternElement.kind !== 190) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -17439,7 +17644,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 137 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -17470,31 +17675,31 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 163 || contextualType.pattern.kind === 167); + (contextualType.pattern.kind === 164 || contextualType.pattern.kind === 168); var typeFlags = 0; var patternWithComputedProperties = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 247 || - memberDecl.kind === 248 || + if (memberDecl.kind === 248 || + memberDecl.kind === 249 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 247) { + if (memberDecl.kind === 248) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 143) { + else if (memberDecl.kind === 144) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 248); + ts.Debug.assert(memberDecl.kind === 249); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 247 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 248 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 248 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 249 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -17521,7 +17726,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); + ts.Debug.assert(memberDecl.kind === 146 || memberDecl.kind === 147); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -17579,13 +17784,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 242: + case 243: checkJsxExpression(child); break; - case 235: + case 236: checkJsxElement(child); break; - case 236: + case 237: checkJsxSelfClosingElement(child); break; } @@ -17596,7 +17801,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135) { + if (tagName.kind === 136) { return false; } else { @@ -17690,6 +17895,7 @@ var ts; if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } + return unknownSymbol; } } function lookupClassTag(node) { @@ -17760,17 +17966,21 @@ var ts; var sym = getJsxElementTagSymbol(node); if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); - var callSignature = getSingleCallSignature(getTypeOfSymbol(sym)); - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType) && (paramType.flags & 80896)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } var elemClassType = getJsxGlobalElementClassType(); + if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { + var elemType = getTypeOfSymbol(sym); + var callSignatures = elemType && getSignaturesOfType(elemType, 0); + var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return links.resolvedJsxType = paramType; + } + } if (elemClassType) { checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } @@ -17868,11 +18078,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 240) { + if (node.attributes[i].kind === 241) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 241); + ts.Debug.assert(node.attributes[i].kind === 242); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -17898,7 +18108,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 141; + return s.valueDeclaration ? s.valueDeclaration.kind : 142; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; @@ -17907,10 +18117,10 @@ var ts; var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (left.kind === 95) { - var errorNode = node.kind === 168 ? + var errorNode = node.kind === 169 ? node.name : node.right; - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 143) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 144) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -17979,7 +18189,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 168 + var left = node.kind === 169 ? node.expression : node.left; var type = checkExpression(left); @@ -17991,10 +18201,47 @@ var ts; } return true; } + function getForInVariableSymbol(node) { + var initializer = node.initializer; + if (initializer.kind === 215) { + var variable = initializer.declarations[0]; + if (variable && !ts.isBindingPattern(variable.name)) { + return getSymbolOfNode(variable); + } + } + else if (initializer.kind === 69) { + return getResolvedSymbol(initializer); + } + return undefined; + } + function hasNumericPropertyNames(type) { + return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0); + } + function isForInVariableForNumericPropertyNames(expr) { + var e = skipParenthesizedNodes(expr); + if (e.kind === 69) { + var symbol = getResolvedSymbol(e); + if (symbol.flags & 3) { + var child = expr; + var node = expr.parent; + while (node) { + if (node.kind === 203 && + child === node.statement && + getForInVariableSymbol(node) === symbol && + hasNumericPropertyNames(checkExpression(node.expression))) { + return true; + } + child = node; + node = node.parent; + } + } + } + return false; + } function checkIndexedAccess(node) { if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 171 && node.parent.expression === node) { + var sourceFile = ts.getSourceFileOfNode(node); + if (node.parent.kind === 172 && 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); @@ -18031,7 +18278,7 @@ var ts; } } if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { return numberIndexType; @@ -18042,7 +18289,9 @@ var ts; return stringIndexType; } if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + 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; } @@ -18053,7 +18302,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 169 || indexArgumentExpression.kind === 168) { + if (indexArgumentExpression.kind === 170 || indexArgumentExpression.kind === 169) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -18096,10 +18345,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 172) { + if (node.kind === 173) { checkExpression(node.template); } - else if (node.kind !== 139) { + else if (node.kind !== 140) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18150,7 +18399,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 187) { + if (arg && arg.kind === 188) { return i; } } @@ -18162,11 +18411,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 172) { + if (node.kind === 173) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 185) { + if (tagExpression.template.kind === 186) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -18178,7 +18427,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 139) { + else if (node.kind === 140) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -18186,7 +18435,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 171); + ts.Debug.assert(callExpression.kind === 172); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -18239,7 +18488,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 !== 189) { + if (arg === undefined || arg.kind !== 190) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -18288,7 +18537,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 !== 189) { + if (arg === undefined || arg.kind !== 190) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -18307,16 +18556,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 172) { + if (node.kind === 173) { var template = node.template; args = [undefined]; - if (template.kind === 185) { + if (template.kind === 186) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 139) { + else if (node.kind === 140) { return undefined; } else { @@ -18325,21 +18574,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139) { + if (node.kind === 140) { switch (node.parent.kind) { - case 216: - case 188: + case 217: + case 189: return 1; - case 141: + case 142: return 2; - case 143: - case 145: + case 144: case 146: + case 147: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 138: + case 139: return 3; } } @@ -18348,48 +18597,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 216) { + if (node.kind === 217) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 138) { + if (node.kind === 139) { node = node.parent; - if (node.kind === 144) { + if (node.kind === 145) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { + if (node.kind === 142 || + node.kind === 144 || + node.kind === 146 || + node.kind === 147) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 216) { + if (node.kind === 217) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 138) { + if (node.kind === 139) { node = node.parent; - if (node.kind === 144) { + if (node.kind === 145) { return anyType; } } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { + if (node.kind === 142 || + node.kind === 144 || + node.kind === 146 || + node.kind === 147) { var element = node; switch (element.name.kind) { case 69: case 8: case 9: return getStringLiteralTypeForText(element.name.text); - case 136: + case 137: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; @@ -18406,20 +18655,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 216) { + if (node.kind === 217) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 138) { + if (node.kind === 139) { return numberType; } - if (node.kind === 141) { + if (node.kind === 142) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143 || - node.kind === 145 || - node.kind === 146) { + if (node.kind === 144 || + node.kind === 146 || + node.kind === 147) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -18440,26 +18689,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 139) { + if (node.kind === 140) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 172) { + else if (argIndex === 0 && node.kind === 173) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 139 || - (argIndex === 0 && node.kind === 172)) { + if (node.kind === 140 || + (argIndex === 0 && node.kind === 173)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139) { + if (node.kind === 140) { return node.expression; } - else if (argIndex === 0 && node.kind === 172) { + else if (argIndex === 0 && node.kind === 173) { return node.template; } else { @@ -18467,8 +18716,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 172; - var isDecorator = node.kind === 139; + var isTaggedTemplate = node.kind === 173; + var isDecorator = node.kind === 140; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -18700,16 +18949,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 216: - case 188: + case 217: + case 189: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141: + case 142: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143: - case 145: + case 144: case 146: + case 147: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -18737,16 +18986,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 170) { + if (node.kind === 171) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 171) { + else if (node.kind === 172) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 172) { + else if (node.kind === 173) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 139) { + else if (node.kind === 140) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -18768,12 +19017,12 @@ var ts; if (node.expression.kind === 95) { return voidType; } - if (node.kind === 171) { + if (node.kind === 172) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 144 && - declaration.kind !== 148 && - declaration.kind !== 153) { + declaration.kind !== 145 && + declaration.kind !== 149 && + declaration.kind !== 154) { var funcSymbol = checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16)) { return getInferredClassType(funcSymbol); @@ -18827,7 +19076,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189) { + if (element.kind !== 190) { if (element.name.kind === 69) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -18861,7 +19110,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 194) { + if (func.body.kind !== 195) { 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); @@ -18966,7 +19215,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 194 || !(func.flags & 524288)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 || !(func.flags & 524288)) { return; } var hasExplicitReturn = func.flags & 1048576; @@ -18986,18 +19235,14 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 175) { + if (!hasGrammarError && node.kind === 176) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); @@ -19025,18 +19270,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { + if (produceDiagnostics && node.kind !== 144 && node.kind !== 143) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -19045,7 +19287,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 194) { + if (node.body.kind === 195) { checkSourceElement(node.body); } else { @@ -19080,13 +19322,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 168: { + case 169: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 169: + case 170: return true; - case 174: + case 175: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -19095,11 +19337,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 69: - case 168: { + case 169: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; } - case 169: { + case 170: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -19109,7 +19351,7 @@ var ts; } return false; } - case 174: + case 175: return isConstVariableReference(n.expression); default: return false; @@ -19239,9 +19481,9 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 247 || p.kind === 248) { + if (p.kind === 248 || p.kind === 249) { var name_13 = p.name; - if (name_13.kind === 136) { + if (name_13.kind === 137) { checkComputedPropertyName(name_13); } if (isComputedNonLiteralName(name_13)) { @@ -19254,7 +19496,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - if (p.kind === 248) { + if (p.kind === 249) { checkDestructuringAssignment(p, type); } else { @@ -19276,8 +19518,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189) { - if (e.kind !== 187) { + if (e.kind !== 190) { + if (e.kind !== 188) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19302,7 +19544,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 183 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 184 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19316,7 +19558,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 248) { + if (exprOrAssignment.kind === 249) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -19326,14 +19568,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 183 && target.operatorToken.kind === 56) { + if (target.kind === 184 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 167) { + if (target.kind === 168) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 166) { + if (target.kind === 167) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19350,7 +19592,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 167 || left.kind === 166)) { + if (operator === 56 && (left.kind === 168 || left.kind === 167)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -19574,14 +19816,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -19604,7 +19846,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 135) { + if (node.kind === 136) { type = checkQualifiedName(node); } else { @@ -19612,9 +19854,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 168 && node.parent.expression === node) || - (node.parent.kind === 169 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 169 && node.parent.expression === node) || + (node.parent.kind === 170 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 136) && 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); } @@ -19640,7 +19882,7 @@ var ts; return booleanType; case 8: return checkNumericLiteral(node); - case 185: + case 186: return checkTemplateExpression(node); case 9: return checkStringLiteralExpression(node); @@ -19648,58 +19890,58 @@ var ts; return stringType; case 10: return globalRegExpType; - case 166: - return checkArrayLiteral(node, contextualMapper); case 167: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 168: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 169: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 170: + return checkIndexedAccess(node); case 171: - return checkCallExpression(node); case 172: - return checkTaggedTemplateExpression(node); - case 174: - return checkExpression(node.expression, contextualMapper); - case 188: - return checkClassExpression(node); - case 175: - case 176: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 178: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 173: - case 191: - return checkAssertion(node); - case 177: - return checkDeleteExpression(node); - case 179: - return checkVoidExpression(node); - case 180: - return checkAwaitExpression(node); - case 181: - return checkPrefixUnaryExpression(node); - case 182: - return checkPostfixUnaryExpression(node); - case 183: - return checkBinaryExpression(node, contextualMapper); - case 184: - return checkConditionalExpression(node, contextualMapper); - case 187: - return checkSpreadElementExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 175: + return checkExpression(node.expression, contextualMapper); case 189: + return checkClassExpression(node); + case 176: + case 177: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 179: + return checkTypeOfExpression(node); + case 174: + case 192: + return checkAssertion(node); + case 178: + return checkDeleteExpression(node); + case 180: + return checkVoidExpression(node); + case 181: + return checkAwaitExpression(node); + case 182: + return checkPrefixUnaryExpression(node); + case 183: + return checkPostfixUnaryExpression(node); + case 184: + return checkBinaryExpression(node, contextualMapper); + case 185: + return checkConditionalExpression(node, contextualMapper); + case 188: + return checkSpreadElementExpression(node, contextualMapper); + case 190: return undefinedType; - case 186: + case 187: return checkYieldExpression(node); - case 242: + case 243: return checkJsxExpression(node); - case 235: - return checkJsxElement(node); case 236: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 237: + return checkJsxSelfClosingElement(node); + case 238: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -19720,7 +19962,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 56) { func = ts.getContainingFunction(node); - if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 145 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -19735,9 +19977,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 143 || - node.kind === 215 || - node.kind === 175; + return node.kind === 144 || + node.kind === 216 || + node.kind === 176; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -19751,104 +19993,97 @@ var ts; } return -1; } - function isInLegalParameterTypePredicatePosition(node) { - switch (node.parent.kind) { - case 176: - case 147: - case 215: - case 175: - case 152: - case 143: - case 142: - return node === node.parent.type; + function checkTypePredicate(node) { + var parent = getTypePredicateParent(node); + if (!parent) { + return; + } + var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); + if (!returnType || !(returnType.flags & 134217728)) { + return; + } + var parameterName = node.parameterName; + if (parameterName.kind === 162) { + getTypeFromThisTypeNode(parameterName); + } + else { + var typePredicate = returnType.predicate; + if (typePredicate.parameterIndex >= 0) { + if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type); + } + } + else if (parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { + var name_14 = _a[_i].name; + if ((name_14.kind === 164 || + name_14.kind === 165) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + hasReportedError = true; + break; + } + } + if (!hasReportedError) { + error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } } - return false; } - function isInLegalThisTypePredicatePosition(node) { - if (isInLegalParameterTypePredicatePosition(node)) { - return true; - } + function getTypePredicateParent(node) { switch (node.parent.kind) { - case 141: - case 140: - case 145: - return node === node.parent.type; + case 177: + case 148: + case 216: + case 176: + case 153: + case 144: + case 143: + var parent_6 = node.parent; + if (node === parent_6.type) { + return parent_6; + } + } + } + function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var name_15 = _a[_i].name; + if (name_15.kind === 69 && + name_15.text === predicateVariableName) { + error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); + return true; + } + else if (name_15.kind === 165 || + name_15.kind === 164) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + return true; + } + } } - return false; } function checkSignatureDeclaration(node) { - if (node.kind === 149) { + if (node.kind === 150) { checkGrammarIndexSignature(node); } - else if (node.kind === 152 || node.kind === 215 || node.kind === 153 || - node.kind === 147 || node.kind === 144 || - node.kind === 148) { + else if (node.kind === 153 || node.kind === 216 || node.kind === 154 || + node.kind === 148 || node.kind === 145 || + node.kind === 149) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - if (!returnType || !(returnType.flags & 134217728)) { - return; - } - var typePredicate = returnType.predicate; - var typePredicateNode = node.type; - checkSourceElement(typePredicateNode); - if (ts.isIdentifierTypePredicate(typePredicate)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 163 || - param.name.kind === 164) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 164 || - element.name.kind === 163) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - } - else { - checkSourceElement(node.type); - } - } + checkSourceElement(node.type); if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 148: + case 149: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 147: + case 148: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -19870,7 +20105,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 217) { + if (node.kind === 218) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -19933,7 +20168,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 170 && n.expression.kind === 95; + return n.kind === 171 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -19954,12 +20189,12 @@ var ts; if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 175 && n.kind !== 215) { + else if (n.kind !== 176 && n.kind !== 216) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 141 && + return n.kind === 142 && !(n.flags & 64) && !!n.initializer; } @@ -19979,7 +20214,7 @@ var ts; var superCallStatement; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 197 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 198 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -20005,7 +20240,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 145) { + if (node.kind === 146) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { if (node.flags & 1048576) { if (compilerOptions.noImplicitReturns) { @@ -20017,11 +20252,11 @@ var ts; } } } - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 145 ? 146 : 145; + var otherKind = node.kind === 146 ? 147 : 146; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 56) !== (otherAccessor.flags & 56))) { @@ -20038,7 +20273,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 167) { + if (node.parent.kind !== 168) { checkSourceElement(node.body); } else { @@ -20120,9 +20355,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 217) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); - var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 218) { + ts.Debug.assert(signatureDeclarationNode.kind === 148 || signatureDeclarationNode.kind === 149); + var signatureKind = signatureDeclarationNode.kind === 148 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -20140,9 +20375,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 217 && - n.parent.kind !== 216 && - n.parent.kind !== 188 && + if (n.parent.kind !== 218 && + n.parent.kind !== 217 && + n.parent.kind !== 189 && ts.isInAmbientContext(n)) { if (!(flags & 4)) { flags |= 2; @@ -20219,7 +20454,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 === 143 || node.kind === 142) && + var reportError = (node.kind === 144 || node.kind === 143) && (node.flags & 64) !== (subsequentNode.flags & 64); if (reportError) { var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -20253,11 +20488,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 217 || node.parent.kind === 155 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 218 || node.parent.kind === 156 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 215 || node.kind === 143 || node.kind === 142 || node.kind === 144) { + if (node.kind === 216 || node.kind === 144 || node.kind === 143 || node.kind === 145) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20370,16 +20605,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 217: + case 218: return 2097152; - case 220: - return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 + case 221: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 216: - case 219: + case 217: + case 220: return 2097152 | 1048576; - case 223: + case 224: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -20510,22 +20745,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 216: + case 217: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 141: + case 142: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 143: - case 145: + case 144: case 146: + case 147: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -20534,9 +20769,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 151) { + if (node && node.kind === 152) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 ? 793056 : 1536; + var meaning = root.parent.kind === 152 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -20570,28 +20805,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 216: + case 217: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 143: - case 145: + case 144: case 146: + case 147: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 141: - case 138: + case 142: + case 139: checkTypeAnnotationAsExpression(node); break; } } - emitDecorate = true; - if (node.kind === 138) { - emitParam = true; - } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { @@ -20606,16 +20837,13 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - if (node.name && node.name.kind === 136) { + if (node.name && node.name.kind === 137) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.forEach(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(getSourceFile(declaration)) ? + var firstDeclaration = ts.forEach(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)) ? declaration : undefined; }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -20641,7 +20869,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 194) { + if (node.kind === 195) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -20660,19 +20888,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 141 || - node.kind === 140 || + if (node.kind === 142 || + node.kind === 141 || + node.kind === 144 || node.kind === 143 || - node.kind === 142 || - node.kind === 145 || - node.kind === 146) { + node.kind === 146 || + node.kind === 147) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 139 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -20720,11 +20948,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 220 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 221 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 250 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 251 && 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)); } } @@ -20732,7 +20960,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 213 && !node.initializer) { + if (node.kind === 214 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -20742,25 +20970,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 214); - var container = varDeclList.parent.kind === 195 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215); + var container = varDeclList.parent.kind === 196 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 194 && ts.isFunctionLike(container.parent) || + (container.kind === 195 && ts.isFunctionLike(container.parent) || + container.kind === 222 || container.kind === 221 || - container.kind === 220 || - container.kind === 250); + container.kind === 251); if (!namesShareScope) { - var name_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + var name_16 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 138) { + if (ts.getRootDeclaration(node).kind !== 139) { return; } var func = ts.getContainingFunction(node); @@ -20769,7 +20997,7 @@ var ts; if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138) { + if (referencedSymbol.valueDeclaration.kind === 139) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -20789,26 +21017,26 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 165) { - if (node.propertyName && node.propertyName.kind === 136) { + if (node.kind === 166) { + if (node.propertyName && node.propertyName.kind === 137) { checkComputedPropertyName(node.propertyName); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 139 && 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) { + if (node.initializer && node.parent.parent.kind !== 203) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -20817,7 +21045,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { - if (node.initializer) { + if (node.initializer && node.parent.parent.kind !== 203) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -20831,9 +21059,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 141 && node.kind !== 140) { + if (node.kind !== 142 && node.kind !== 141) { checkExportsOnMergedDeclarations(node); - if (node.kind === 213 || node.kind === 165) { + if (node.kind === 214 || node.kind === 166) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -20854,7 +21082,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 167) { + if (node.modifiers && node.parent.kind === 168) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -20873,7 +21101,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 196) { + if (node.thenStatement.kind === 197) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -20890,12 +21118,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 214) { + if (node.initializer && node.initializer.kind === 215) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -20910,13 +21138,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 166 || varExpr.kind === 167) { + if (varExpr.kind === 167 || varExpr.kind === 168) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -20931,7 +21159,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { 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); @@ -20941,7 +21169,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 166 || varExpr.kind === 167) { + if (varExpr.kind === 167 || varExpr.kind === 168) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -21109,7 +21337,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); + return !!(node.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -21127,10 +21355,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 146) { + if (func.kind === 147) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 144) { + else if (func.kind === 145) { if (!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); } @@ -21166,7 +21394,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 244 && !hasDuplicateDefaultClause) { + if (clause.kind === 245 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21178,7 +21406,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 243) { + if (produceDiagnostics && clause.kind === 244) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var expressionTypeIsAssignableToCaseType = (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, 258)) || @@ -21197,7 +21425,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 209 && current.label.text === node.label.text) { + if (current.kind === 210 && 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; @@ -21291,7 +21519,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 137 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21366,7 +21594,6 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; @@ -21440,7 +21667,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { - if (derivedClassDecl.kind === 188) { + if (derivedClassDecl.kind === 189) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -21484,7 +21711,7 @@ var ts; } } function isAccessor(kind) { - return kind === 145 || kind === 146; + return kind === 146 || kind === 147; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -21550,7 +21777,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 217); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -21648,7 +21875,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 181: + case 182: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -21659,7 +21886,7 @@ var ts; case 50: return ~value_1; } return undefined; - case 183: + case 184: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -21684,11 +21911,11 @@ var ts; return undefined; case 8: return +e.text; - case 174: + case 175: return evalConstant(e.expression); case 69: + case 170: case 169: - case 168: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -21699,7 +21926,7 @@ var ts; } else { var expression; - if (e.kind === 169) { + if (e.kind === 170) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -21716,7 +21943,7 @@ var ts; if (current.kind === 69) { break; } - else if (current.kind === 168) { + else if (current.kind === 169) { current = current.expression; } else { @@ -21775,7 +22002,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 219) { + if (declaration.kind !== 220) { return false; } var enumDeclaration = declaration; @@ -21798,8 +22025,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 === 216 || - (declaration.kind === 215 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 217 || + (declaration.kind === 216 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -21821,7 +22048,12 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 9; + var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); + var inAmbientContext = ts.isInAmbientContext(node); + if (isGlobalAugmentation && !inAmbientContext) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); + } + var isAmbientExternalModule = ts.isAmbientModule(node); var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -21829,7 +22061,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9) { + if (!inAmbientContext && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -21839,7 +22071,7 @@ var ts; var symbol = getSymbolOfNode(node); if (symbol.flags & 512 && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) + && !inAmbientContext && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { @@ -21850,29 +22082,102 @@ 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, 216); + var mergedClass = ts.getDeclarationOfKind(symbol, 217); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; } } if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + if (ts.isExternalModuleAugmentation(node)) { + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + if (checkBody) { + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + checkModuleAugmentationElement(statement, isGlobalAugmentation); + } + } } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + else if (isGlobalSourceFile(node.parent)) { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + else { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else { + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } } } } checkSourceElement(node.body); } + function checkModuleAugmentationElement(node, isGlobalAugmentation) { + switch (node.kind) { + case 196: + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + checkModuleAugmentationElement(decl, isGlobalAugmentation); + } + break; + case 230: + case 231: + grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); + break; + case 224: + if (node.moduleReference.kind !== 9) { + error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + break; + } + case 225: + grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); + break; + case 166: + case 214: + var name_17 = node.name; + if (ts.isBindingPattern(name_17)) { + for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + var el = _c[_b]; + checkModuleAugmentationElement(el, isGlobalAugmentation); + } + break; + } + case 217: + case 220: + case 216: + case 218: + case 221: + case 219: + var symbol = getSymbolOfNode(node); + if (symbol) { + var reportError = !(symbol.flags & 33554432); + if (!reportError) { + if (isGlobalAugmentation) { + reportError = symbol.parent !== undefined; + } + else { + reportError = ts.isExternalModuleAugmentation(symbol.parent.valueDeclaration); + } + } + if (reportError) { + error(node, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + } + } + break; + } + } function getFirstIdentifier(node) { while (true) { - if (node.kind === 135) { + if (node.kind === 136) { node = node.left; } - else if (node.kind === 168) { + else if (node.kind === 169) { node = node.expression; } else { @@ -21888,16 +22193,18 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 221 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 250 && !inAmbientExternalModule) { - error(moduleName, node.kind === 230 ? + var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 && !inAmbientExternalModule) { + error(moduleName, node.kind === 231 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; + if (!isTopLevelInExternalModuleAugmentation(node)) { + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } } return true; } @@ -21909,7 +22216,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 232 ? + var message = node.kind === 233 ? 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)); @@ -21935,7 +22242,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226) { + if (importClause.namedBindings.kind === 227) { checkImportBinding(importClause.namedBindings); } else { @@ -21986,8 +22293,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 221 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 250 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -22000,22 +22307,29 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 250 && node.parent.kind !== 221 && node.parent.kind !== 220) { + if (node.parent.kind !== 251 && node.parent.kind !== 222 && node.parent.kind !== 221) { return grammarErrorOnFirstToken(node, errorMessage); } } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); + var exportedName = node.propertyName || node.name; + var symbol = resolveName(exportedName, exportedName.text, 107455 | 793056 | 1536 | 8388608, undefined, undefined); + if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); + } + else { + markExportAsReferenced(node); + } } } function checkExportAssignment(node) { if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 250 ? node.parent : node.parent.parent; - if (container.kind === 220 && container.name.kind === 69) { + var container = node.parent.kind === 251 ? node.parent : node.parent.parent; + if (container.kind === 221 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -22053,7 +22367,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports["export="]; if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + if (!isTopLevelInExternalModuleAugmentation(declaration)) { + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } } var exports = getExportsOfModule(moduleSymbol); for (var id in exports) { @@ -22074,21 +22390,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 215 || !!declaration.body; - } - } - function checkTypePredicate(node) { - var parameterName = node.parameterName; - if (parameterName.kind === 69 && !isInLegalParameterTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - else if (parameterName.kind === 161) { - if (!isInLegalThisTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods); - } - else { - getTypeFromThisTypeNode(parameterName); - } + return declaration.kind !== 216 || !!declaration.body; } } function checkSourceElement(node) { @@ -22098,118 +22400,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 220: - case 216: + case 221: case 217: - case 215: + case 218: + case 216: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 137: - return checkTypeParameter(node); case 138: + return checkTypeParameter(node); + case 139: return checkParameter(node); + case 142: case 141: - case 140: return checkPropertyDeclaration(node); - case 152: case 153: - case 147: + case 154: case 148: - return checkSignatureDeclaration(node); case 149: return checkSignatureDeclaration(node); - case 143: - case 142: - return checkMethodDeclaration(node); - case 144: - return checkConstructorDeclaration(node); - case 145: - case 146: - return checkAccessorDeclaration(node); - case 151: - return checkTypeReferenceNode(node); case 150: + return checkSignatureDeclaration(node); + case 144: + case 143: + return checkMethodDeclaration(node); + case 145: + return checkConstructorDeclaration(node); + case 146: + case 147: + return checkAccessorDeclaration(node); + case 152: + return checkTypeReferenceNode(node); + case 151: return checkTypePredicate(node); - case 154: - return checkTypeQuery(node); case 155: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 156: - return checkArrayType(node); + return checkTypeLiteral(node); case 157: - return checkTupleType(node); + return checkArrayType(node); case 158: + return checkTupleType(node); case 159: - return checkUnionOrIntersectionType(node); case 160: + return checkUnionOrIntersectionType(node); + case 161: return checkSourceElement(node.type); - case 215: - return checkFunctionDeclaration(node); - case 194: - case 221: - return checkBlock(node); - case 195: - return checkVariableStatement(node); - case 197: - return checkExpressionStatement(node); - case 198: - return checkIfStatement(node); - case 199: - return checkDoStatement(node); - case 200: - return checkWhileStatement(node); - case 201: - return checkForStatement(node); - case 202: - return checkForInStatement(node); - case 203: - return checkForOfStatement(node); - case 204: - case 205: - return checkBreakOrContinueStatement(node); - case 206: - return checkReturnStatement(node); - case 207: - return checkWithStatement(node); - case 208: - return checkSwitchStatement(node); - case 209: - return checkLabeledStatement(node); - case 210: - return checkThrowStatement(node); - case 211: - return checkTryStatement(node); - case 213: - return checkVariableDeclaration(node); - case 165: - return checkBindingElement(node); case 216: - return checkClassDeclaration(node); - case 217: - return checkInterfaceDeclaration(node); - case 218: - return checkTypeAliasDeclaration(node); - case 219: - return checkEnumDeclaration(node); - case 220: - return checkModuleDeclaration(node); - case 224: - return checkImportDeclaration(node); - case 223: - return checkImportEqualsDeclaration(node); - case 230: - return checkExportDeclaration(node); - case 229: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 195: + case 222: + return checkBlock(node); case 196: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 198: + return checkExpressionStatement(node); + case 199: + return checkIfStatement(node); + case 200: + return checkDoStatement(node); + case 201: + return checkWhileStatement(node); + case 202: + return checkForStatement(node); + case 203: + return checkForInStatement(node); + case 204: + return checkForOfStatement(node); + case 205: + case 206: + return checkBreakOrContinueStatement(node); + case 207: + return checkReturnStatement(node); + case 208: + return checkWithStatement(node); + case 209: + return checkSwitchStatement(node); + case 210: + return checkLabeledStatement(node); + case 211: + return checkThrowStatement(node); case 212: + return checkTryStatement(node); + case 214: + return checkVariableDeclaration(node); + case 166: + return checkBindingElement(node); + case 217: + return checkClassDeclaration(node); + case 218: + return checkInterfaceDeclaration(node); + case 219: + return checkTypeAliasDeclaration(node); + case 220: + return checkEnumDeclaration(node); + case 221: + return checkModuleDeclaration(node); + case 225: + return checkImportDeclaration(node); + case 224: + return checkImportEqualsDeclaration(node); + case 231: + return checkExportDeclaration(node); + case 230: + return checkExportAssignment(node); + case 197: checkGrammarStatementInAmbientContext(node); return; - case 233: + case 213: + checkGrammarStatementInAmbientContext(node); + return; + case 234: return checkMissingDeclaration(node); } } @@ -22222,17 +22524,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 175: case 176: + case 177: + case 144: case 143: - case 142: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 145: case 146: + case 147: checkAccessorDeferred(node); break; - case 188: + case 189: checkClassExpressionDeferred(node); break; } @@ -22252,10 +22554,6 @@ var ts; } } checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - emitAwaiter = false; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); @@ -22268,21 +22566,6 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) { - links.flags |= 8; - } - if (emitDecorate) { - links.flags |= 16; - } - if (emitParam) { - links.flags |= 32; - } - if (emitAwaiter) { - links.flags |= 64; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2)) { - links.flags |= 128; - } links.flags |= 1; } } @@ -22316,7 +22599,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 207 && node.parent.statement === node) { + if (node.parent.kind === 208 && node.parent.statement === node) { return true; } node = node.parent; @@ -22338,28 +22621,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 250: + case 251: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 220: + case 221: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 219: + case 220: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 188: + case 189: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 216: case 217: + case 218: if (!(memberFlags & 64)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 175: + case 176: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -22398,36 +22681,36 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 137: - case 216: + case 138: case 217: case 218: case 219: + case 220: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 135) { + while (node.parent && node.parent.kind === 136) { node = node.parent; } - return node.parent && node.parent.kind === 151; + return node.parent && node.parent.kind === 152; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 168) { + while (node.parent && node.parent.kind === 169) { node = node.parent; } - return node.parent && node.parent.kind === 190; + return node.parent && node.parent.kind === 191; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135) { + while (nodeOnRightSide.parent.kind === 136) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 223) { + if (nodeOnRightSide.parent.kind === 224) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22439,10 +22722,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 229) { + if (entityName.parent.kind === 230) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 168) { + if (entityName.kind !== 169) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -22452,7 +22735,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 190) { + if (entityName.parent.kind === 191) { meaning = 793056; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -22464,9 +22747,9 @@ var ts; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 237) || - (entityName.parent.kind === 236) || - (entityName.parent.kind === 239)) { + else if ((entityName.parent.kind === 238) || + (entityName.parent.kind === 237) || + (entityName.parent.kind === 240)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -22477,14 +22760,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 168) { + else if (entityName.kind === 169) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 135) { + else if (entityName.kind === 136) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -22493,14 +22776,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 ? 793056 : 1536; + var meaning = entityName.parent.kind === 152 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 240) { + else if (entityName.parent.kind === 241) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 150) { + if (entityName.parent.kind === 151) { return resolveEntityName(entityName, 1); } return undefined; @@ -22514,12 +22797,12 @@ var ts; } if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 229 + return node.parent.kind === 230 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 165 && - node.parent.parent.kind === 163 && + else if (node.parent.kind === 166 && + node.parent.parent.kind === 164 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -22530,30 +22813,30 @@ var ts; } switch (node.kind) { case 69: - case 168: - case 135: + case 169: + case 136: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 161: + case 162: return getTypeFromTypeNode(node).symbol; case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144) { + if (constructorDeclaration && constructorDeclaration.kind === 145) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 224 || node.parent.kind === 230) && + ((node.parent.kind === 225 || node.parent.kind === 231) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 169 && node.parent.argumentExpression === node) { + if (node.parent.kind === 170 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -22567,11 +22850,16 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 248) { - return resolveEntityName(location.name, 107455); + if (location && location.kind === 249) { + return resolveEntityName(location.name, 107455 | 8388608); } return undefined; } + function getExportSpecifierLocalTargetSymbol(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536 | 8388608); + } function getTypeOfNode(node) { if (isInsideWithStatementBody(node)) { return unknownType; @@ -22638,9 +22926,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var name_15 = symbol.name; + var name_18 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); + var symbol = getPropertyOfType(t, name_18); if (symbol) { symbols.push(symbol); } @@ -22689,11 +22977,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 250) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 251) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 220 || n.kind === 219) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 221 || n.kind === 220) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -22706,11 +22994,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 194: - case 222: - case 201: + case 195: + case 223: case 202: case 203: + case 204: return true; } return false; @@ -22736,22 +23024,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 223: - case 225: + case 224: case 226: - case 228: - case 232: + case 227: + case 229: + case 233: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 230: + case 231: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 229: + case 230: return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 250 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 251 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -22799,7 +23087,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 249) { + if (node.kind === 250) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -22915,21 +23203,34 @@ var ts; } function getExternalModuleFileFromDeclaration(declaration) { var specifier = ts.getExternalModuleName(declaration); - var moduleSymbol = getSymbolAtLocation(specifier); + var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 250); + return ts.getDeclarationOfKind(moduleSymbol, 251); } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { ts.bindSourceFile(file, compilerOptions); }); + var augmentations; ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } + if (file.moduleAugmentations) { + (augmentations || (augmentations = [])).push(file.moduleAugmentations); + } }); + if (augmentations) { + for (var _i = 0, augmentations_1 = augmentations; _i < augmentations_1.length; _i++) { + var list = augmentations_1[_i]; + for (var _a = 0, list_2 = list; _a < list_2.length; _a++) { + var augmentation = list_2[_a]; + mergeModuleAugmentation(augmentation); + } + } + } addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); @@ -22994,14 +23295,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 143 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 144 && !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 === 145 || node.kind === 146) { + else if (node.kind === 146 || node.kind === 147) { 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); @@ -23011,38 +23312,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 145: case 146: - case 144: - case 141: - case 140: - case 143: + case 147: + case 145: case 142: - case 149: - case 220: + case 141: + case 144: + case 143: + case 150: + case 221: + case 225: case 224: - case 223: + case 231: case 230: - case 229: - case 138: - break; - case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && - node.parent.kind !== 221 && node.parent.kind !== 250) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 139: break; case 216: - case 217: - case 195: - case 218: - if (node.modifiers && node.parent.kind !== 221 && node.parent.kind !== 250) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 222 && node.parent.kind !== 251) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 217: + case 218: + case 196: case 219: + if (node.modifiers && node.parent.kind !== 222 && node.parent.kind !== 251) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 220: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && - node.parent.kind !== 221 && node.parent.kind !== 250) { + node.parent.kind !== 222 && node.parent.kind !== 251) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23058,7 +23359,7 @@ var ts; var modifier = _a[_i]; switch (modifier.kind) { case 74: - if (node.kind !== 219 && node.parent.kind === 216) { + if (node.kind !== 220 && node.parent.kind === 217) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); } break; @@ -23086,7 +23387,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 === 221 || node.parent.kind === 250) { + else if (node.parent.kind === 222 || node.parent.kind === 251) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 128) { @@ -23106,10 +23407,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 === 221 || node.parent.kind === 250) { + else if (node.parent.kind === 222 || node.parent.kind === 251) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -23131,10 +23432,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 === 216) { + else if (node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 2; @@ -23146,13 +23447,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 === 216) { + else if (node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 221) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 4; @@ -23162,11 +23463,11 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 216) { - if (node.kind !== 143) { + if (node.kind !== 217) { + if (node.kind !== 144) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 216 && node.parent.flags & 128)) { + if (!(node.parent.kind === 217 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 64) { @@ -23185,7 +23486,7 @@ var ts; else if (flags & 4 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -23193,7 +23494,7 @@ var ts; break; } } - if (node.kind === 144) { + if (node.kind === 145) { if (flags & 64) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -23211,10 +23512,10 @@ var ts; } return; } - else if ((node.kind === 224 || node.kind === 223) && flags & 4) { + else if ((node.kind === 225 || node.kind === 224) && flags & 4) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 && (flags & 56) && ts.isBindingPattern(node.name)) { + else if (node.kind === 139 && (flags & 56) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256) { @@ -23226,10 +23527,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 143: - case 215: - case 175: + case 144: + case 216: case 176: + case 177: if (!node.asteriskToken) { return false; } @@ -23294,7 +23595,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 176) { + if (node.kind === 177) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23361,7 +23662,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 189) { + if (arg.kind === 190) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23432,19 +23733,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 136) { + if (node.kind !== 137) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 183 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 184 && computedPropertyName.expression.operatorToken.kind === 24) { 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 === 215 || - node.kind === 175 || - node.kind === 143); + ts.Debug.assert(node.kind === 216 || + node.kind === 176 || + node.kind === 144); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -23468,58 +23769,58 @@ var ts; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; var _loop_1 = function(prop) { - var name_16 = prop.name; - if (prop.kind === 189 || - name_16.kind === 136) { - checkGrammarComputedPropertyName(name_16); + var name_19 = prop.name; + if (prop.kind === 190 || + name_19.kind === 137) { + checkGrammarComputedPropertyName(name_19); return "continue"; } - if (prop.kind === 248 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 249 && !inDestructuring && prop.objectAssignmentInitializer) { return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 || prop.kind !== 143) { + if (mod.kind !== 118 || prop.kind !== 144) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); var currentKind = void 0; - if (prop.kind === 247 || prop.kind === 248) { + if (prop.kind === 248 || prop.kind === 249) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8) { - checkGrammarNumericLiteral(name_16); + if (name_19.kind === 8) { + checkGrammarNumericLiteral(name_19); } currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = Property; } - else if (prop.kind === 145) { + else if (prop.kind === 146) { currentKind = GetAccessor; } - else if (prop.kind === 146) { + else if (prop.kind === 147) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = currentKind; } else { - var existingKind = seen[name_16.text]; + var existingKind = seen[name_19.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; + seen[name_19.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; @@ -23534,19 +23835,19 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 241) { + if (attr.kind === 242) { continue; } var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; + var name_20 = jsxAttr.name; + if (!ts.hasProperty(seen, name_20.text)) { + seen[name_20.text] = true; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 242 && !initializer.expression) { + if (initializer && initializer.kind === 243 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -23555,7 +23856,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 214) { + if (forInOrOfStatement.initializer.kind === 215) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -23563,20 +23864,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 202 + var diagnostic = forInOrOfStatement.kind === 203 ? 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 === 202 + var diagnostic = forInOrOfStatement.kind === 203 ? 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 === 202 + var diagnostic = forInOrOfStatement.kind === 203 ? 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); @@ -23599,10 +23900,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 145 && accessor.parameters.length) { + else if (kind === 146 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 146) { + else if (kind === 147) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -23637,12 +23938,12 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 167) { + if (node.parent.kind === 168) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -23656,10 +23957,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 === 217) { + else if (node.parent.kind === 218) { 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 === 155) { + else if (node.parent.kind === 156) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -23670,9 +23971,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 209: + case 210: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 204 + var isMisplacedContinueLabel = node.kind === 205 && !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); @@ -23680,8 +23981,8 @@ var ts; return false; } break; - case 208: - if (node.kind === 205 && !node.label) { + case 209: + if (node.kind === 206 && !node.label) { return false; } break; @@ -23694,13 +23995,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 205 + var message = node.kind === 206 ? 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 === 205 + var message = node.kind === 206 ? 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); @@ -23712,7 +24013,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 164 || node.name.kind === 163) { + if (node.name.kind === 165 || node.name.kind === 164) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -23721,7 +24022,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 202 && node.parent.parent.kind !== 203) { + if (node.parent.parent.kind !== 203 && node.parent.parent.kind !== 204) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -23750,7 +24051,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 189) { + if (element.kind !== 190) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -23767,15 +24068,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 198: case 199: case 200: - case 207: case 201: + case 208: case 202: case 203: + case 204: return false; - case 209: + case 210: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -23831,7 +24132,7 @@ var ts; return true; } } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -23839,7 +24140,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 155) { + else if (node.parent.kind === 156) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -23852,12 +24153,12 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 217 || - node.kind === 218 || + if (node.kind === 218 || + node.kind === 219 || + node.kind === 225 || node.kind === 224 || - node.kind === 223 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || (node.flags & 4) || (node.flags & (2 | 512))) { return false; @@ -23867,7 +24168,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 === 195) { + if (ts.isDeclaration(decl) || decl.kind === 196) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -23886,7 +24187,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 === 194 || node.parent.kind === 221 || node.parent.kind === 250) { + if (node.parent.kind === 195 || node.parent.kind === 222 || node.parent.kind === 251) { 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); @@ -23922,8 +24223,9 @@ var ts; getSourceMapData: function () { return undefined; }, setSourceFile: function (sourceFile) { }, emitStart: function (range) { }, - emitEnd: function (range) { }, + emitEnd: function (range, stopOverridingSpan) { }, emitPos: function (pos) { }, + changeEmitSourcePos: function () { }, getText: function () { return undefined; }, getSourceMappingURL: function () { return undefined; }, initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, @@ -23937,6 +24239,8 @@ var ts; var compilerOptions = host.getCompilerOptions(); var currentSourceFile; var sourceMapDir; + var stopOverridingSpan = false; + var modifyLastSourcePos = false; var sourceMapSourceIndex; var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan; @@ -23948,6 +24252,7 @@ var ts; emitPos: emitPos, emitStart: emitStart, emitEnd: emitEnd, + changeEmitSourcePos: changeEmitSourcePos, getText: getText, getSourceMappingURL: getSourceMappingURL, initialize: initialize, @@ -24011,6 +24316,29 @@ var ts; lastEncodedNameIndex = undefined; sourceMapData = undefined; } + function updateLastEncodedAndRecordedSpans() { + if (modifyLastSourcePos) { + modifyLastSourcePos = false; + lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; + lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; + sourceMapData.sourceMapDecodedMappings.pop(); + lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? + sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : + undefined; + var sourceMapMappings = sourceMapData.sourceMapMappings; + var lenthToSet = sourceMapMappings.length - 1; + for (; lenthToSet >= 0; lenthToSet--) { + var currentChar = sourceMapMappings.charAt(lenthToSet); + if (currentChar === ",") { + break; + } + if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { + break; + } + } + sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); + } + } function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { return; @@ -24032,6 +24360,7 @@ var ts; sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); if (lastRecordedSourceMapSpan.nameIndex >= 0) { + ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } @@ -24061,19 +24390,29 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; + stopOverridingSpan = false; } - else { + else if (!stopOverridingSpan) { lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } + updateLastEncodedAndRecordedSpans(); + } + function getStartPos(range) { + var rangeHasDecorators = !!range.decorators; + return range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1; } function emitStart(range) { - var rangeHasDecorators = !!range.decorators; - emitPos(range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1); + emitPos(getStartPos(range)); } - function emitEnd(range) { + function emitEnd(range, stopOverridingEnd) { emitPos(range.end); + stopOverridingSpan = stopOverridingEnd; + } + function changeEmitSourcePos() { + ts.Debug.assert(!modifyLastSourcePos); + modifyLastSourcePos = true; } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -24160,6 +24499,7 @@ var ts; var writeTextOfNode; var writer = createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; + var resultHasExternalModuleIndicator; var currentText; var currentLineMap; var currentIdentifiers; @@ -24190,6 +24530,7 @@ var ts; } }); } + resultHasExternalModuleIndicator = false; if (!isBundledEmit || !ts.isExternalModule(sourceFile)) { noDeclare = false; emitSourceFile(sourceFile); @@ -24208,7 +24549,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 224); + ts.Debug.assert(aliasEmitInfo.node.kind === 225); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -24225,6 +24566,10 @@ var ts; allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo); moduleElementDeclarationEmitInfo = []; } + if (!isBundledEmit && ts.isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) { + write("export {};"); + writeLine(); + } }); return { reportedDeclarationError: reportedDeclarationError, @@ -24271,10 +24616,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 213) { + if (declaration.kind === 214) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 227 || declaration.kind === 228 || declaration.kind === 225) { + else if (declaration.kind === 228 || declaration.kind === 229 || declaration.kind === 226) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24285,7 +24630,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 224) { + if (moduleElementEmitInfo.node.kind === 225) { moduleElementEmitInfo.isVisible = true; } else { @@ -24293,12 +24638,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 220) { + if (nodeToCheck.kind === 221) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 220) { + if (nodeToCheck.kind === 221) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24401,35 +24746,35 @@ var ts; case 120: case 131: case 103: - case 161: case 162: + case 163: return writeTextOfNode(currentText, type); - case 190: + case 191: return emitExpressionWithTypeArguments(type); - case 151: - return emitTypeReference(type); - case 154: - return emitTypeQuery(type); - case 156: - return emitArrayType(type); - case 157: - return emitTupleType(type); - case 158: - return emitUnionType(type); - case 159: - return emitIntersectionType(type); - case 160: - return emitParenType(type); case 152: - case 153: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 155: + return emitTypeQuery(type); + case 157: + return emitArrayType(type); + case 158: + return emitTupleType(type); + case 159: + return emitUnionType(type); + case 160: + return emitIntersectionType(type); + case 161: + return emitParenType(type); + case 153: + case 154: + return emitSignatureDeclarationWithJsDocComments(type); + case 156: return emitTypeLiteral(type); case 69: return emitEntityName(type); - case 135: + case 136: return emitEntityName(type); - case 150: + case 151: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -24437,21 +24782,21 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 135 ? entityName.left : entityName.expression; - var right = entityName.kind === 135 ? entityName.right : entityName.name; + var left = entityName.kind === 136 ? entityName.left : entityName.expression; + var right = entityName.kind === 136 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 223 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 224 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 168); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 169); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -24525,9 +24870,9 @@ var ts; var count = 0; while (true) { count++; - var name_18 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_18)) { - return name_18; + var name_21 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_21)) { + return name_21; } } } @@ -24568,10 +24913,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 223 || - (node.parent.kind === 250 && isCurrentFileExternalModule)) { + else if (node.kind === 224 || + (node.parent.kind === 251 && isCurrentFileExternalModule)) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 250) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -24580,7 +24925,7 @@ var ts; }); } else { - if (node.kind === 224) { + if (node.kind === 225) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -24598,37 +24943,37 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 215: - return writeFunctionDeclaration(node); - case 195: - return writeVariableStatement(node); - case 217: - return writeInterfaceDeclaration(node); case 216: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 196: + return writeVariableStatement(node); case 218: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 217: + return writeClassDeclaration(node); case 219: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 220: + return writeEnumDeclaration(node); + case 221: return writeModuleDeclaration(node); - case 223: - return writeImportEqualsDeclaration(node); case 224: + return writeImportEqualsDeclaration(node); + case 225: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 250) { + if (node.parent.kind === 251) { if (node.flags & 2) { write("export "); } if (node.flags & 512) { write("default "); } - else if (node.kind !== 217 && !noDeclare) { + else if (node.kind !== 218 && !noDeclare) { write("declare "); } } @@ -24675,7 +25020,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 226) { + if (namedBindings.kind === 227) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -24701,7 +25046,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 226) { + if (node.importClause.namedBindings.kind === 227) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -24718,11 +25063,15 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 221; var moduleSpecifier; - if (parent.kind === 223) { + if (parent.kind === 224) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } + else if (parent.kind === 221) { + moduleSpecifier = parent.name; + } else { var node = parent; moduleSpecifier = node.moduleSpecifier; @@ -24771,14 +25120,24 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 65536) { - write("namespace "); + if (ts.isGlobalScopeAugmentation(node)) { + write("global "); } else { - write("module "); + if (node.flags & 65536) { + write("namespace "); + } + else { + write("module "); + } + if (ts.isExternalModuleAugmentation(node)) { + emitExternalModuleSpecifier(node); + } + else { + writeTextOfNode(currentText, node.name); + } } - writeTextOfNode(currentText, node.name); - while (node.body.kind !== 221) { + while (node.body.kind !== 222) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -24843,7 +25202,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 16); + return node.parent.kind === 144 && (node.parent.flags & 16); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -24853,15 +25212,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - (node.parent.parent && node.parent.parent.kind === 155)) { - ts.Debug.assert(node.parent.kind === 143 || - node.parent.kind === 142 || - node.parent.kind === 152 || + if (node.parent.kind === 153 || + node.parent.kind === 154 || + (node.parent.parent && node.parent.parent.kind === 156)) { + ts.Debug.assert(node.parent.kind === 144 || + node.parent.kind === 143 || node.parent.kind === 153 || - node.parent.kind === 147 || - node.parent.kind === 148); + node.parent.kind === 154 || + node.parent.kind === 148 || + node.parent.kind === 149); emitType(node.constraint); } else { @@ -24871,31 +25230,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 216: + case 217: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 217: + case 218: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 148: + case 149: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 144: case 143: - case 142: if (node.parent.flags & 64) { 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 === 216) { + else if (node.parent.parent.kind === 217) { 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 215: + case 216: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -24928,7 +25287,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 216) { + if (node.parent.parent.kind === 217) { 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; @@ -25008,16 +25367,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 213 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 214 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { + if ((node.kind === 142 || node.kind === 141) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { + if ((node.kind === 142 || node.kind === 141) && node.parent.kind === 156) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 16)) { @@ -25026,14 +25385,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 213) { + if (node.kind === 214) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 === 141 || node.kind === 140) { + else if (node.kind === 142 || node.kind === 141) { if (node.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -25041,7 +25400,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 === 216) { + else if (node.parent.kind === 217) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25067,7 +25426,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189) { + if (element.kind !== 190) { elements.push(element); } } @@ -25133,7 +25492,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 146 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25146,7 +25505,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 145 + return accessor.kind === 146 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -25155,7 +25514,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146) { + if (accessorWithTypeAnnotation.kind === 147) { if (accessorWithTypeAnnotation.parent.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -25201,17 +25560,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 215) { + if (node.kind === 216) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 143) { + else if (node.kind === 144) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 215) { + if (node.kind === 216) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 144) { + else if (node.kind === 145) { write("constructor"); } else { @@ -25230,31 +25589,31 @@ var ts; function emitSignatureDeclaration(node) { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - if (node.kind === 148 || node.kind === 153) { + if (node.kind === 149 || node.kind === 154) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 149) { + if (node.kind === 150) { write("["); } else { write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149) { + if (node.kind === 150) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { + var isFunctionTypeOrConstructorType = node.kind === 153 || node.kind === 154; + if (isFunctionTypeOrConstructorType || node.parent.kind === 156) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 144 && !(node.flags & 16)) { + else if (node.kind !== 145 && !(node.flags & 16)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25265,23 +25624,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 148: + case 149: diagnosticMessage = symbolAccesibilityResult.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 147: + case 148: diagnosticMessage = symbolAccesibilityResult.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 149: + case 150: diagnosticMessage = symbolAccesibilityResult.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 144: case 143: - case 142: if (node.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -25289,7 +25648,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 === 216) { + else if (node.parent.kind === 217) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -25302,7 +25661,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 215: + case 216: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25334,9 +25693,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - node.parent.parent.kind === 155) { + if (node.parent.kind === 153 || + node.parent.kind === 154 || + node.parent.parent.kind === 156) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 16)) { @@ -25352,22 +25711,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 144: + case 145: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 148: + case 149: return symbolAccesibilityResult.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 147: + case 148: return symbolAccesibilityResult.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 144: case 143: - case 142: if (node.parent.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -25375,7 +25734,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 === 216) { + else if (node.parent.parent.kind === 217) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -25387,7 +25746,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 215: + case 216: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25398,12 +25757,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 163) { + if (bindingPattern.kind === 164) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 164) { + else if (bindingPattern.kind === 165) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25414,10 +25773,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 189) { + if (bindingElement.kind === 190) { write(" "); } - else if (bindingElement.kind === 165) { + else if (bindingElement.kind === 166) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -25439,39 +25798,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 215: - case 220: - case 223: - case 217: case 216: - case 218: - case 219: - return emitModuleElement(node, isModuleElementVisible(node)); - case 195: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 221: case 224: + case 218: + case 217: + case 219: + case 220: + return emitModuleElement(node, isModuleElementVisible(node)); + case 196: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 225: return emitModuleElement(node, !node.importClause); - case 230: + case 231: return emitExportDeclaration(node); + case 145: case 144: case 143: - case 142: return writeFunctionDeclaration(node); - case 148: - case 147: case 149: + case 148: + case 150: return emitSignatureDeclarationWithJsDocComments(node); - case 145: case 146: + case 147: return emitAccessorDeclaration(node); + case 142: case 141: - case 140: return emitPropertyDeclaration(node); - case 249: - return emitEnumMemberDeclaration(node); - case 229: - return emitExportAssignment(node); case 250: + return emitEnumMemberDeclaration(node); + case 230: + return emitExportAssignment(node); + case 251: return emitSourceFile(node); } } @@ -25798,7 +26157,7 @@ var ts; 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};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -25886,6 +26245,7 @@ var ts; var sourceMapData; var isOwnFileEmit; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, _a[5] = emitES6Module, _a[2] = emitAMDModule, @@ -25964,19 +26324,19 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_19)) { + var name_22 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_22)) { tempFlags |= flags; - return name_19; + return name_22; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; + var name_23 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_23)) { + return name_23; } } } @@ -26014,17 +26374,17 @@ var ts; switch (node.kind) { case 69: return makeUniqueName(node.text); + case 221: case 220: - case 219: return generateNameForModuleOrEnum(node); - case 224: - case 230: + case 225: + case 231: return generateNameForImportOrExportDeclaration(node); - case 215: case 216: - case 229: + case 217: + case 230: return generateNameForExportDefault(); - case 188: + case 189: return generateNameForClassExpression(); } } @@ -26264,10 +26624,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 185) { + if (node.template.kind === 186) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 183 + var needsParens = templateSpan.expression.kind === 184 && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26291,7 +26651,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 174 + var needsParens = templateSpan.expression.kind !== 175 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -26311,11 +26671,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 170: case 171: - return parent.expression === template; case 172: - case 174: + return parent.expression === template; + case 173: + case 175: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -26323,7 +26683,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 183: + case 184: switch (expression.operatorToken.kind) { case 37: case 39: @@ -26335,8 +26695,8 @@ var ts; default: return -1; } - case 186: - case 184: + case 187: + case 185: return -1; default: return 1; @@ -26392,37 +26752,37 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 241; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 242; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 241) { - if (i_1 === 0) { + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].kind === 242) { + if (i === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_1 > 0) { + if (i > 0) { write(", "); } - emit(attrs[i_1].expression); + emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 240); + ts.Debug.assert(attrs[i].kind === 241); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_1 > 0) { + if (i > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_1]); + emitJsxAttribute(attrs[i]); } } if (haveOpenedObjectLiteral) @@ -26431,7 +26791,7 @@ var ts; } else { write("{"); - for (var i = 0; i < attrs.length; i++) { + for (var i = 0, n = attrs.length; i < n; i++) { if (i > 0) { write(", "); } @@ -26442,10 +26802,10 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 242 && !(children[i].expression)) { + if (children[i].kind === 243 && !(children[i].expression)) { continue; } - if (children[i].kind === 238) { + if (children[i].kind === 239) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -26462,11 +26822,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 235) { + if (node.kind === 236) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 236); + ts.Debug.assert(node.kind === 237); emitJsxElement(node); } } @@ -26488,11 +26848,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 241) { + if (attribs[i].kind === 242) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 240); + ts.Debug.assert(attribs[i].kind === 241); emitJsxAttribute(attribs[i]); } } @@ -26500,11 +26860,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 236)) { + if (node.attributes.length > 0 || (node.kind === 237)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 236) { + if (node.kind === 237) { write("/>"); } else { @@ -26523,20 +26883,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 235) { + if (node.kind === 236) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 236); + ts.Debug.assert(node.kind === 237); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 165); + ts.Debug.assert(node.kind !== 166); if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 136) { + else if (node.kind === 137) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -26567,62 +26927,62 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 166: - case 191: - case 183: - case 170: - case 243: - case 136: + case 167: + case 192: case 184: - case 139: - case 177: - case 199: - case 169: - case 229: - case 197: - case 190: - case 201: + case 171: + case 244: + case 137: + case 185: + case 140: + case 178: + case 200: + case 170: + case 230: + case 198: + case 191: case 202: case 203: - case 198: - case 239: - case 236: + case 204: + case 199: + case 240: case 237: - case 241: + case 238: case 242: - case 171: - case 174: - case 182: - case 181: - case 206: - case 248: - case 187: - case 208: + case 243: case 172: - case 192: - case 210: - case 173: - case 178: - case 179: - case 200: - case 207: - case 186: - return true; - case 165: - case 249: - case 138: - case 247: - case 141: - case 213: - return parent.initializer === node; - case 168: - return parent.expression === node; - case 176: case 175: + case 183: + case 182: + case 207: + case 249: + case 188: + case 209: + case 173: + case 193: + case 211: + case 174: + case 179: + case 180: + case 201: + case 208: + case 187: + return true; + case 166: + case 250: + case 139: + case 248: + case 142: + case 214: + return parent.initializer === node; + case 169: + return parent.expression === node; + case 177: + case 176: return parent.body === node; - case 223: + case 224: return parent.moduleReference === node; - case 135: + case 136: return parent.left === node; } return false; @@ -26634,7 +26994,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 250) { + if (container.kind === 251) { if (modulekind !== 5 && modulekind !== 4) { write("exports."); } @@ -26648,15 +27008,15 @@ var ts; if (modulekind !== 5) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 225) { + if (declaration.kind === 226) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 228) { + else if (declaration.kind === 229) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_21 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_21); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); if (languageVersion === 0 && identifier === "default") { write("[\"default\"]"); } @@ -26685,13 +27045,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 165: - case 216: - case 219: - case 213: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + var parent_7 = node.parent; + switch (parent_7.kind) { + case 166: + case 217: + case 220: + case 214: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } return false; @@ -26699,8 +27059,8 @@ var ts; function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { - var name_22 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_22); + var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_25); return; } } @@ -26800,10 +27160,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 183 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 184 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 184 && node.parent.condition === node) { + else if (node.parent.kind === 185 && node.parent.condition === node) { return true; } return false; @@ -26811,11 +27171,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69: - case 166: - case 168: + case 167: case 169: case 170: - case 174: + case 171: + case 175: return false; } return true; @@ -26832,17 +27192,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 187) { + if (e.kind === 188) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 166) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 187) { + while (i < length && elements[i].kind !== 188) { i++; } write("["); @@ -26865,7 +27225,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 187; + return node.kind === 188; } function emitArrayLiteral(node) { var elements = node.elements; @@ -26926,7 +27286,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 145 || property.kind === 146) { + if (property.kind === 146 || property.kind === 147) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -26977,13 +27337,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 247) { + if (property.kind === 248) { emit(property.initializer); } - else if (property.kind === 248) { + else if (property.kind === 249) { emitExpressionIdentifier(property.name); } - else if (property.kind === 143) { + else if (property.kind === 144) { emitFunctionDeclaration(property); } else { @@ -27015,7 +27375,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136) { + if (properties[i].name.kind === 137) { numInitialNonComputedProperties = i; break; } @@ -27029,35 +27389,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(183, startsOnNewLine); + var result = ts.createSynthesizedNode(184, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(168); + var result = ts.createSynthesizedNode(169); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(169); + var result = ts.createSynthesizedNode(170); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 173 || expr.kind === 191) { + while (expr.kind === 174 || expr.kind === 192) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 171 && + expr.kind !== 172 && expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(174); + var node = ts.createSynthesizedNode(175); node.expression = expr; return node; } @@ -27084,7 +27444,7 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 250; + return container && container.kind !== 251; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentText, node.name); @@ -27102,7 +27462,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 168 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 169 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -27113,7 +27473,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 168 || node.kind === 169 + return node.kind === 169 || node.kind === 170 ? resolver.getConstantValue(node) : undefined; } @@ -27193,7 +27553,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 135: + case 136: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -27211,10 +27571,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 187; }); + return ts.forEach(elements, function (e) { return e.kind === 188; }); } function skipParentheses(node) { - while (node.kind === 174 || node.kind === 173 || node.kind === 191) { + while (node.kind === 175 || node.kind === 174 || node.kind === 192) { node = node.expression; } return node; @@ -27235,12 +27595,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 168) { + if (expr.kind === 169) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 169) { + else if (expr.kind === 170) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -27281,7 +27641,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 168 && node.expression.expression.kind === 95; + superCall = node.expression.kind === 169 && node.expression.expression.kind === 95; } if (superCall && languageVersion < 2) { write(".call("); @@ -27332,21 +27692,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 176) { - if (node.expression.kind === 173 || node.expression.kind === 191) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 177) { + if (node.expression.kind === 174 || node.expression.kind === 192) { var operand = node.expression.expression; - while (operand.kind === 173 || operand.kind === 191) { + while (operand.kind === 174 || operand.kind === 192) { operand = operand.expression; } - if (operand.kind !== 181 && + if (operand.kind !== 182 && + operand.kind !== 180 && operand.kind !== 179 && operand.kind !== 178 && - operand.kind !== 177 && - operand.kind !== 182 && - operand.kind !== 171 && - !(operand.kind === 170 && node.parent.kind === 171) && - !(operand.kind === 175 && node.parent.kind === 170) && - !(operand.kind === 8 && node.parent.kind === 168)) { + operand.kind !== 183 && + operand.kind !== 172 && + !(operand.kind === 171 && node.parent.kind === 172) && + !(operand.kind === 176 && node.parent.kind === 171) && + !(operand.kind === 8 && node.parent.kind === 169)) { emit(operand); return; } @@ -27375,7 +27735,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 213 || node.parent.kind === 165); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 || node.parent.kind === 166); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27390,7 +27750,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 181) { + if (node.operand.kind === 182) { var operand = node.operand; if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { write(" "); @@ -27433,10 +27793,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 250) { + if (current.kind === 251) { return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 221) { + else if (ts.isFunctionLike(current) || current.kind === 222) { return false; } else { @@ -27452,14 +27812,14 @@ var ts; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169, false); + synthesizedLHS = ts.createSynthesizedNode(170, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 && leftHandSideExpression.argumentExpression.kind !== 9) { var tempArgumentExpression = createAndRecordTempVariable(268435456); synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true, leftHandSideExpression.expression); } else { synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; @@ -27469,7 +27829,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(168, false); + synthesizedLHS = ts.createSynthesizedNode(169, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -27497,8 +27857,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 56 && - (node.left.kind === 167 || node.left.kind === 166)) { - emitDestructuring(node, node.parent.kind === 197); + (node.left.kind === 168 || node.left.kind === 167)) { + emitDestructuring(node, node.parent.kind === 198); } else { var exportChanged = node.operatorToken.kind >= 56 && @@ -27550,7 +27910,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 194) { + if (node && node.kind === 195) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -27564,12 +27924,12 @@ var ts; } emitToken(15, node.pos); increaseIndent(); - if (node.kind === 221) { - ts.Debug.assert(node.parent.kind === 220); + if (node.kind === 222) { + ts.Debug.assert(node.parent.kind === 221); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 221) { + if (node.kind === 222) { emitTempDeclarations(true); } decreaseIndent(); @@ -27577,7 +27937,7 @@ var ts; emitToken(16, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 194) { + if (node.kind === 195) { write(" "); emit(node); } @@ -27589,7 +27949,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 176); + emitParenthesizedIf(node.expression, node.expression.kind === 177); write(";"); } function emitIfStatement(node) { @@ -27602,7 +27962,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80, node.thenStatement.end); - if (node.elseStatement.kind === 198) { + if (node.elseStatement.kind === 199) { write(" "); emit(node.elseStatement); } @@ -27622,7 +27982,7 @@ var ts; else { emitNormalLoopBody(node, true); } - if (node.statement.kind === 194) { + if (node.statement.kind === 195) { write(" "); } else { @@ -27646,7 +28006,7 @@ var ts; emitNormalLoopBody(node, true); } } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { + function tryEmitStartOfVariableDeclarationList(decl) { if (shouldHoistVariable(decl, true)) { return false; } @@ -27657,31 +28017,20 @@ var ts; } return false; } - var tokenKind = 102; + emitStart(decl); if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 108; + write("let "); } else if (ts.isConst(decl)) { - tokenKind = 74; + write("const "); + } + else { + write("var "); } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); } else { - switch (tokenKind) { - case 102: - write("var "); - break; - case 108: - write("let "); - break; - case 74: - write("const "); - break; - } + write("var "); } return true; } @@ -27713,7 +28062,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 209) { + if (node.parent.kind === 210) { emitLabelAndColon(node.parent); } loopEmitter(node, loop); @@ -27723,10 +28072,11 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 201: case 202: case 203: - if (node.initializer.kind === 214) { + case 204: + var initializer = node.initializer; + if (initializer && initializer.kind === 215) { loopInitializer = node.initializer; } break; @@ -27739,7 +28089,7 @@ var ts; collectNames(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 194; + var bodyIsBlock = node.statement.kind === 195; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); @@ -27836,7 +28186,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 194) { + else if (node.statement.kind === 195) { emitLines(node.statement.statements); } else { @@ -27932,9 +28282,9 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 214) { + if (node.initializer && node.initializer.kind === 215) { var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { emitCommaList(variableDeclarationList.declarations); } @@ -27958,7 +28308,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 203) { + if (languageVersion < 2 && node.kind === 204) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -27969,17 +28319,17 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + tryEmitStartOfVariableDeclarationList(variableDeclarationList); emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 202) { + if (node.kind === 203) { write(" in "); } else { @@ -28015,24 +28365,24 @@ var ts; emitNodeWithoutSourceMap(node.expression); emitEnd(node.expression); write("; "); - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write(" < "); emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); - emitEnd(node.initializer); + emitEnd(node.expression); write("; "); - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write("++"); - emitEnd(node.initializer); + emitEnd(node.expression); emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -28054,7 +28404,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); - if (node.initializer.kind === 166 || node.initializer.kind === 167) { + if (node.initializer.kind === 167 || node.initializer.kind === 168) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -28076,12 +28426,12 @@ var ts; } function emitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 205 ? 2 : 4; + var jump = node.kind === 206 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { if (!node.label) { - if (node.kind === 205) { + if (node.kind === 206) { convertedLoopState.nonLocalJumps |= 2; write("return \"break\";"); } @@ -28092,7 +28442,7 @@ var ts; } else { var labelMarker; - if (node.kind === 205) { + if (node.kind === 206) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -28105,7 +28455,7 @@ var ts; return; } } - emitToken(node.kind === 205 ? 70 : 75, node.pos); + emitToken(node.kind === 206 ? 70 : 75, node.pos); emitOptional(" ", node.label); write(";"); } @@ -28170,7 +28520,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 243) { + if (node.kind === 244) { write("case "); emit(node.expression); write(":"); @@ -28239,7 +28589,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 220); + } while (node && node.kind !== 221); return node; } function emitContainingModuleName(node) { @@ -28264,13 +28614,13 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(179); + var result = ts.createSynthesizedNode(180); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 250) { - ts.Debug.assert(!!(node.flags & 512) || node.kind === 229); + if (node.parent.kind === 251) { + ts.Debug.assert(!!(node.flags & 512) || node.kind === 230); if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!isEs6Module) { if (languageVersion !== 0) { @@ -28355,7 +28705,7 @@ var ts; emitEnd(specifier.name); write(";"); } - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment, nodeForSourceMap) { if (shouldEmitCommaBeforeAssignment) { write(", "); } @@ -28365,63 +28715,75 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 213 || name.parent.kind === 165); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 || name.parent.kind === 166); + emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); + withTemporaryNoSourceMap(function () { + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + }); + emitEnd(nodeForSourceMap, true); if (exportChanged) { write(")"); } } - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment, sourceMapNode) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment, sourceMapNode || expression.parent); return identifier; } + function isFirstVariableDeclaration(root) { + return root.kind === 214 && + root.parent.kind === 215 && + root.parent.declarations[0] === root; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 213) { + if (root.kind === 214) { var isExported = ts.getCombinedNodeFlags(root) & 2; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 138) { + else if (root.kind === 139) { canDefineTempVariablesInPlace = true; } - if (root.kind === 183) { + if (root.kind === 184) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); + if (isFirstVariableDeclaration(root)) { + sourceMap.changeEmitSourcePos(); + } emitBindingElement(root, value); } - function ensureIdentifier(expr, reuseIdentifierExpressions) { + function ensureIdentifier(expr, reuseIdentifierExpressions, sourceMapNode) { if (expr.kind === 69 && reuseIdentifierExpressions) { return expr; } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0, sourceMapNode); emitCount++; return identifier; } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(183); + function createDefaultValueCheck(value, defaultValue, sourceMapNode) { + value = ensureIdentifier(value, true, sourceMapNode); + var equals = ts.createSynthesizedNode(184); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(184); + var cond = ts.createSynthesizedNode(185); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53); cond.whenTrue = whenTrue; @@ -28436,9 +28798,9 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 136; + var nameIsComputed = propName.kind === 137; if (nameIsComputed) { - index = ensureIdentifier(propName.expression, false); + index = ensureIdentifier(propName.expression, false, propName); } else { index = ts.createSynthesizedNode(propName.kind); @@ -28449,7 +28811,7 @@ var ts; : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(170); + var call = ts.createSynthesizedNode(171); var sliceIdentifier = ts.createSynthesizedNode(69); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -28457,56 +28819,56 @@ var ts; call.arguments[0] = createNumericLiteral(sliceIndex); return call; } - function emitObjectLiteralAssignment(target, value) { + function emitObjectLiteralAssignment(target, value, sourceMapNode) { var properties = target.properties; if (properties.length !== 1) { - value = ensureIdentifier(value, true); + value = ensureIdentifier(value, true, sourceMapNode); } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 247 || p.kind === 248) { + if (p.kind === 248 || p.kind === 249) { var propName = p.name; - var target_1 = p.kind === 248 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 249 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } } - function emitArrayLiteralAssignment(target, value) { + function emitArrayLiteralAssignment(target, value, sourceMapNode) { var elements = target.elements; if (elements.length !== 1) { - value = ensureIdentifier(value, true); + value = ensureIdentifier(value, true, sourceMapNode); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189) { - if (e.kind !== 187) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + if (e.kind !== 190) { + if (e.kind !== 188) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + emitDestructuringAssignment(e.expression, createSliceCall(value, i), e); } } } } - function emitDestructuringAssignment(target, value) { - if (target.kind === 248) { + function emitDestructuringAssignment(target, value, sourceMapNode) { + if (target.kind === 249) { if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 183 && target.operatorToken.kind === 56) { - value = createDefaultValueCheck(value, target.right); + else if (target.kind === 184 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 167) { - emitObjectLiteralAssignment(target, value); + if (target.kind === 168) { + emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 166) { - emitArrayLiteralAssignment(target, value); + else if (target.kind === 167) { + emitArrayLiteralAssignment(target, value, sourceMapNode); } else { - emitAssignment(target, value, emitCount > 0); + emitAssignment(target, value, emitCount > 0, sourceMapNode); emitCount++; } } @@ -28517,24 +28879,24 @@ var ts; emit(value); } else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); + emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 174) { + if (root.parent.kind !== 175) { write("("); } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); + value = ensureIdentifier(value, true, root); + emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 174) { + if (root.parent.kind !== 175) { write(")"); } } } function emitBindingElement(target, value) { if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + value = value ? createDefaultValueCheck(value, target.initializer, target) : target.initializer; } else if (!value) { value = createVoidZero(); @@ -28544,15 +28906,15 @@ var ts; var elements = pattern.elements; var numElements = elements.length; if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); + value = ensureIdentifier(value, numElements !== 0, target); } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 163) { + if (pattern.kind === 164) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 189) { + else if (element.kind !== 190) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -28563,7 +28925,7 @@ var ts; } } else { - emitAssignment(target.name, value, emitCount > 0); + emitAssignment(target.name, value, emitCount > 0, target); emitCount++; } } @@ -28584,8 +28946,8 @@ var ts; var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 8192); if (isLetDefinedInLoop && - node.parent.parent.kind !== 202 && - node.parent.parent.kind !== 203) { + node.parent.parent.kind !== 203 && + node.parent.parent.kind !== 204) { initializer = createVoidZero(); } } @@ -28603,7 +28965,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 189) { + if (node.kind === 190) { return; } var name = node.name; @@ -28615,7 +28977,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 213 && node.parent.kind !== 165)) { + if (!node.parent || (node.parent.kind !== 214 && node.parent.kind !== 166)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -28623,7 +28985,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 2) && modulekind === 5 && - node.parent.kind === 250; + node.parent.kind === 251; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28668,12 +29030,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); + var name_26 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_26); + emit(name_26); } else { emit(node.name); @@ -28772,12 +29134,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 145 ? "get " : "set "); + write(node.kind === 146 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 176 && languageVersion >= 2; + return node.kind === 177 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -28788,10 +29150,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 175) { + if (node.kind === 176) { return !!node.name; } - if (node.kind === 215) { + if (node.kind === 216) { return !!node.name || modulekind !== 5; } } @@ -28800,12 +29162,12 @@ var ts; return emitCommentsOnNotEmittedNode(node); } var kind = node.kind, parent = node.parent; - if (kind !== 143 && - kind !== 142 && + if (kind !== 144 && + kind !== 143 && parent && - parent.kind !== 247 && - parent.kind !== 170 && - parent.kind !== 166) { + parent.kind !== 248 && + parent.kind !== 171 && + parent.kind !== 167) { emitLeadingComments(node); } emitStart(node); @@ -28826,11 +29188,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 && kind === 215 && parent === currentSourceFile && node.name) { + if (modulekind !== 5 && kind === 216 && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 143 && kind !== 142) { + if (kind !== 144 && kind !== 143) { emitTrailingComments(node); } } @@ -28862,7 +29224,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 176; + var isArrowFunction = node.kind === 177; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; if (!isArrowFunction) { write(" {"); @@ -28903,7 +29265,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 194) { + if (node.body.kind === 195) { emitBlockFunctionBody(node, node.body); } else { @@ -28955,10 +29317,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 173) { + while (current.kind === 174) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 167); + emitParenthesizedIf(body, current.kind === 168); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -29028,9 +29390,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 197) { + if (statement && statement.kind === 198) { var expr = statement.expression; - if (expr && expr.kind === 170) { + if (expr && expr.kind === 171) { var func = expr.expression; if (func && func.kind === 95) { return statement; @@ -29061,7 +29423,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 136) { + else if (memberName.kind === 137) { emitComputedPropertyName(memberName); } else { @@ -29073,7 +29435,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { + if (member.kind === 142 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { properties.push(member); } } @@ -29113,11 +29475,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 193) { + if (member.kind === 194) { writeLine(); write(";"); } - else if (member.kind === 143 || node.kind === 142) { + else if (member.kind === 144 || node.kind === 143) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -29134,7 +29496,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 145 || member.kind === 146) { + else if (member.kind === 146 || member.kind === 147) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -29184,22 +29546,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 143 || node.kind === 142) && !member.body) { + if ((member.kind === 144 || node.kind === 143) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 143 || - member.kind === 145 || - member.kind === 146) { + else if (member.kind === 144 || + member.kind === 146 || + member.kind === 147) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 64) { write("static "); } - if (member.kind === 145) { + if (member.kind === 146) { write("get "); } - else if (member.kind === 146) { + else if (member.kind === 147) { write("set "); } if (member.asteriskToken) { @@ -29210,7 +29572,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 193) { + else if (member.kind === 194) { writeLine(); write(";"); } @@ -29235,10 +29597,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 144 && !member.body) { + if (member.kind === 145 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 141 && member.initializer && (member.flags & 64) === 0) { + if (member.kind === 142 && member.initializer && (member.flags & 64) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -29342,7 +29704,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 216) { + if (node.kind === 217) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); @@ -29359,7 +29721,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 188; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -29422,7 +29784,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 250) { + else if (node.parent.kind !== 251) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -29434,7 +29796,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 216) { + if (node.kind === 217) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -29494,11 +29856,11 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 216) { + if (node.kind === 217) { write(";"); } emitEnd(node); - if (node.kind === 216) { + if (node.kind === 217) { emitExportMemberAssignment(node); } } @@ -29565,7 +29927,7 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 143) { + if (member.kind === 144) { functionLikeMember = member; } } @@ -29591,7 +29953,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0) { - if (member.kind !== 141) { + if (member.kind !== 142) { write(", null"); } else { @@ -29626,45 +29988,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 143: - case 145: + case 144: case 146: - case 141: + case 147: + case 142: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 143: + case 144: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 216: - case 143: - case 146: + case 217: + case 144: + case 147: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 216: + case 217: write("Function"); return; - case 141: + case 142: emitSerializedTypeNode(node.type); return; - case 138: - emitSerializedTypeNode(node.type); - return; - case 145: + case 139: emitSerializedTypeNode(node.type); return; case 146: + emitSerializedTypeNode(node.type); + return; + case 147: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -29680,23 +30042,23 @@ var ts; case 103: write("void 0"); return; - case 160: + case 161: emitSerializedTypeNode(node.type); return; - case 152: case 153: + case 154: write("Function"); return; - case 156: case 157: + case 158: write("Array"); return; - case 150: + case 151: case 120: write("Boolean"); return; case 130: - case 162: + case 163: write("String"); return; case 128: @@ -29705,15 +30067,15 @@ var ts; case 131: write("Symbol"); return; - case 151: + case 152: emitSerializedTypeReferenceNode(node); return; - case 154: case 155: - case 158: + case 156: case 159: + case 160: case 117: - case 161: + case 162: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -29777,7 +30139,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 216) { + if (node.kind === 217) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -29793,10 +30155,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 156) { + if (parameterType.kind === 157) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 152 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -29868,7 +30230,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 219))) { + if (!(node.flags & 2) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -29948,7 +30310,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 220) { + if (moduleDeclaration.body.kind === 221) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -29971,7 +30333,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -29989,7 +30351,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 221) { + if (node.body.kind === 222) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -30060,16 +30422,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 223) { + if (node.kind === 224) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 226) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 224 && node.importClause && !!node.importClause.name; + return node.kind === 225 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -30096,7 +30458,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 226) { + if (node.importClause.namedBindings.kind === 227) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -30122,7 +30484,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 223 && (node.flags & 2) !== 0; + var isExportedImport = node.kind === 224 && (node.flags & 2) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2) { emitLeadingComments(node); @@ -30134,7 +30496,7 @@ var ts; write(" = "); } else { - var isNakedImport = 224 && !node.importClause; + var isNakedImport = 225 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -30301,8 +30663,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 215 && - expression.kind !== 216) { + if (expression.kind !== 216 && + expression.kind !== 217) { write(";"); } emitEnd(node); @@ -30339,18 +30701,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 224: + case 225: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 223: - if (node.moduleReference.kind === 234 && resolver.isReferencedAliasDeclaration(node)) { + case 224: + if (node.moduleReference.kind === 235 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 230: + case 231: if (node.moduleSpecifier) { if (!node.exportClause) { if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { @@ -30365,12 +30727,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_27 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_27] || (exportSpecifiers[name_27] = [])).push(specifier); } } break; - case 229: + case 230: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -30395,18 +30757,18 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 224 && node.importClause) { + if (node.kind === 225 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 230 && node.moduleSpecifier) { + if (node.kind === 231 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode, emitRelativePathAsModuleName) { if (emitRelativePathAsModuleName) { - var name_25 = getExternalModuleNameFromDeclaration(host, resolver, importNode); - if (name_25) { - return "\"" + name_25 + "\""; + var name_28 = getExternalModuleNameFromDeclaration(host, resolver, importNode); + if (name_28) { + return "\"" + name_28 + "\""; } } var moduleName = ts.getExternalModuleName(importNode); @@ -30423,8 +30785,8 @@ var ts; var started = false; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; - var skipNode = importNode.kind === 230 || - (importNode.kind === 224 && !importNode.importClause); + var skipNode = importNode.kind === 231 || + (importNode.kind === 225 && !importNode.importClause); if (skipNode) { continue; } @@ -30449,7 +30811,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 230 && externalImport.exportClause) { + if (externalImport.kind === 231 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30478,7 +30840,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 230) { + if (externalImport.kind !== 231) { continue; } var exportDecl = externalImport; @@ -30552,11 +30914,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; i++) { var local = hoistedVars[i]; - var name_26 = local.kind === 69 + var name_29 = local.kind === 69 ? local : local.name; - if (name_26) { - var text = ts.unescapeIdentifier(name_26.text); + if (name_29) { + var text = ts.unescapeIdentifier(name_29.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30567,7 +30929,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 216 || local.kind === 220 || local.kind === 219) { + if (local.kind === 217 || local.kind === 221 || local.kind === 220) { emitDeclarationName(local); } else { @@ -30601,21 +30963,21 @@ var ts; if (node.flags & 4) { return; } - if (node.kind === 215) { + if (node.kind === 216) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 216) { + if (node.kind === 217) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 219) { + if (node.kind === 220) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30624,7 +30986,7 @@ var ts; } return; } - if (node.kind === 220) { + if (node.kind === 221) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30633,17 +30995,17 @@ var ts; } return; } - if (node.kind === 213 || node.kind === 165) { + if (node.kind === 214 || node.kind === 166) { if (shouldHoistVariable(node, false)) { - var name_27 = node.name; - if (name_27.kind === 69) { + var name_30 = node.name; + if (name_30.kind === 69) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_27); + hoistedVars.push(name_30); } else { - ts.forEachChild(name_27, visit); + ts.forEachChild(name_30, visit); } } return; @@ -30669,7 +31031,7 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 24576) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 250; + ts.getEnclosingBlockScopeContainer(node).kind === 251; } function isCurrentFileSystemExternalModule() { return modulekind === 4 && isCurrentFileExternalModule; @@ -30707,29 +31069,29 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 224: + case 225: if (!entry.importClause) { break; } - case 223: + case 224: ts.Debug.assert(importVariableName !== ""); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 230: + case 231: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { writeLine(); write(exportFunctionForFile + "({"); writeLine(); increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; i_2++) { - if (i_2 !== 0) { + for (var i_1 = 0, len = entry.exportClause.elements.length; i_1 < len; i_1++) { + if (i_1 !== 0) { write(","); writeLine(); } - var e = entry.exportClause.elements[i_2]; + var e = entry.exportClause.elements[i_1]; write("\""); emitNodeWithCommentsAndWithoutSourcemap(e.name); write("\": " + parameterName + "[\""); @@ -30761,10 +31123,10 @@ var ts; for (var i = startIndex; i < node.statements.length; i++) { var statement = node.statements[i]; switch (statement.kind) { - case 215: - case 224: + case 216: + case 225: continue; - case 230: + case 231: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -30772,7 +31134,7 @@ var ts; } } continue; - case 223: + case 224: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { continue; } @@ -31088,22 +31450,22 @@ var ts; } function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + if ((languageVersion < 2) && (!extendsEmitted && node.flags & 4194304)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + if (!decorateEmitted && node.flags & 8388608) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + if (!paramEmitted && node.flags & 16777216) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + if (!awaiterEmitted && node.flags & 33554432) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -31171,30 +31533,43 @@ var ts; emitJavaScriptWorker(node); } } + function changeSourceMapEmit(writer) { + sourceMap = writer; + emitStart = writer.emitStart; + emitEnd = writer.emitEnd; + emitPos = writer.emitPos; + setSourceFile = writer.setSourceFile; + } + function withTemporaryNoSourceMap(callback) { + var prevSourceMap = sourceMap; + setSourceMapWriterEmit(ts.getNullSourceMapWriter()); + callback(); + setSourceMapWriterEmit(prevSourceMap); + } function isSpecializedCommentHandling(node) { switch (node.kind) { - case 217: - case 215: - case 224: - case 223: case 218: - case 229: + case 216: + case 225: + case 224: + case 219: + case 230: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 195: + case 196: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 220: + case 221: return shouldEmitModuleDeclaration(node); - case 219: + case 220: return shouldEmitEnumDeclaration(node); } ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 194 && + if (node.kind !== 195 && node.parent && - node.parent.kind === 176 && + node.parent.kind === 177 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -31205,13 +31580,13 @@ var ts; switch (node.kind) { case 69: return emitIdentifier(node); - case 138: + case 139: return emitParameter(node); + case 144: case 143: - case 142: return emitMethod(node); - case 145: case 146: + case 147: return emitAccessor(node); case 97: return emitThis(node); @@ -31231,142 +31606,142 @@ var ts; case 13: case 14: return emitLiteral(node); - case 185: - return emitTemplateExpression(node); - case 192: - return emitTemplateSpan(node); - case 235: - case 236: - return emitJsxElement(node); - case 238: - return emitJsxText(node); - case 242: - return emitJsxExpression(node); - case 135: - return emitQualifiedName(node); - case 163: - return emitObjectBindingPattern(node); - case 164: - return emitArrayBindingPattern(node); - case 165: - return emitBindingElement(node); - case 166: - return emitArrayLiteral(node); - case 167: - return emitObjectLiteral(node); - case 247: - return emitPropertyAssignment(node); - case 248: - return emitShorthandPropertyAssignment(node); - case 136: - return emitComputedPropertyName(node); - case 168: - return emitPropertyAccess(node); - case 169: - return emitIndexedAccess(node); - case 170: - return emitCallExpression(node); - case 171: - return emitNewExpression(node); - case 172: - return emitTaggedTemplateExpression(node); - case 173: - return emit(node.expression); - case 191: - return emit(node.expression); - case 174: - return emitParenExpression(node); - case 215: - case 175: - case 176: - return emitFunctionDeclaration(node); - case 177: - return emitDeleteExpression(node); - case 178: - return emitTypeOfExpression(node); - case 179: - return emitVoidExpression(node); - case 180: - return emitAwaitExpression(node); - case 181: - return emitPrefixUnaryExpression(node); - case 182: - return emitPostfixUnaryExpression(node); - case 183: - return emitBinaryExpression(node); - case 184: - return emitConditionalExpression(node); - case 187: - return emitSpreadElementExpression(node); case 186: - return emitYieldExpression(node); - case 189: - return; - case 194: - case 221: - return emitBlock(node); - case 195: - return emitVariableStatement(node); - case 196: - return write(";"); - case 197: - return emitExpressionStatement(node); - case 198: - return emitIfStatement(node); - case 199: - return emitDoStatement(node); - case 200: - return emitWhileStatement(node); - case 201: - return emitForStatement(node); - case 203: - case 202: - return emitForInOrForOfStatement(node); - case 204: - case 205: - return emitBreakOrContinueStatement(node); - case 206: - return emitReturnStatement(node); - case 207: - return emitWithStatement(node); - case 208: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 193: + return emitTemplateSpan(node); + case 236: + case 237: + return emitJsxElement(node); + case 239: + return emitJsxText(node); case 243: - case 244: - return emitCaseOrDefaultClause(node); - case 209: - return emitLabeledStatement(node); - case 210: - return emitThrowStatement(node); - case 211: - return emitTryStatement(node); - case 246: - return emitCatchClause(node); - case 212: - return emitDebuggerStatement(node); - case 213: - return emitVariableDeclaration(node); - case 188: - return emitClassExpression(node); - case 216: - return emitClassDeclaration(node); - case 217: - return emitInterfaceDeclaration(node); - case 219: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 136: + return emitQualifiedName(node); + case 164: + return emitObjectBindingPattern(node); + case 165: + return emitArrayBindingPattern(node); + case 166: + return emitBindingElement(node); + case 167: + return emitArrayLiteral(node); + case 168: + return emitObjectLiteral(node); + case 248: + return emitPropertyAssignment(node); case 249: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 137: + return emitComputedPropertyName(node); + case 169: + return emitPropertyAccess(node); + case 170: + return emitIndexedAccess(node); + case 171: + return emitCallExpression(node); + case 172: + return emitNewExpression(node); + case 173: + return emitTaggedTemplateExpression(node); + case 174: + return emit(node.expression); + case 192: + return emit(node.expression); + case 175: + return emitParenExpression(node); + case 216: + case 176: + case 177: + return emitFunctionDeclaration(node); + case 178: + return emitDeleteExpression(node); + case 179: + return emitTypeOfExpression(node); + case 180: + return emitVoidExpression(node); + case 181: + return emitAwaitExpression(node); + case 182: + return emitPrefixUnaryExpression(node); + case 183: + return emitPostfixUnaryExpression(node); + case 184: + return emitBinaryExpression(node); + case 185: + return emitConditionalExpression(node); + case 188: + return emitSpreadElementExpression(node); + case 187: + return emitYieldExpression(node); + case 190: + return; + case 195: + case 222: + return emitBlock(node); + case 196: + return emitVariableStatement(node); + case 197: + return write(";"); + case 198: + return emitExpressionStatement(node); + case 199: + return emitIfStatement(node); + case 200: + return emitDoStatement(node); + case 201: + return emitWhileStatement(node); + case 202: + return emitForStatement(node); + case 204: + case 203: + return emitForInOrForOfStatement(node); + case 205: + case 206: + return emitBreakOrContinueStatement(node); + case 207: + return emitReturnStatement(node); + case 208: + return emitWithStatement(node); + case 209: + return emitSwitchStatement(node); + case 244: + case 245: + return emitCaseOrDefaultClause(node); + case 210: + return emitLabeledStatement(node); + case 211: + return emitThrowStatement(node); + case 212: + return emitTryStatement(node); + case 247: + return emitCatchClause(node); + case 213: + return emitDebuggerStatement(node); + case 214: + return emitVariableDeclaration(node); + case 189: + return emitClassExpression(node); + case 217: + return emitClassDeclaration(node); + case 218: + return emitInterfaceDeclaration(node); case 220: - return emitModuleDeclaration(node); - case 224: - return emitImportDeclaration(node); - case 223: - return emitImportEqualsDeclaration(node); - case 230: - return emitExportDeclaration(node); - case 229: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 250: + return emitEnumMember(node); + case 221: + return emitModuleDeclaration(node); + case 225: + return emitImportDeclaration(node); + case 224: + return emitImportEqualsDeclaration(node); + case 231: + return emitExportDeclaration(node); + case 230: + return emitExportAssignment(node); + case 251: return emitSourceFileNode(node); } } @@ -31396,7 +31771,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 250 || node.pos !== node.parent.pos) { + if (node.parent.kind === 251 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -31408,7 +31783,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 250 || node.end !== node.parent.end) { + if (node.parent.kind === 251 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -31794,7 +32169,23 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + : (function (moduleNames, containingFile) { + var resolvedModuleNames = []; + var lookup = {}; + for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { + var moduleName = moduleNames_1[_i]; + var resolvedName = void 0; + if (ts.hasProperty(lookup, moduleName)) { + resolvedName = lookup[moduleName]; + } + else { + resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule; + lookup[moduleName] = resolvedName; + } + resolvedModuleNames.push(resolvedName); + } + return resolvedModuleNames; + }); var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { @@ -31896,8 +32287,11 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { return false; } + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + return false; + } if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); for (var i = 0; i < moduleNames.length; i++) { var newResolution = resolutions[i]; @@ -32034,44 +32428,44 @@ var ts; return false; } switch (node.kind) { - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 216: + case 217: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 245: + case 246: var heritageClause = node; if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 217: + case 218: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 175: - case 215: + case 147: case 176: - case 215: + case 216: + case 177: + case 216: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -32079,20 +32473,20 @@ var ts; return true; } break; - case 195: + case 196: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 213: + case 214: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 170: case 171: + case 172: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -32100,7 +32494,7 @@ var ts; return true; } break; - case 138: + case 139: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -32116,17 +32510,17 @@ var ts; return true; } break; - case 141: + case 142: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219: + case 220: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 173: + case 174: 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 139: + case 140: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -32202,51 +32596,64 @@ var ts; function moduleNameIsEqualTo(a, b) { return a.text === b.text; } + function getTextOfLiteral(literal) { + return literal.text; + } function collectExternalModuleReferences(file) { if (file.imports) { return; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); + var isExternalModuleFile = ts.isExternalModule(file); var imports; + var moduleAugmentations; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; - collect(node, true, false); + collectModuleReferences(node, false); + if (isJavaScriptFile) { + collectRequireCalls(node); + } } file.imports = imports || emptyArray; + file.moduleAugmentations = moduleAugmentations || emptyArray; return; - function collect(node, allowRelativeModuleNames, collectOnlyRequireCalls) { - if (!collectOnlyRequireCalls) { - switch (node.kind) { - case 224: - case 223: - case 230: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } + function collectModuleReferences(node, inAmbientModule) { + switch (node.kind) { + case 225: + case 224: + case 231: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; - case 220: - if (node.name.kind === 9 && (node.flags & 4 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - collect(node, false, collectOnlyRequireCalls); - }); - } + } + if (!moduleNameExpr.text) { break; - } + } + if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 221: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 || ts.isDeclarationFile(file))) { + var moduleName = node.name; + if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { + (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + } + else if (!inAmbientModule) { + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + collectModuleReferences(statement, true); + } + } + } } - if (isJavaScriptFile) { - if (ts.isRequireCall(node)) { - (imports || (imports = [])).push(node.arguments[0]); - } - else { - ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames, true); }); - } + } + function collectRequireCalls(node) { + if (ts.isRequireCall(node)) { + (imports || (imports = [])).push(node.arguments[0]); + } + else { + ts.forEachChild(node, collectRequireCalls); } } } @@ -32352,14 +32759,17 @@ var ts; } function processImportedModules(file, basePath) { collectExternalModuleReferences(file); - if (file.imports.length) { + if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); - for (var i = 0; i < file.imports.length; i++) { + for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { + var shouldAddFile = resolution && + !options.noResolve && + i < file.imports.length; + if (shouldAddFile) { var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { @@ -33351,7 +33761,8 @@ var ts; return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { - configFileWatcher = ts.sys.watchFile(configFileName, configFileChanged); + var configFilePath = ts.toPath(configFileName, ts.sys.getCurrentDirectory(), ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); + configFileWatcher = ts.sys.watchFile(configFilePath, configFileChanged); } if (ts.sys.watchDirectory && configFileName) { var directory = ts.getDirectoryPath(configFileName); @@ -33435,7 +33846,8 @@ var ts; } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); + var filePath = ts.toPath(sourceFile.fileName, ts.sys.getCurrentDirectory(), ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); + sourceFile.fileWatcher = ts.sys.watchFile(filePath, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } return sourceFile; } @@ -33646,10 +34058,10 @@ var ts; function serializeCompilerOptions(options) { var result = {}; var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name_28 in options) { - if (ts.hasProperty(options, name_28)) { - var value = options[name_28]; - switch (name_28) { + for (var name_31 in options) { + if (ts.hasProperty(options, name_31)) { + var value = options[name_31]; + switch (name_31) { case "init": case "watch": case "version": @@ -33657,17 +34069,17 @@ var ts; case "project": break; default: - var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + var optionDefinition = optionsNameMap[name_31.toLowerCase()]; if (optionDefinition) { if (typeof optionDefinition.type === "string") { - result[name_28] = value; + result[name_31] = value; } else { var typeMap = optionDefinition.type; for (var key in typeMap) { if (ts.hasProperty(typeMap, key)) { if (typeMap[key] === value) - result[name_28] = key; + result[name_31] = key; } } } diff --git a/lib/tsserver.js b/lib/tsserver.js index b04981dc6db..ba62ebe0dde 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -636,7 +636,8 @@ var ts; if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { directoryComponents.length--; } - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + var joinStartIndex; + for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } @@ -773,6 +774,12 @@ var ts; return copiedList; } ts.copyListRemovingItem = copyListRemovingItem; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; })(ts || (ts = {})); var ts; (function (ts) { @@ -911,7 +918,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); - function createWatchedFileSet(interval, chunkSize) { + function createPollingWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } var watchedFiles = []; @@ -925,13 +932,13 @@ var ts; if (!watchedFile) { return; } - _fs.stat(watchedFile.fileName, function (err, stats) { + _fs.stat(watchedFile.filePath, function (err, stats) { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.filePath); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + watchedFile.mtime = getModifiedTime(watchedFile.filePath); + watchedFile.callback(watchedFile.filePath, watchedFile.mtime.getTime() === 0); } }); } @@ -954,11 +961,11 @@ var ts; nextFileToCheck = nextToCheck; }, interval); } - function addFile(fileName, callback) { + function addFile(filePath, callback) { var file = { - fileName: fileName, + filePath: filePath, callback: callback, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(filePath) }; watchedFiles.push(file); if (watchedFiles.length === 1) { @@ -977,7 +984,77 @@ var ts; removeFile: removeFile }; } + function createWatchedFileSet() { + var dirWatchers = ts.createFileMap(); + var fileWatcherCallbacks = ts.createFileMap(); + return { addFile: addFile, removeFile: removeFile }; + function reduceDirWatcherRefCountForFile(filePath) { + var dirPath = ts.getDirectoryPath(filePath); + if (dirWatchers.contains(dirPath)) { + var watcher = dirWatchers.get(dirPath); + watcher.referenceCount -= 1; + if (watcher.referenceCount <= 0) { + watcher.close(); + dirWatchers.remove(dirPath); + } + } + } + function addDirWatcher(dirPath) { + if (dirWatchers.contains(dirPath)) { + var watcher_1 = dirWatchers.get(dirPath); + watcher_1.referenceCount += 1; + return; + } + var watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher.referenceCount = 1; + dirWatchers.set(dirPath, watcher); + return; + } + function addFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + fileWatcherCallbacks.get(filePath).push(callback); + } + else { + fileWatcherCallbacks.set(filePath, [callback]); + } + } + function addFile(filePath, callback) { + addFileWatcherCallback(filePath, callback); + addDirWatcher(ts.getDirectoryPath(filePath)); + return { filePath: filePath, callback: callback }; + } + function removeFile(watchedFile) { + removeFileWatcherCallback(watchedFile.filePath, watchedFile.callback); + reduceDirWatcherRefCountForFile(watchedFile.filePath); + } + function removeFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + var newCallbacks = ts.copyListRemovingItem(callback, fileWatcherCallbacks.get(filePath)); + if (newCallbacks.length === 0) { + fileWatcherCallbacks.remove(filePath); + } + else { + fileWatcherCallbacks.set(filePath, newCallbacks); + } + } + } + function fileEventHandler(eventName, relativeFileName, baseDirPath) { + var filePath = typeof relativeFileName !== "string" + ? undefined + : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); + if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { + var fileCallback = _a[_i]; + fileCallback(filePath); + } + } + } + } + var pollingWatchedFileSet = createPollingWatchedFileSet(); var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -1019,7 +1096,7 @@ var ts; } } function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; + return useCaseSensitiveFileNames ? path : path.toLowerCase(); } function readDirectory(path, extension, exclude) { var result = []; @@ -1059,14 +1136,22 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { - var watchedFile = watchedFileSet.addFile(fileName, callback); + watchFile: function (filePath, callback) { + var watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet; + var watchedFile = watchSet.addFile(filePath, callback); return { - close: function () { return watchedFileSet.removeFile(watchedFile); } + close: function () { return watchSet.removeFile(watchedFile); } }; }, watchDirectory: function (path, callback, recursive) { - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + var options; + if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + options = { persistent: true, recursive: !!recursive }; + } + else { + options = { persistent: true }; + } + return _fs.watch(path, options, function (eventName, relativeFileName) { if (eventName === "rename") { callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); } @@ -1325,7 +1410,6 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -1561,7 +1645,6 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, - A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods: { code: 2519, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_r_2519", message: "A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, @@ -1590,6 +1673,16 @@ var ts; Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, + Cannot_re_export_name_that_is_not_defined_in_the_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_re_export_name_that_is_not_defined_in_the_module_2661", message: "Cannot re-export name that is not defined in the module." }, + 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." }, + Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope_2665", message: "Module augmentation cannot introduce new names in the top level scope." }, + 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." }, + Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, + Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, 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}'." }, @@ -1754,6 +1847,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, 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'." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, 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." }, 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." }, @@ -1849,6 +1943,7 @@ var ts; "protected": 111, "public": 112, "require": 127, + "global": 134, "return": 94, "set": 129, "static": 113, @@ -1869,7 +1964,7 @@ var ts; "yield": 114, "async": 118, "await": 119, - "of": 134, + "of": 135, "{": 15, "}": 16, "(": 17, @@ -3130,7 +3225,7 @@ var ts; break; } } - return token = 238; + return token = 239; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -3831,7 +3926,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 250) { + while (node && node.kind !== 251) { node = node.parent; } return node; @@ -3915,6 +4010,28 @@ var ts; isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isAmbientModule(node) { + return node && node.kind === 221 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 2097152); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 251: + return isExternalModule(node.parent); + case 222: + return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function getEnclosingBlockScopeContainer(node) { var current = node.parent; while (current) { @@ -3922,15 +4039,15 @@ var ts; return current; } switch (current.kind) { - case 250: - case 222: - case 246: - case 220: - case 201: + case 251: + case 223: + case 247: + case 221: case 202: case 203: + case 204: return current; - case 194: + case 195: if (!isFunctionLike(current.parent)) { return current; } @@ -3941,9 +4058,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 213 && + declaration.kind === 214 && declaration.parent && - declaration.parent.kind === 246; + declaration.parent.kind === 247; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3979,23 +4096,24 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 250: + case 251: 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 213: - case 165: - case 216: - case 188: + case 214: + case 166: case 217: + case 189: + case 218: + case 221: case 220: + case 250: + case 216: + case 176: + case 144: case 219: - case 249: - case 215: - case 175: - case 143: errorNode = node.name; break; } @@ -4021,11 +4139,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 219 && isConst(node); + return node.kind === 220 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 165 || isBindingPattern(node))) { + while (node && (node.kind === 166 || isBindingPattern(node))) { node = node.parent; } return node; @@ -4033,14 +4151,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 213) { + if (node.kind === 214) { node = node.parent; } - if (node && node.kind === 214) { + if (node && node.kind === 215) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 195) { + if (node && node.kind === 196) { flags |= node.flags; } return flags; @@ -4055,7 +4173,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 197 && node.expression.kind === 9; + return node.kind === 198 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4071,7 +4189,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 138 || node.kind === 137) ? + var commentRanges = (node.kind === 139 || node.kind === 138) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -4085,7 +4203,7 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (150 <= node.kind && node.kind <= 162) { + if (151 <= node.kind && node.kind <= 163) { return true; } switch (node.kind) { @@ -4096,56 +4214,56 @@ var ts; case 131: return true; case 103: - return node.parent.kind !== 179; - case 190: + return node.parent.kind !== 180; + case 191: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 69: - if (node.parent.kind === 135 && node.parent.right === node) { + if (node.parent.kind === 136 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 168 && node.parent.name === node) { + else if (node.parent.kind === 169 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 168, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135: - case 168: + ts.Debug.assert(node.kind === 69 || node.kind === 136 || node.kind === 169, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 136: + case 169: case 97: var parent_1 = node.parent; - if (parent_1.kind === 154) { + if (parent_1.kind === 155) { return false; } - if (150 <= parent_1.kind && parent_1.kind <= 162) { + if (151 <= parent_1.kind && parent_1.kind <= 163) { return true; } switch (parent_1.kind) { - case 190: + case 191: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137: - return node === parent_1.constraint; - case 141: - case 140: case 138: - case 213: + return node === parent_1.constraint; + case 142: + case 141: + case 139: + case 214: return node === parent_1.type; - case 215: - case 175: + case 216: case 176: + case 177: + case 145: case 144: case 143: - case 142: - case 145: case 146: - return node === parent_1.type; case 147: + return node === parent_1.type; case 148: case 149: + case 150: return node === parent_1.type; - case 173: + case 174: return node === parent_1.type; - case 170: case 171: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 172: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 173: return false; } } @@ -4156,23 +4274,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 206: + case 207: return visitor(node); - case 222: - case 194: - case 198: + case 223: + case 195: case 199: case 200: case 201: case 202: case 203: - case 207: + case 204: case 208: - case 243: - case 244: case 209: - case 211: - case 246: + case 244: + case 245: + case 210: + case 212: + case 247: return ts.forEachChild(node, traverse); } } @@ -4182,23 +4300,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186: + case 187: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 219: - case 217: case 220: case 218: - case 216: - case 188: + case 221: + case 219: + case 217: + case 189: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 136) { + if (name_5 && name_5.kind === 137) { traverse(name_5.expression); return; } @@ -4213,14 +4331,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 165: - case 249: - case 138: - case 247: - case 141: - case 140: + case 166: + case 250: + case 139: case 248: - case 213: + case 142: + case 141: + case 249: + case 214: return true; } } @@ -4228,11 +4346,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 145 || node.kind === 146); + return node && (node.kind === 146 || node.kind === 147); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 216 || node.kind === 188); + return node && (node.kind === 217 || node.kind === 189); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -4241,32 +4359,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 144: - case 175: - case 215: - case 176: - case 143: - case 142: case 145: + case 176: + case 216: + case 177: + case 144: + case 143: case 146: case 147: case 148: case 149: - case 152: + case 150: case 153: + case 154: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 215: - case 175: + case 147: + case 216: + case 176: return true; } return false; @@ -4274,24 +4392,24 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 201: case 202: case 203: - case 199: + case 204: case 200: + case 201: return true; - case 209: + case 210: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 194 && isFunctionLike(node.parent); + return node && node.kind === 195 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 143 && node.parent.kind === 167; + return node && node.kind === 144 && node.parent.kind === 168; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { @@ -4323,39 +4441,39 @@ var ts; return undefined; } switch (node.kind) { - case 136: + case 137: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + case 140: + if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 176: + case 177: if (!includeArrowFunctions) { continue; } - case 215: - case 175: - case 220: - case 141: - case 140: - case 143: + case 216: + case 176: + case 221: case 142: + case 141: case 144: + case 143: case 145: case 146: case 147: case 148: case 149: - case 219: - case 250: + case 150: + case 220: + case 251: return node; } } @@ -4368,25 +4486,25 @@ var ts; return node; } switch (node.kind) { - case 136: + case 137: node = node.parent; break; - case 215: - case 175: + case 216: case 176: + case 177: if (!stopOnFunctions) { continue; } - case 141: - case 140: - case 143: case 142: + case 141: case 144: + case 143: case 145: case 146: + case 147: return node; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + case 140: + if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -4400,12 +4518,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 151: + case 152: return node.typeName; - case 190: + case 191: return node.expression; case 69: - case 135: + case 136: return node; } } @@ -4413,7 +4531,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 172) { + if (node.kind === 173) { return node.tag; } return node.expression; @@ -4421,54 +4539,36 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 216: + case 217: return true; - case 141: - return node.parent.kind === 216; - case 138: - return node.parent.body && node.parent.parent.kind === 216; - case 145: + case 142: + return node.parent.kind === 217; case 146: - case 143: - return node.body && node.parent.kind === 216; + case 147: + case 144: + return node.body !== undefined + && node.parent.kind === 217; + case 139: + return node.parent.body !== undefined + && (node.parent.kind === 145 + || node.parent.kind === 144 + || node.parent.kind === 147) + && node.parent.parent.kind === 217; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { - switch (node.kind) { - case 216: - if (node.decorators) { - return true; - } - return false; - case 141: - case 138: - if (node.decorators) { - return true; - } - return false; - case 145: - if (node.body && node.decorators) { - return true; - } - return false; - case 143: - case 146: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; + return node.decorators !== undefined + && nodeCanBeDecorated(node); } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 168; + return node.kind === 169; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 169; + return node.kind === 170; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -4478,42 +4578,42 @@ var ts; case 99: case 84: case 10: - case 166: case 167: case 168: case 169: case 170: case 171: case 172: - case 191: case 173: + case 192: case 174: case 175: - case 188: case 176: - case 179: + case 189: case 177: + case 180: case 178: - case 181: + case 179: case 182: case 183: case 184: - case 187: case 185: - case 11: - case 189: - case 235: - case 236: + case 188: case 186: - case 180: + case 11: + case 190: + case 236: + case 237: + case 187: + case 181: return true; - case 135: - while (node.parent.kind === 135) { + case 136: + while (node.parent.kind === 136) { node = node.parent; } - return node.parent.kind === 154; + return node.parent.kind === 155; case 69: - if (node.parent.kind === 154) { + if (node.parent.kind === 155) { return true; } case 8: @@ -4521,47 +4621,47 @@ var ts; case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 213: - case 138: + case 214: + case 139: + case 142: case 141: - case 140: - case 249: - case 247: - case 165: + case 250: + case 248: + case 166: return parent_2.initializer === node; - case 197: case 198: case 199: case 200: - case 206: + case 201: case 207: case 208: - case 243: - case 210: - case 208: + case 209: + case 244: + case 211: + case 209: return parent_2.expression === node; - case 201: + case 202: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 214) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 215) || forStatement.condition === node || forStatement.incrementor === node; - case 202: case 203: + case 204: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 214) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215) || forInStatement.expression === node; - case 173: - case 191: - return node === parent_2.expression; + case 174: case 192: return node === parent_2.expression; - case 136: + case 193: return node === parent_2.expression; - case 139: + case 137: + return node === parent_2.expression; + case 140: + case 243: case 242: - case 241: return true; - case 190: + case 191: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4583,7 +4683,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 && node.moduleReference.kind === 234; + return node.kind === 224 && node.moduleReference.kind === 235; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4592,7 +4692,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 && node.moduleReference.kind !== 234; + return node.kind === 224 && node.moduleReference.kind !== 235; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -4604,7 +4704,7 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression) { - return expression.kind === 170 && + return expression.kind === 171 && expression.expression.kind === 69 && expression.expression.text === "require" && expression.arguments.length === 1 && @@ -4612,11 +4712,11 @@ var ts; } ts.isRequireCall = isRequireCall; function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 183) { + if (expression.kind !== 184) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 168) { + if (expr.operatorToken.kind !== 56 || expr.left.kind !== 169) { return 0; } var lhs = expr.left; @@ -4632,7 +4732,7 @@ var ts; else if (lhs.expression.kind === 97) { return 4; } - else if (lhs.expression.kind === 168) { + else if (lhs.expression.kind === 169) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 && innerPropertyAccess.name.text === "prototype") { return 3; @@ -4642,30 +4742,33 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 224) { + if (node.kind === 225) { return node.moduleSpecifier; } - if (node.kind === 223) { + if (node.kind === 224) { var reference = node.moduleReference; - if (reference.kind === 234) { + if (reference.kind === 235) { return reference.expression; } } - if (node.kind === 230) { + if (node.kind === 231) { return node.moduleSpecifier; } + if (node.kind === 221 && node.name.kind === 9) { + return node.name; + } } ts.getExternalModuleName = getExternalModuleName; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 138: + case 139: + case 144: case 143: - case 142: + case 249: case 248: - case 247: + case 142: case 141: - case 140: return node.questionToken !== undefined; } } @@ -4673,9 +4776,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 263 && + return node.kind === 264 && node.parameters.length > 0 && - node.parameters[0].type.kind === 265; + node.parameters[0].type.kind === 266; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4689,15 +4792,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 271); + return getJSDocTag(node, 272); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 270); + return getJSDocTag(node, 271); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 272); + return getJSDocTag(node, 273); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -4706,7 +4809,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 269) { + if (t.kind === 270) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4725,12 +4828,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 264) { + if (node.type && node.type.kind === 265) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 264; + return paramTag.typeExpression.type.kind === 265; } } return node.dotDotDotToken !== undefined; @@ -4751,7 +4854,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 164 || node.kind === 163); + return !!node && (node.kind === 165 || node.kind === 164); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -4775,34 +4878,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 176: - case 165: - case 216: - case 188: - case 144: - case 219: - case 249: - case 232: - case 215: - case 175: - case 145: - case 225: - case 223: - case 228: + case 177: + case 166: case 217: - case 143: - case 142: + case 189: + case 145: case 220: - case 226: - case 138: - case 247: - case 141: - case 140: + case 250: + case 233: + case 216: + case 176: case 146: - case 248: + case 226: + case 224: + case 229: case 218: - case 137: - case 213: + case 144: + case 143: + case 221: + case 227: + case 139: + case 248: + case 142: + case 141: + case 147: + case 249: + case 219: + case 138: + case 214: return true; } return false; @@ -4810,25 +4913,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 205: - case 204: - case 212: - case 199: - case 197: - case 196: - case 202: - case 203: - case 201: - case 198: - case 209: case 206: - case 208: - case 210: - case 211: - case 195: + case 205: + case 213: case 200: + case 198: + case 197: + case 203: + case 204: + case 202: + case 199: + case 210: case 207: - case 229: + case 209: + case 211: + case 212: + case 196: + case 201: + case 208: + case 230: return true; default: return false; @@ -4837,13 +4940,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 144: - case 141: - case 143: case 145: - case 146: case 142: - case 149: + case 144: + case 146: + case 147: + case 143: + case 150: return true; default: return false; @@ -4855,7 +4958,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 228 || parent.kind === 232) { + if (parent.kind === 229 || parent.kind === 233) { if (parent.propertyName) { return true; } @@ -4869,40 +4972,40 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 141: - case 140: - case 143: case 142: - case 145: + case 141: + case 144: + case 143: case 146: - case 249: - case 247: - case 168: + case 147: + case 250: + case 248: + case 169: return parent.name === node; - case 135: + case 136: if (parent.right === node) { - while (parent.kind === 135) { + while (parent.kind === 136) { parent = parent.parent; } - return parent.kind === 154; + return parent.kind === 155; } return false; - case 165: - case 228: + case 166: + case 229: return parent.propertyName === node; - case 232: + case 233: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 223 || - node.kind === 225 && !!node.name || - node.kind === 226 || - node.kind === 228 || - node.kind === 232 || - node.kind === 229 && node.expression.kind === 69; + return node.kind === 224 || + node.kind === 226 && !!node.name || + node.kind === 227 || + node.kind === 229 || + node.kind === 233 || + node.kind === 230 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4984,7 +5087,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 134; + return 70 <= token && token <= 135; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5004,7 +5107,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 136 && + return name.kind === 137 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -5017,7 +5120,7 @@ var ts; if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 136) { + if (name.kind === 137) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5054,18 +5157,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 138; + return root.kind === 139; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 165) { + while (node.kind === 166) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 220 || n.kind === 250; + return isFunctionLike(n) || n.kind === 221 || n.kind === 251; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneNode(node, location, flags, parent) { @@ -5098,7 +5201,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 135; + return node.kind === 136; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -5411,7 +5514,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 144 && nodeIsPresent(member.body)) { + if (member.kind === 145 && nodeIsPresent(member.body)) { return member; } }); @@ -5428,10 +5531,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 145) { + if (accessor.kind === 146) { getAccessor = accessor; } - else if (accessor.kind === 146) { + else if (accessor.kind === 147) { setAccessor = accessor; } else { @@ -5440,7 +5543,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 145 || member.kind === 146) + if ((member.kind === 146 || member.kind === 147) && (member.flags & 64) === (accessor.flags & 64)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5451,10 +5554,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 145 && !getAccessor) { + if (member.kind === 146 && !getAccessor) { getAccessor = member; } - if (member.kind === 146 && !setAccessor) { + if (member.kind === 147 && !setAccessor) { setAccessor = member; } } @@ -5620,24 +5723,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 168: case 169: - case 171: case 170: - case 235: - case 236: case 172: - case 166: - case 174: + case 171: + case 236: + case 237: + case 173: case 167: - case 188: case 175: + case 168: + case 189: + case 176: case 69: case 10: case 8: case 9: case 11: - case 185: + case 186: case 84: case 93: case 97: @@ -5654,7 +5757,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 190 && + return node.kind === 191 && node.parent.token === 83 && isClassLike(node.parent.parent); } @@ -5675,16 +5778,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 && node.parent.right === node) || - (node.parent.kind === 168 && node.parent.name === node); + return (node.parent.kind === 136 && node.parent.right === node) || + (node.parent.kind === 169 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 167) { + if (kind === 168) { return expression.properties.length === 0; } - if (kind === 166) { + if (kind === 167) { return expression.elements.length === 0; } return false; @@ -5928,9 +6031,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 137) { + if (d && d.kind === 138) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 217) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218) { return current; } } @@ -5938,7 +6041,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 && node.parent.kind === 144 && ts.isClassLike(node.parent.parent); + return node.flags & 56 && node.parent.kind === 145 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -5948,7 +6051,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 250) { + if (kind === 251) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -5984,26 +6087,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 135: + case 136: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 137: + case 138: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 248: + case 249: 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 138: + case 139: + case 142: case 141: - case 140: - case 247: - case 213: - case 165: + case 248: + case 214: + case 166: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6012,24 +6115,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152: case 153: - case 147: + case 154: case 148: case 149: + case 150: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 175: - case 215: + case 147: case 176: + case 216: + case 177: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6040,160 +6143,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 151: + case 152: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 150: + case 151: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 154: - return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 156: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 157: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 158: + return visitNodes(cbNodes, node.elementTypes); case 159: - return visitNodes(cbNodes, node.types); case 160: + return visitNodes(cbNodes, node.types); + case 161: return visitNode(cbNode, node.type); - case 163: case 164: - return visitNodes(cbNodes, node.elements); - case 166: + case 165: return visitNodes(cbNodes, node.elements); case 167: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 168: + return visitNodes(cbNodes, node.properties); + case 169: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 169: + case 170: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 170: case 171: + case 172: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 172: + case 173: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 173: + case 174: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 174: - return visitNode(cbNode, node.expression); - case 177: + case 175: return visitNode(cbNode, node.expression); case 178: return visitNode(cbNode, node.expression); case 179: return visitNode(cbNode, node.expression); - case 181: - return visitNode(cbNode, node.operand); - case 186: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 180: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.operand); + case 187: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 181: + return visitNode(cbNode, node.expression); case 183: + return visitNode(cbNode, node.operand); + case 184: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 191: + case 192: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 184: + case 185: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 187: + case 188: return visitNode(cbNode, node.expression); - case 194: - case 221: + case 195: + case 222: return visitNodes(cbNodes, node.statements); - case 250: + case 251: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 195: + case 196: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 214: + case 215: return visitNodes(cbNodes, node.declarations); - case 197: - return visitNode(cbNode, node.expression); case 198: + return visitNode(cbNode, node.expression); + case 199: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 199: + case 200: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 200: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 201: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 202: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 203: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 204: - case 205: - return visitNode(cbNode, node.label); - case 206: - return visitNode(cbNode, node.expression); - case 207: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 205: + case 206: + return visitNode(cbNode, node.label); + case 207: + return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 222: + case 223: return visitNodes(cbNodes, node.clauses); - case 243: + case 244: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 244: + case 245: return visitNodes(cbNodes, node.statements); - case 209: + case 210: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 210: - return visitNode(cbNode, node.expression); case 211: + return visitNode(cbNode, node.expression); + case 212: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 246: + case 247: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 139: + case 140: return visitNode(cbNode, node.expression); - case 216: - case 188: - 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 217: + case 189: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -6205,125 +6301,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 249: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 220: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 250: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 223: + case 224: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 225: + case 226: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 226: - return visitNode(cbNode, node.name); case 227: - case 231: + return visitNode(cbNode, node.name); + case 228: + case 232: return visitNodes(cbNodes, node.elements); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 228: - case 232: + case 229: + case 233: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 185: + case 186: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 192: + case 193: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 245: + case 246: return visitNodes(cbNodes, node.types); - case 190: + case 191: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 234: - return visitNode(cbNode, node.expression); - case 233: - return visitNodes(cbNodes, node.decorators); case 235: + return visitNode(cbNode, node.expression); + case 234: + return visitNodes(cbNodes, node.decorators); + case 236: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 236: case 237: + case 238: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 240: + case 241: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 241: - return visitNode(cbNode, node.expression); case 242: return visitNode(cbNode, node.expression); - case 239: + case 243: + return visitNode(cbNode, node.expression); + case 240: return visitNode(cbNode, node.tagName); - case 251: + case 252: return visitNode(cbNode, node.type); - case 255: - return visitNodes(cbNodes, node.types); case 256: return visitNodes(cbNodes, node.types); - case 254: + case 257: + return visitNodes(cbNodes, node.types); + case 255: return visitNode(cbNode, node.elementType); + case 259: + return visitNode(cbNode, node.type); case 258: return visitNode(cbNode, node.type); - case 257: - return visitNode(cbNode, node.type); - case 259: + case 260: return visitNodes(cbNodes, node.members); - case 261: + case 262: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 262: - return visitNode(cbNode, node.type); case 263: + return visitNode(cbNode, node.type); + case 264: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 264: - return visitNode(cbNode, node.type); case 265: return visitNode(cbNode, node.type); case 266: return visitNode(cbNode, node.type); - case 260: + case 267: + return visitNode(cbNode, node.type); + case 261: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 267: + case 268: return visitNodes(cbNodes, node.tags); - case 269: + case 270: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 270: - return visitNode(cbNode, node.typeExpression); case 271: return visitNode(cbNode, node.typeExpression); case 272: + return visitNode(cbNode, node.typeExpression); + case 273: return visitNodes(cbNodes, node.typeParameters); } } @@ -6430,9 +6533,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 195: - case 215: - case 138: + case 196: + case 216: + case 139: addJSDocComment(node); } forEachChild(node, visit); @@ -6466,7 +6569,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = new SourceFileConstructor(250, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(251, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -6757,7 +6860,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(136); + var node = createNode(137); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -7056,14 +7159,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 144: - case 149: case 145: + case 150: case 146: - case 141: - case 193: + case 147: + case 142: + case 194: return true; - case 143: + case 144: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 69 && methodDeclaration.name.originalKeywordKind === 121; @@ -7075,8 +7178,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 243: case 244: + case 245: return true; } } @@ -7085,65 +7188,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 215: + case 216: + case 196: case 195: - case 194: + case 199: case 198: - case 197: - case 210: + case 211: + case 207: + case 209: case 206: - case 208: case 205: + case 203: case 204: case 202: - case 203: case 201: - case 200: - case 207: - case 196: - case 211: - case 209: - case 199: + case 208: + case 197: case 212: + case 210: + case 200: + case 213: + case 225: case 224: - case 223: + case 231: case 230: - case 229: - case 220: - case 216: + case 221: case 217: - case 219: case 218: + case 220: + case 219: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 249; + return node.kind === 250; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 148: - case 142: case 149: - case 140: - case 147: + case 143: + case 150: + case 141: + case 148: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 213) { + if (node.kind !== 214) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 138) { + if (node.kind !== 139) { return false; } var parameter = node; @@ -7243,7 +7346,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(135, entity.pos); + var node = createNode(136, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7260,7 +7363,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(185); + var template = createNode(186); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -7273,7 +7376,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(192); + var span = createNode(193); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -7287,7 +7390,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(162, true); + return parseLiteralLikeNode(163, true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -7315,12 +7418,9 @@ var ts; } return node; } - function parseTypeReferenceOrTypePredicate() { + function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(typeName); - } - var node = createNode(151, typeName.pos); + var node = createNode(152, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -7329,24 +7429,24 @@ var ts; } function parseTypePredicate(lhs) { nextToken(); - var node = createNode(150, lhs.pos); + var node = createNode(151, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(161); + var node = createNode(162); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(154); + var node = createNode(155); parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(137); + var node = createNode(138); node.name = parseIdentifier(); if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { @@ -7379,7 +7479,7 @@ var ts; } } function parseParameter() { - var node = createNode(138); + var node = createNode(139); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -7404,10 +7504,10 @@ var ts; signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } else if (parseOptional(returnToken)) { - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { @@ -7434,7 +7534,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 148) { + if (kind === 149) { parseExpected(92); } fillSignature(54, false, false, false, node); @@ -7474,7 +7574,7 @@ var ts; return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149, fullStart); + var node = createNode(150, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -7487,7 +7587,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(142, fullStart); + var method = createNode(143, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(54, false, false, false, method); @@ -7495,7 +7595,7 @@ var ts; return finishNode(method); } else { - var property = createNode(140, fullStart); + var property = createNode(141, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7540,14 +7640,14 @@ var ts; switch (token) { case 17: case 25: - return parseSignatureMember(147); + return parseSignatureMember(148); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148); + return parseSignatureMember(149); } case 9: case 8: @@ -7577,7 +7677,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(155); + var node = createNode(156); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7593,12 +7693,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(157); + var node = createNode(158); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(160); + var node = createNode(161); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7606,7 +7706,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(92); } fillSignature(34, false, false, false, node); @@ -7624,7 +7724,7 @@ var ts; case 120: case 131: var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); + return node || parseTypeReference(); case 9: return parseStringLiteralTypeNode(); case 103: @@ -7647,7 +7747,7 @@ var ts; case 17: return parseParenthesizedType(); default: - return parseTypeReferenceOrTypePredicate(); + return parseTypeReference(); } } function isStartOfType() { @@ -7680,7 +7780,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(156, type.pos); + var node = createNode(157, type.pos); node.elementType = type; type = finishNode(node); } @@ -7702,10 +7802,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(160, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(159, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7734,15 +7834,35 @@ var ts; } return false; } + function parseTypeOrTypePredicate() { + var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); + var type = parseType(); + if (typePredicateVariable) { + var node = createNode(151, typePredicateVariable.pos); + node.parameterName = typePredicateVariable; + node.type = type; + return finishNode(node); + } + else { + return type; + } + } + function parseTypePredicatePrefix() { + var id = parseIdentifier(); + if (token === 124 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + return id; + } + } function parseType() { return doOutsideOfContext(10, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152); + return parseFunctionOrConstructorType(153); } if (token === 92) { - return parseFunctionOrConstructorType(153); + return parseFunctionOrConstructorType(154); } return parseUnionTypeOrHigher(); } @@ -7861,7 +7981,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(186); + var node = createNode(187); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7875,8 +7995,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(176, identifier.pos); - var parameter = createNode(138, identifier.pos); + var node = createNode(177, identifier.pos); + var parameter = createNode(139, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7987,7 +8107,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(176); + var node = createNode(177); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); @@ -8019,7 +8139,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(184, leftOperand.pos); + var node = createNode(185, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8032,7 +8152,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 134; + return t === 90 || t === 135; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -8110,43 +8230,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(183, left.pos); + var node = createNode(184, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(191, left.pos); + var node = createNode(192, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(181); + var node = createNode(182); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(177); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(178); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(179); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(180); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token === 119) { if (inAwaitContext()) { @@ -8157,7 +8277,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(180); + var node = createNode(181); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -8176,7 +8296,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 173) { + if (simpleUnaryExpression.kind === 174) { 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 { @@ -8224,7 +8344,7 @@ var ts; } function parseIncrementExpression() { if (token === 41 || token === 42) { - var node = createNode(181); + var node = createNode(182); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -8236,7 +8356,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(182, expression.pos); + var node = createNode(183, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -8259,7 +8379,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(168, expression.pos); + var node = createNode(169, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -8278,8 +8398,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 237) { - var node = createNode(235, opening.pos); + if (opening.kind === 238) { + var node = createNode(236, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -8289,14 +8409,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 236); + ts.Debug.assert(opening.kind === 237); result = opening; } if (inExpressionContext && token === 25) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(183, result.pos); + var badNode = createNode(184, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -8308,13 +8428,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(238, scanner.getStartPos()); + var node = createNode(239, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 238: + case 239: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -8350,7 +8470,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(237, fullStart); + node = createNode(238, fullStart); scanJsxText(); } else { @@ -8362,7 +8482,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(236, fullStart); + node = createNode(237, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -8373,7 +8493,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(135, elementName.pos); + var node = createNode(136, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -8381,7 +8501,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(242); + var node = createNode(243); parseExpected(15); if (token !== 16) { node.expression = parseAssignmentExpressionOrHigher(); @@ -8400,7 +8520,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(240); + var node = createNode(241); node.name = parseIdentifierName(); if (parseOptional(56)) { switch (token) { @@ -8415,7 +8535,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(241); + var node = createNode(242); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -8423,7 +8543,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(239); + var node = createNode(240); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -8436,7 +8556,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(173); + var node = createNode(174); parseExpected(25); node.type = parseType(); parseExpected(27); @@ -8447,7 +8567,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(168, expression.pos); + var propertyAccess = createNode(169, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8455,7 +8575,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(169, expression.pos); + var indexedAccess = createNode(170, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -8469,7 +8589,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(172, expression.pos); + var tagExpression = createNode(173, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -8488,7 +8608,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(170, expression.pos); + var callExpr = createNode(171, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8496,7 +8616,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(170, expression.pos); + var callExpr = createNode(171, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8591,28 +8711,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(174); + var node = createNode(175); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(187); + var node = createNode(188); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(189) : + token === 24 ? createNode(190) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(166); + var node = createNode(167); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 1024; @@ -8622,10 +8742,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123)) { - return parseAccessorDeclaration(145, fullStart, decorators, modifiers); + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } else if (parseContextualModifier(129)) { - return parseAccessorDeclaration(146, fullStart, decorators, modifiers); + return parseAccessorDeclaration(147, fullStart, decorators, modifiers); } return undefined; } @@ -8646,7 +8766,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(248, fullStart); + var shorthandDeclaration = createNode(249, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56); @@ -8657,7 +8777,7 @@ var ts; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(247, fullStart); + var propertyAssignment = createNode(248, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -8667,7 +8787,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(167); + var node = createNode(168); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 1024; @@ -8681,7 +8801,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(175); + var node = createNode(176); setModifiers(node, parseModifiers()); parseExpected(87); node.asteriskToken = parseOptionalToken(37); @@ -8703,7 +8823,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(171); + var node = createNode(172); parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -8713,7 +8833,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(194); + var node = createNode(195); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8741,12 +8861,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(198); + var node = createNode(199); parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8756,7 +8876,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(199); + var node = createNode(200); parseExpected(79); node.statement = parseStatement(); parseExpected(104); @@ -8767,7 +8887,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(200); + var node = createNode(201); parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8790,21 +8910,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90)) { - var forInStatement = createNode(202, pos); + var forInStatement = createNode(203, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(134)) { - var forOfStatement = createNode(203, pos); + else if (parseOptional(135)) { + var forOfStatement = createNode(204, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(201, pos); + var forStatement = createNode(202, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8822,7 +8942,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 205 ? 70 : 75); + parseExpected(kind === 206 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8830,7 +8950,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -8839,7 +8959,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8848,7 +8968,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(243); + var node = createNode(244); parseExpected(71); node.expression = allowInAnd(parseExpression); parseExpected(54); @@ -8856,7 +8976,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(244); + var node = createNode(245); parseExpected(77); parseExpected(54); node.statements = parseList(3, parseStatement); @@ -8866,12 +8986,12 @@ var ts; return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(222, scanner.getStartPos()); + var caseBlock = createNode(223, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8879,14 +8999,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(100); node.tryBlock = parseBlock(false); node.catchClause = token === 72 ? parseCatchClause() : undefined; @@ -8897,7 +9017,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(246); + var result = createNode(247); parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); @@ -8907,7 +9027,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(212); + var node = createNode(213); parseExpected(76); parseSemicolon(); return finishNode(node); @@ -8916,13 +9036,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(209, fullStart); + var labeledStatement = createNode(210, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(197, fullStart); + var expressionStatement = createNode(198, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -8967,6 +9087,8 @@ var ts; return false; } continue; + case 134: + return nextToken() === 15; case 89: nextToken(); return token === 9 || token === 37 || @@ -9024,6 +9146,7 @@ var ts; case 125: case 126: case 132: + case 134: return true; case 112: case 110: @@ -9067,9 +9190,9 @@ var ts; case 86: return parseForOrForInOrForOfStatement(); case 75: - return parseBreakOrContinueStatement(204); - case 70: return parseBreakOrContinueStatement(205); + case 70: + return parseBreakOrContinueStatement(206); case 94: return parseReturnStatement(); case 105: @@ -9101,6 +9224,7 @@ var ts; case 112: case 115: case 113: + case 134: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -9127,6 +9251,7 @@ var ts; return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); + case 134: case 125: case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -9139,7 +9264,7 @@ var ts; parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(233, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(234, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -9160,16 +9285,16 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(189); + return createNode(190); } - var node = createNode(165); + var node = createNode(166); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(165); + var node = createNode(166); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54) { @@ -9184,14 +9309,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(163); + var node = createNode(164); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(164); + var node = createNode(165); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -9210,7 +9335,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(213); + var node = createNode(214); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -9219,7 +9344,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(214); + var node = createNode(215); switch (token) { case 102: break; @@ -9233,7 +9358,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 135 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -9248,7 +9373,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(195, fullStart); + var node = createNode(196, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -9256,7 +9381,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87); @@ -9269,7 +9394,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144, pos); + var node = createNode(145, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121); @@ -9278,7 +9403,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143, fullStart); + var method = createNode(144, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -9291,7 +9416,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141, fullStart); + var property = createNode(142, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -9387,7 +9512,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(139, decoratorStart); + var decorator = createNode(140, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -9443,7 +9568,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(193); + var result = createNode(194); nextToken(); return finishNode(result); } @@ -9474,10 +9599,10 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 188); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 189); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 216); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -9512,7 +9637,7 @@ var ts; } function parseHeritageClause() { if (token === 83 || token === 106) { - var node = createNode(245); + var node = createNode(246); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -9521,7 +9646,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(190); + var node = createNode(191); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9535,7 +9660,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107); @@ -9546,7 +9671,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); + var node = createNode(219, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(132); @@ -9558,13 +9683,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(249, scanner.getStartPos()); + var node = createNode(250, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219, fullStart); + var node = createNode(220, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81); @@ -9579,7 +9704,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(221, scanner.getStartPos()); + var node = createNode(222, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9590,7 +9715,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); var namespaceFlag = flags & 65536; node.decorators = decorators; setModifiers(node, modifiers); @@ -9602,16 +9727,25 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + if (token === 134) { + node.name = parseIdentifier(); + node.flags |= 2097152; + } + else { + node.name = parseLiteralNode(true); + } node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126)) { + if (token === 134) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + else if (parseOptional(126)) { flags |= 65536; } else { @@ -9639,7 +9773,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token !== 24 && token !== 133) { - var importEqualsDeclaration = createNode(223, fullStart); + var importEqualsDeclaration = createNode(224, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -9649,7 +9783,7 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(224, fullStart); + var importDeclaration = createNode(225, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || @@ -9663,13 +9797,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(225, fullStart); + var importClause = createNode(226, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(227); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(228); } return finishNode(importClause); } @@ -9679,7 +9813,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(234); + var node = createNode(235); parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); @@ -9697,7 +9831,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(226); + var namespaceImport = createNode(227); parseExpected(37); parseExpected(116); namespaceImport.name = parseIdentifier(); @@ -9705,14 +9839,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 227 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 228 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(232); + return parseImportOrExportSpecifier(233); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(229); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9731,13 +9865,13 @@ var ts; else { node.name = identifierName; } - if (kind === 228 && checkIdentifierIsKeyword) { + if (kind === 229 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { @@ -9745,7 +9879,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(231); + node.exportClause = parseNamedImportsOrExports(232); if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); @@ -9755,7 +9889,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56)) { @@ -9827,10 +9961,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 2 - || node.kind === 223 && node.moduleReference.kind === 234 - || node.kind === 224 - || node.kind === 229 + || node.kind === 224 && node.moduleReference.kind === 235 + || node.kind === 225 || node.kind === 230 + || node.kind === 231 ? node : undefined; }); @@ -9865,7 +9999,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(251); + var result = createNode(252); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9876,12 +10010,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47) { - var unionType = createNode(255, type.pos); + var unionType = createNode(256, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56) { - var optionalType = createNode(262, type.pos); + var optionalType = createNode(263, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9892,20 +10026,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(254, type.pos); + var arrayType = createNode(255, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } else if (token === 53) { - var nullableType = createNode(257, type.pos); + var nullableType = createNode(258, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49) { - var nonNullableType = createNode(258, type.pos); + var nonNullableType = createNode(259, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9949,27 +10083,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(266); + var result = createNode(267); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(265); + var result = createNode(266); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(264); + var result = createNode(265); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(263); + var result = createNode(264); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); @@ -9982,12 +10116,12 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(138); + var parameter = createNode(139); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(261); + var result = createNode(262); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -10016,13 +10150,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(135, left.pos); + var result = createNode(136, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -10030,7 +10164,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(260); + var result = createNode(261); result.name = parseSimplePropertyName(); if (token === 54) { nextToken(); @@ -10039,13 +10173,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(258); + var result = createNode(259); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(256); + var result = createNode(257); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -10059,7 +10193,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(255); + var result = createNode(256); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -10077,7 +10211,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(252); + var result = createNode(253); nextToken(); return finishNode(result); } @@ -10090,11 +10224,11 @@ var ts; token === 27 || token === 56 || token === 47) { - var result = createNode(253, pos); + var result = createNode(254, pos); return finishNode(result); } else { - var result = createNode(257, pos); + var result = createNode(258, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -10165,7 +10299,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(267, start); + var result = createNode(268, start); result.tags = tags; return finishNode(result, end); } @@ -10202,7 +10336,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(268, atToken.pos); + var result = createNode(269, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -10253,7 +10387,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(269, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -10263,16 +10397,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(270, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 271; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -10282,10 +10406,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 272; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(272, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 273; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -10296,7 +10430,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(137, name_8.pos); + var typeParameter = createNode(138, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -10307,7 +10441,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(272, atToken.pos); + var result = createNode(273, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -10629,16 +10763,16 @@ var ts; : 4; } function getModuleInstanceState(node) { - if (node.kind === 217 || node.kind === 218) { + if (node.kind === 218 || node.kind === 219) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 224 || node.kind === 223) && !(node.flags & 2)) { + else if ((node.kind === 225 || node.kind === 224) && !(node.flags & 2)) { return 0; } - else if (node.kind === 221) { + else if (node.kind === 222) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -10654,7 +10788,7 @@ var ts; }); return state; } - else if (node.kind === 220) { + else if (node.kind === 221) { return getModuleInstanceState(node.body); } else { @@ -10682,6 +10816,10 @@ var ts; var labelStack; var labelIndexMap; var implicitLabels; + var hasClassExtends; + var hasAsyncFunctions; + var hasDecorators; + var hasParameterDecorators; var inStrictMode; var symbolCount = 0; var Symbol; @@ -10708,6 +10846,10 @@ var ts; labelStack = undefined; labelIndexMap = undefined; implicitLabels = undefined; + hasClassExtends = false; + hasAsyncFunctions = false; + hasDecorators = false; + hasParameterDecorators = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -10730,17 +10872,17 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 220)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221)) { symbol.valueDeclaration = node; } } } function getDeclarationName(node) { if (node.name) { - if (node.kind === 220 && node.name.kind === 9) { - return "\"" + node.name.text + "\""; + if (ts.isAmbientModule(node)) { + return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 136) { + if (node.name.kind === 137) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -10751,21 +10893,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 144: + case 145: return "__constructor"; - case 152: - case 147: - return "__call"; case 153: case 148: - return "__new"; + return "__call"; + case 154: case 149: + return "__new"; + case 150: return "__index"; - case 230: + case 231: return "__export"; - case 229: + case 230: return node.isExportEquals ? "export=" : "default"; - case 183: + case 184: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -10777,8 +10919,8 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 215: case 216: + case 217: return node.flags & 512 ? "default" : undefined; } } @@ -10826,7 +10968,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; if (symbolFlags & 8388608) { - if (node.kind === 232 || (node.kind === 223 && hasExportModifier)) { + if (node.kind === 233 || (node.kind === 224 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10834,7 +10976,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 131072) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072)) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -10873,10 +11015,11 @@ var ts; var kind = node.kind; var flags = node.flags; flags &= ~1572864; - if (kind === 217) { + flags &= ~62914560; + if (kind === 218) { seenThisKeyword = false; } - var saveState = kind === 250 || kind === 221 || ts.isFunctionLikeKind(kind); + var saveState = kind === 251 || kind === 222 || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -10894,9 +11037,23 @@ var ts; flags |= 1048576; } } - if (kind === 217) { + if (kind === 218) { flags = seenThisKeyword ? flags | 262144 : flags & ~262144; } + if (kind === 251) { + if (hasClassExtends) { + flags |= 4194304; + } + if (hasDecorators) { + flags |= 8388608; + } + if (hasParameterDecorators) { + flags |= 16777216; + } + if (hasAsyncFunctions) { + flags |= 33554432; + } + } node.flags = flags; if (saveState) { hasExplicitReturn = savedHasExplicitReturn; @@ -10915,40 +11072,40 @@ var ts; return; } switch (node.kind) { - case 200: + case 201: bindWhileStatement(node); break; - case 199: + case 200: bindDoStatement(node); break; - case 201: + case 202: bindForStatement(node); break; - case 202: case 203: + case 204: bindForInOrForOfStatement(node); break; - case 198: + case 199: bindIfStatement(node); break; - case 206: - case 210: + case 207: + case 211: bindReturnOrThrow(node); break; + case 206: case 205: - case 204: bindBreakOrContinueStatement(node); break; - case 211: + case 212: bindTryStatement(node); break; - case 208: + case 209: bindSwitchStatement(node); break; - case 222: + case 223: bindCaseBlock(node); break; - case 209: + case 210: bindLabeledStatement(node); break; default: @@ -11010,14 +11167,14 @@ var ts; } function bindReturnOrThrow(n) { bind(n.expression); - if (n.kind === 206) { + if (n.kind === 207) { hasExplicitReturn = true; } currentReachabilityState = 4; } function bindBreakOrContinueStatement(n) { bind(n.label); - var isValidJump = jumpToLabel(n.label, n.kind === 205 ? currentReachabilityState : 4); + var isValidJump = jumpToLabel(n.label, n.kind === 206 ? currentReachabilityState : 4); if (isValidJump) { currentReachabilityState = 4; } @@ -11038,7 +11195,7 @@ var ts; var postSwitchLabel = pushImplicitLabel(); bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 244; }); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245; }); var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); } @@ -11063,37 +11220,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 188: - case 216: + case 189: case 217: - case 219: - case 155: - case 167: + case 218: + case 220: + case 156: + case 168: return 1; - case 147: case 148: case 149: - case 143: - case 142: - case 215: + case 150: case 144: + case 143: + case 216: case 145: case 146: - case 152: + case 147: case 153: - case 175: + case 154: case 176: - case 220: - case 250: - case 218: + case 177: + case 221: + case 251: + case 219: return 5; - case 246: - case 201: + case 247: case 202: case 203: - case 222: + case 204: + case 223: return 2; - case 194: + case 195: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -11109,33 +11266,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 220: + case 221: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 250: + case 251: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 188: - case 216: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 219: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155: - case 167: + case 189: case 217: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 220: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 156: + case 168: + case 218: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 152: case 153: - case 147: + case 154: case 148: case 149: - case 143: - case 142: + case 150: case 144: + case 143: case 145: case 146: - case 215: - case 175: + case 147: + case 216: case 176: - case 218: + case 177: + case 219: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -11150,11 +11307,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 250 ? node : node.body; - if (body.kind === 250 || body.kind === 221) { + var body = node.kind === 251 ? node : node.body; + if (body.kind === 251 || body.kind === 222) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 230 || stat.kind === 229) { + if (stat.kind === 231 || stat.kind === 230) { return true; } } @@ -11171,7 +11328,10 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 9) { + if (ts.isAmbientModule(node)) { + if (node.flags & 2) { + errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); + } declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -11213,7 +11373,7 @@ var ts; continue; } var identifier = prop.name; - var currentKind = prop.kind === 247 || prop.kind === 248 || prop.kind === 143 + var currentKind = prop.kind === 248 || prop.kind === 249 || prop.kind === 144 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -11235,10 +11395,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 220: + case 221: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 250: + case 251: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -11360,17 +11520,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 250: - case 221: + case 251: + case 222: updateStrictModeStatementList(node.statements); return; - case 194: + case 195: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 216: - case 188: + case 217: + case 189: inStrictMode = true; return; } @@ -11395,7 +11555,7 @@ var ts; switch (node.kind) { case 69: return checkStrictModeIdentifier(node); - case 183: + case 184: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -11418,94 +11578,91 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 246: + case 247: return checkStrictModeCatchClause(node); - case 177: + case 178: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 182: + case 183: return checkStrictModePostfixUnaryExpression(node); - case 181: + case 182: return checkStrictModePrefixUnaryExpression(node); - case 207: + case 208: return checkStrictModeWithStatement(node); - case 161: + case 162: seenThisKeyword = true; return; - case 150: + case 151: return checkTypePredicate(node); - case 137: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); case 138: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 139: return bindParameter(node); - case 213: - case 165: + case 214: + case 166: return bindVariableDeclarationOrBindingElement(node); + case 142: case 141: - case 140: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 247: case 248: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 249: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 250: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 147: case 148: case 149: + case 150: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 143: - case 142: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 215: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16, 106927); case 144: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 143: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 216: + return bindFunctionDeclaration(node); case 145: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 146: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 147: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 152: case 153: + case 154: return bindFunctionOrConstructorType(node); - case 155: + case 156: return bindAnonymousDeclaration(node, 2048, "__type"); - case 167: + case 168: return bindObjectLiteralExpression(node); - case 175: case 176: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16, bindingName); - case 170: + case 177: + return bindFunctionExpression(node); + case 171: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 188: - case 216: - return bindClassLikeDeclaration(node); + case 189: case 217: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 218: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 219: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 220: + return bindEnumDeclaration(node); + case 221: return bindModuleDeclaration(node); - case 223: - case 226: - case 228: - case 232: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 225: - return bindImportClause(node); - case 230: - return bindExportDeclaration(node); + case 224: + case 227: case 229: + case 233: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 226: + return bindImportClause(node); + case 231: + return bindExportDeclaration(node); + case 230: return bindExportAssignment(node); - case 250: + case 251: return bindSourceFileIfExternalModule(); } } @@ -11514,7 +11671,7 @@ var ts; if (parameterName && parameterName.kind === 69) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 161) { + if (parameterName && parameterName.kind === 162) { seenThisKeyword = true; } bind(type); @@ -11529,7 +11686,7 @@ var ts; bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 229 ? node.expression : node.right; + var boundExpression = node.kind === 230 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } @@ -11568,7 +11725,7 @@ var ts; bindExportAssignment(node); } function bindThisPropertyAssignment(node) { - if (container.kind === 175 || container.kind === 215) { + if (container.kind === 176 || container.kind === 216) { container.symbol.members = container.symbol.members || {}; declareSymbol(container.symbol.members, container.symbol, node, 4, 107455); } @@ -11590,7 +11747,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 216) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { + hasClassExtends = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } + if (node.kind === 217) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -11633,6 +11798,12 @@ var ts; } } function bindParameter(node) { + if (!ts.isDeclarationFile(file) && + !ts.isInAmbientContext(node) && + ts.nodeIsDecorated(node)) { + hasDecorators = true; + hasParameterDecorators = true; + } if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } @@ -11647,7 +11818,34 @@ var ts; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } } + function bindFunctionDeclaration(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + } + function bindFunctionExpression(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16, bindingName); + } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -11707,15 +11905,15 @@ var ts; function checkUnreachable(node) { switch (currentReachabilityState) { case 4: - var reportError = (ts.isStatement(node) && node.kind !== 196) || - node.kind === 216 || - (node.kind === 220 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 219 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatement(node) && node.kind !== 197) || + node.kind === 217 || + (node.kind === 221 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 220 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 195 || + (node.kind !== 196 || ts.getCombinedNodeFlags(node.declarationList) & 24576 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -11789,6 +11987,7 @@ var ts; getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, @@ -11803,6 +12002,7 @@ var ts; getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, @@ -11876,11 +12076,6 @@ var ts; var unionTypes = {}; var intersectionTypes = {}; var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -12013,7 +12208,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 220 && source.valueDeclaration.kind !== 220))) { + (target.valueDeclaration.kind === 221 && source.valueDeclaration.kind !== 221))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -12067,6 +12262,24 @@ var ts; } } } + function mergeModuleAugmentation(moduleName) { + var moduleAugmentation = moduleName.parent; + if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { + ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); + return; + } + if (ts.isGlobalScopeAugmentation(moduleAugmentation)) { + mergeSymbolTable(globals, moduleAugmentation.symbol.exports); + } + else { + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); + if (!mainModule) { + return; + } + mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + } function addToSymbolTable(target, source, message) { for (var id in source) { if (ts.hasProperty(source, id)) { @@ -12092,17 +12305,8 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } - function getSourceFile(node) { - return ts.getAncestor(node, 250); - } function isGlobalSourceFile(node) { - return node.kind === 250 && !ts.isExternalOrCommonJsModule(node); - } - function isPrimitiveApparentType(type) { - return type === globalStringType || - type === globalNumberType || - type === globalBooleanType || - type === globalESSymbolType; + return node.kind === 251 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12140,18 +12344,18 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 213 || + return declaration.kind !== 214 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 195 || - declaration.parent.parent.kind === 201) { + if (declaration.parent.parent.kind === 196 || + declaration.parent.parent.kind === 202) { return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 203 || - declaration.parent.parent.kind === 202) { + else if (declaration.parent.parent.kind === 204 || + declaration.parent.parent.kind === 203) { var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); } @@ -12167,7 +12371,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 && + current.parent.kind === 142 && (current.parent.flags & 64) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -12192,15 +12396,15 @@ var ts; if (meaning & result.flags & 793056) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 138 || - lastLocation.kind === 137 + lastLocation.kind === 139 || + lastLocation.kind === 138 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 138 || + lastLocation.kind === 139 || (lastLocation === location.type && - result.valueDeclaration.kind === 138); + result.valueDeclaration.kind === 139); } } if (useResult) { @@ -12212,13 +12416,12 @@ var ts; } } switch (location.kind) { - case 250: + case 251: if (!ts.isExternalOrCommonJsModule(location)) break; - case 220: + case 221: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 250 || - (location.kind === 220 && location.name.kind === 9)) { + if (location.kind === 251 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -12228,7 +12431,7 @@ var ts; } if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 232)) { + ts.getDeclarationOfKind(moduleExports[name], 233)) { break; } } @@ -12236,13 +12439,13 @@ var ts; break loop; } break; - case 219: + case 220: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 142: case 141: - case 140: if (ts.isClassLike(location.parent) && !(location.flags & 64)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -12252,9 +12455,9 @@ var ts; } } break; - case 216: - case 188: case 217: + case 189: + case 218: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 64) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -12262,7 +12465,7 @@ var ts; } break loop; } - if (location.kind === 188 && meaning & 32) { + if (location.kind === 189 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -12270,28 +12473,28 @@ var ts; } } break; - case 136: + case 137: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 217) { + if (ts.isClassLike(grandparent) || grandparent.kind === 218) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 215: - case 176: + case 147: + case 216: + case 177: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 175: + case 176: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -12304,8 +12507,8 @@ var ts; } } break; - case 139: - if (location.parent && location.parent.kind === 138) { + case 140: + if (location.parent && location.parent.kind === 139) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -12321,7 +12524,9 @@ var ts; } if (!result) { if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } } return undefined; } @@ -12340,11 +12545,40 @@ var ts; } return result; } + function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { + if (!errorLocation || (errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + return false; + } + var container = ts.getThisContainer(errorLocation, true); + var location = container; + while (location) { + if (ts.isClassLike(location.parent)) { + var classSymbol = getSymbolOfNode(location.parent); + if (!classSymbol) { + break; + } + var constructorType = getTypeOfSymbol(classSymbol); + if (getPropertyOfType(constructorType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg), symbolToString(classSymbol)); + return true; + } + if (location === container && !(location.flags & 64)) { + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + if (getPropertyOfType(instanceType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return true; + } + } + } + location = location.parent; + } + return false; + } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 213), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -12361,10 +12595,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 223) { + if (node.kind === 224) { return node; } - while (node && node.kind !== 224) { + while (node && node.kind !== 225) { node = node.parent; } return node; @@ -12374,7 +12608,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 234) { + if (node.moduleReference.kind === 235) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12458,17 +12692,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 223: + case 224: return getTargetOfImportEqualsDeclaration(node); - case 225: - return getTargetOfImportClause(node); case 226: + return getTargetOfImportClause(node); + case 227: return getTargetOfNamespaceImport(node); - case 228: - return getTargetOfImportSpecifier(node); - case 232: - return getTargetOfExportSpecifier(node); case 229: + return getTargetOfImportSpecifier(node); + case 233: + return getTargetOfExportSpecifier(node); + case 230: return getTargetOfExportAssignment(node); } } @@ -12510,10 +12744,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 229) { + if (node.kind === 230) { checkExpressionCached(node.expression); } - else if (node.kind === 232) { + else if (node.kind === 233) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -12523,17 +12757,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 223); + importDeclaration = ts.getAncestor(entityName, 224); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 135) { + if (entityName.kind === 69 || entityName.parent.kind === 136) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 223); + ts.Debug.assert(entityName.parent.kind === 224); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -12552,9 +12786,9 @@ var ts; return undefined; } } - else if (name.kind === 135 || name.kind === 168) { - var left = name.kind === 135 ? name.left : name.expression; - var right = name.kind === 135 ? name.right : name.name; + else if (name.kind === 136 || name.kind === 169) { + var left = name.kind === 136 ? name.left : name.expression; + var right = name.kind === 136 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12574,6 +12808,9 @@ var ts; return symbol.flags & meaning ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { + return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); + } + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { if (moduleReferenceExpression.kind !== 9) { return; } @@ -12586,19 +12823,24 @@ var ts; if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { - return symbol; + return getMergedSymbol(symbol); } } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReferenceLiteral.text); var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { - return sourceFile.symbol; + return getMergedSymbol(sourceFile.symbol); } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; + if (moduleNotFoundError) { + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + } + return undefined; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + if (moduleNotFoundError) { + error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + } + return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; @@ -12709,7 +12951,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 === 144 && ts.nodeIsPresent(member.body)) { + if (member.kind === 145 && ts.nodeIsPresent(member.body)) { return member; } } @@ -12775,17 +13017,17 @@ var ts; } } switch (location_1.kind) { - case 250: + case 251: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 220: + case 221: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 216: case 217: + case 218: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12818,7 +13060,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 232)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -12847,7 +13089,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 232)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -12902,8 +13144,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 220 && declaration.name.kind === 9) || - (declaration.kind === 250 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 251 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12935,11 +13176,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { meaning = 107455 | 1048576; } - else if (entityName.kind === 135 || entityName.kind === 168 || - entityName.parent.kind === 223) { + else if (entityName.kind === 136 || entityName.kind === 169 || + entityName.parent.kind === 224) { meaning = 1536; } else { @@ -12990,15 +13231,20 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent; } - if (node.kind === 218) { + if (node.kind === 219) { return getSymbolOfNode(node); } } return undefined; } + function isTopLevelInExternalModuleAugmentation(node) { + return node && node.parent && + node.parent.kind === 222 && + ts.isExternalModuleAugmentation(node.parent.parent); + } function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -13007,10 +13253,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 188: + case 189: return "(Anonymous class)"; - case 175: case 176: + case 177: return "(Anonymous function)"; } } @@ -13224,7 +13470,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 250 || declaration.parent.kind === 221; + return declaration.parent.kind === 251 || declaration.parent.kind === 222; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -13478,60 +13724,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 165: + case 166: return isDeclarationVisible(node.parent.parent); - case 213: + case 214: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 220: - case 216: + case 221: case 217: case 218: - case 215: case 219: - case 223: + case 216: + case 220: + case 224: + if (ts.isExternalModuleAugmentation(node)) { + return true; + } var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 2) && - !(node.kind !== 223 && parent_4.kind !== 250 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 224 && parent_4.kind !== 251 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 141: - case 140: - case 145: - case 146: - case 143: case 142: + case 141: + case 146: + case 147: + case 144: + case 143: if (node.flags & (16 | 32)) { return false; } - case 144: - case 148: - case 147: + case 145: case 149: - case 138: - case 221: - case 152: + case 148: + case 150: + case 139: + case 222: case 153: - case 155: - case 151: + case 154: case 156: + case 152: case 157: case 158: case 159: case 160: + case 161: return isDeclarationVisible(node.parent); - case 225: case 226: - case 228: - return false; - case 137: - case 250: - return true; + case 227: case 229: return false; + case 138: + case 251: + return true; + case 230: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -13539,10 +13788,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 229) { + if (node.parent && node.parent.kind === 230) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 232) { + else if (node.parent.kind === 233) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -13564,7 +13813,9 @@ var ts; var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); + if (importSymbol) { + buildVisibleNodeList(importSymbol.declarations); + } } }); } @@ -13617,10 +13868,10 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 213 ? node.parent.parent.parent : node.parent; + return node.kind === 214 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(prototype.parent); + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } function getTypeOfPropertyOfType(type, name) { @@ -13641,7 +13892,7 @@ var ts; case 9: case 8: return name.text; - case 136: + case 137: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -13649,7 +13900,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 136 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 137 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -13664,7 +13915,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 163) { + if (pattern.kind === 164) { var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { return anyType; @@ -13702,10 +13953,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 202) { - return anyType; - } if (declaration.parent.parent.kind === 203) { + return stringType; + } + if (declaration.parent.parent.kind === 204) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -13714,10 +13965,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138) { + if (declaration.kind === 139) { var func = declaration.parent; - if (func.kind === 146 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); + if (func.kind === 147 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13730,7 +13981,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 248) { + if (declaration.kind === 249) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -13777,7 +14028,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 189 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 190 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -13786,7 +14037,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 163 + return pattern.kind === 164 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -13796,10 +14047,10 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 247) { + if (declaration.kind === 248) { return type; } - if (type.flags & 134217728 && (declaration.kind === 141 || declaration.kind === 140)) { + if (type.flags & 134217728 && (declaration.kind === 142 || declaration.kind === 141)) { return type; } return getWidenedType(type); @@ -13807,7 +14058,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 139 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13820,17 +14071,17 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 246) { + if (declaration.parent.kind === 247) { return links.type = anyType; } - if (declaration.kind === 229) { + if (declaration.kind === 230) { return links.type = checkExpression(declaration.expression); } - if (declaration.kind === 183) { + if (declaration.kind === 184) { return links.type = checkExpression(declaration.right); } - if (declaration.kind === 168) { - if (declaration.parent.kind === 183) { + if (declaration.kind === 169) { + if (declaration.parent.kind === 184) { return links.type = checkExpressionCached(declaration.parent.right); } } @@ -13856,7 +14107,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 145) { + if (accessor.kind === 146) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13872,8 +14123,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 145); - var setter = ts.getDeclarationOfKind(symbol, 146); + var getter = ts.getDeclarationOfKind(symbol, 146); + var setter = ts.getDeclarationOfKind(symbol, 147); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -13899,7 +14150,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145); + var getter_1 = ts.getDeclarationOfKind(symbol, 146); 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)); } } @@ -13988,9 +14239,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 216 || node.kind === 188 || - node.kind === 215 || node.kind === 175 || - node.kind === 143 || node.kind === 176) { + if (node.kind === 217 || node.kind === 189 || + node.kind === 216 || node.kind === 176 || + node.kind === 144 || node.kind === 177) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -13999,15 +14250,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 217); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 218); 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 === 217 || node.kind === 216 || - node.kind === 188 || node.kind === 218) { + if (node.kind === 218 || node.kind === 217 || + node.kind === 189 || node.kind === 219) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14130,7 +14381,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 218 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -14159,7 +14410,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217) { + if (declaration.kind === 218) { if (declaration.flags & 262144) { return false; } @@ -14208,7 +14459,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 218); + var declaration = ts.getDeclarationOfKind(symbol, 219); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -14239,7 +14490,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137).constraint) { + if (!ts.getDeclarationOfKind(symbol, 138).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14291,11 +14542,11 @@ var ts; case 120: case 131: case 103: - case 162: + case 163: return true; - case 156: + case 157: return isIndependentType(node.elementType); - case 151: + case 152: return isIndependentTypeReference(node); } return false; @@ -14304,7 +14555,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 145 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -14320,12 +14571,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 141: - case 140: - return isIndependentVariableLikeDeclaration(declaration); - case 143: case 142: + case 141: + return isIndependentVariableLikeDeclaration(declaration); case 144: + case 143: + case 145: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -14838,7 +15089,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 144 ? + var classType = declaration.kind === 145 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : @@ -14854,7 +15105,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 162) { + if (param.type && param.type.kind === 163) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -14877,8 +15128,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146); + if (declaration.kind === 146 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 147); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -14896,19 +15147,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 152: case 153: - case 215: - case 143: - case 142: + case 154: + case 216: case 144: - case 147: + case 143: + case 145: case 148: case 149: - case 145: + case 150: case 146: - case 175: + case 147: case 176: + case 177: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -14988,7 +15239,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; + var isConstructor = signature.declaration.kind === 145 || signature.declaration.kind === 149; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -15025,7 +15276,7 @@ var ts; : undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 137).constraint; + return ts.getDeclarationOfKind(type.symbol, 138).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -15058,7 +15309,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138).parent); } function getTypeListId(types) { if (types) { @@ -15144,7 +15395,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 151 ? node.typeName : + var typeNameOrExpression = node.kind === 152 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -15170,9 +15421,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 216: case 217: - case 219: + case 218: + case 220: return declaration; } } @@ -15388,9 +15639,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 217)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 218)) { if (!(container.flags & 64) && - (container.kind !== 144 || ts.isNodeDescendentOf(node, container.body))) { + (container.kind !== 145 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -15434,34 +15685,34 @@ var ts; return esSymbolType; case 103: return voidType; - case 161: - return getTypeFromThisTypeNode(node); case 162: + return getTypeFromThisTypeNode(node); + case 163: return getTypeFromStringLiteralTypeNode(node); - case 151: - return getTypeFromTypeReference(node); - case 150: - return getTypeFromPredicateTypeNode(node); - case 190: - return getTypeFromTypeReference(node); - case 154: - return getTypeFromTypeQueryNode(node); - case 156: - return getTypeFromArrayTypeNode(node); - case 157: - return getTypeFromTupleTypeNode(node); - case 158: - return getTypeFromUnionTypeNode(node); - case 159: - return getTypeFromIntersectionTypeNode(node); - case 160: - return getTypeFromTypeNode(node.type); case 152: - case 153: + return getTypeFromTypeReference(node); + case 151: + return getTypeFromPredicateTypeNode(node); + case 191: + return getTypeFromTypeReference(node); case 155: + return getTypeFromTypeQueryNode(node); + case 157: + return getTypeFromArrayTypeNode(node); + case 158: + return getTypeFromTupleTypeNode(node); + case 159: + return getTypeFromUnionTypeNode(node); + case 160: + return getTypeFromIntersectionTypeNode(node); + case 161: + return getTypeFromTypeNode(node.type); + case 153: + case 154: + case 156: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 69: - case 135: + case 136: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15641,27 +15892,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 175: case 176: + case 177: return isContextSensitiveFunctionLikeDeclaration(node); - case 167: + case 168: return ts.forEach(node.properties, isContextSensitive); - case 166: + case 167: return ts.forEach(node.elements, isContextSensitive); - case 184: + case 185: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 183: + case 184: return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 247: + case 248: return isContextSensitive(node.initializer); + case 144: case 143: - case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 174: + case 175: return isContextSensitive(node.expression); } return false; @@ -15689,6 +15940,9 @@ var ts; function compareTypesIdentical(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 : 0; } + function compareTypesAssignable(source, target) { + return checkTypeRelatedTo(source, target, assignableRelation, undefined) ? -1 : 0; + } function isTypeSubtypeOf(source, target) { return checkTypeSubtypeOf(source, target, undefined); } @@ -15702,39 +15956,52 @@ var ts; return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { + return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + } + function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { if (source === target) { - return true; + return -1; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return 0; } source = getErasedSignature(source); target = getErasedSignature(target); + var result = -1; var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); + var sourceParams = source.parameters; + var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var related = isTypeAssignableTo(t, s) || isTypeAssignableTo(s, t); + var s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target); + var related = compareTypes(t, s, false) || compareTypes(s, t, reportErrors); if (!related) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); + } + return 0; } + result &= related; } if (!ignoreReturnTypes) { var targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) { - return true; + return result; } var sourceReturnType = getReturnTypeOfSignature(source); if (targetReturnType.flags & 134217728 && targetReturnType.predicate.kind === 1) { if (!(sourceReturnType.flags & 134217728)) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; } } - return isTypeAssignableTo(sourceReturnType, targetReturnType); + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); } - return true; + return result; } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); @@ -15777,18 +16044,12 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; - var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + var result = isRelatedTo(source, target, !!errorNode, headMessage); if (overflow) { error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } else if (errorInfo) { - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); } @@ -15796,6 +16057,7 @@ var ts; } return result !== 0; function reportError(message, arg0, arg1, arg2) { + ts.Debug.assert(!!errorNode); errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } function reportRelationError(message, source, target) { @@ -15916,10 +16178,10 @@ var ts; return result; } } - var apparentType = getApparentType(source); - if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + var apparentSource = getApparentType(source); + if (apparentSource.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 16777726); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } @@ -15974,6 +16236,7 @@ var ts; var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { if (reportErrors) { + ts.Debug.assert(!!errorNode); errorNode = prop.valueDeclaration; reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } @@ -16066,7 +16329,7 @@ var ts; var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { - if (elaborateErrors && related === 2) { + if (reportErrors && related === 2) { relation[id] = 3; } else { @@ -16260,7 +16523,7 @@ var ts; shouldElaborateErrors = false; } } - if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind)); } return 0; @@ -16269,65 +16532,7 @@ var ts; return result; } function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) { - return result; - } - var sourceReturnType = getReturnTypeOfSignature(source); - if (targetReturnType.flags & 134217728 && targetReturnType.predicate.kind === 1) { - if (!(sourceReturnType.flags & 134217728)) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0; - } - } - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -16690,22 +16895,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 142: case 141: - case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 138: + case 139: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 215: + case 216: + case 144: case 143: - case 142: - case 145: case 146: - case 175: + case 147: case 176: + case 177: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16994,10 +17199,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 154: + case 155: return true; case 69: - case 135: + case 136: node = node.parent; continue; default: @@ -17038,55 +17243,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 183: + case 184: return isAssignedInBinaryExpression(node); - case 213: - case 165: - return isAssignedInVariableDeclaration(node); - case 163: - case 164: + case 214: case 166: + return isAssignedInVariableDeclaration(node); + case 164: + case 165: case 167: case 168: case 169: case 170: case 171: - case 173: - case 191: + case 172: case 174: - case 181: - case 177: - case 180: - case 178: - case 179: + case 192: + case 175: case 182: - case 186: - case 184: + case 178: + case 181: + case 179: + case 180: + case 183: case 187: - case 194: + case 185: + case 188: case 195: - case 197: + case 196: case 198: case 199: case 200: case 201: case 202: case 203: - case 206: + case 204: case 207: case 208: - case 243: - case 244: case 209: + case 244: + case 245: case 210: case 211: - case 246: - case 235: + case 212: + case 247: case 236: - case 240: - case 241: case 237: + case 241: case 242: + case 238: + case 243: return ts.forEachChild(node, isAssignedIn); } return false; @@ -17096,7 +17301,7 @@ var ts; var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -17104,13 +17309,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 198: + case 199: + case 185: case 184: - case 183: nodeStack.push({ node: node, child: child }); break; - case 250: - case 220: + case 251: + case 221: break loop; } if (node === top_1) { @@ -17121,17 +17326,17 @@ var ts; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 198: + case 199: if (child !== node_1.expression) { type = narrowType(type, node_1.expression, child === node_1.thenStatement); } break; - case 184: + case 185: if (child !== node_1.condition) { type = narrowType(type, node_1.condition, child === node_1.whenTrue); } break; - case 183: + case 184: if (child === node_1.right) { if (node_1.operatorToken.kind === 51) { type = narrowType(type, node_1.left, true); @@ -17155,7 +17360,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 178 || expr.right.kind !== 9) { + if (expr.left.kind !== 179 || expr.right.kind !== 9) { return type; } var left = expr.left; @@ -17170,9 +17375,6 @@ var ts; if (typeInfo && typeInfo.type === undefinedType) { return type; } - if (!!(type.flags & 1) && typeInfo && assumeTrue) { - return typeInfo.type; - } var flags; if (typeInfo) { flags = typeInfo.flags; @@ -17182,6 +17384,9 @@ var ts; flags = 132 | 258 | 16777216 | 8; } if (!(type.flags & 16384)) { + if (assumeTrue && typeInfo && isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } return filterUnion(type) ? type : emptyUnionType; } return getUnionType(ts.filter(type.types, filterUnion), true); @@ -17296,7 +17501,7 @@ var ts; return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); } function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 169 || expression.kind === 168) { + if (expression.kind === 170 || expression.kind === 169) { var accessExpression = expression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { @@ -17309,18 +17514,18 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69: - case 168: - case 135: + case 169: + case 136: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 170: + case 171: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 174: + case 175: return narrowType(type, expr.expression, assumeTrue); - case 183: + case 184: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -17335,20 +17540,20 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 181: + case 182: if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; + case 170: case 169: - case 168: return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 174) { + while (expression.kind === 175) { expression = expression.expression; } return expression; @@ -17357,7 +17562,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 176) { + if (container.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -17388,7 +17593,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 246) { + symbol.valueDeclaration.parent.kind === 247) { return; } var container; @@ -17397,11 +17602,11 @@ var ts; } else { container = symbol.valueDeclaration; - while (container.kind !== 214) { + while (container.kind !== 215) { container = container.parent; } container = container.parent; - if (container.kind === 195) { + if (container.kind === 196) { container = container.parent; } } @@ -17420,7 +17625,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 141 || container.kind === 144) { + if (container.kind === 142 || container.kind === 145) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -17431,29 +17636,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 176) { + if (container.kind === 177) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 220: + case 221: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 219: + case 220: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 144: + case 145: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 142: case 141: - case 140: if (container.flags & 64) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 136: + case 137: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -17464,7 +17669,7 @@ var ts; var symbol = getSymbolOfNode(container.parent); return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } - if (ts.isInJavaScriptFile(node) && container.kind === 175) { + if (ts.isInJavaScriptFile(node) && container.kind === 176) { if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -17480,18 +17685,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138) { + if (n.kind === 139) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 170 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 171 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 176) { + while (container && container.kind === 177) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -17500,16 +17705,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 136) { + while (current && current !== container && current.kind !== 137) { current = current.parent; } - if (current && current.kind === 136) { + if (current && current.kind === 137) { 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 === 167)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -17527,7 +17732,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 167) { + if (container.parent.kind === 168) { 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; @@ -17545,7 +17750,7 @@ var ts; } return unknownType; } - if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 145 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -17557,24 +17762,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 144; + return container.kind === 145; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 167) { + if (ts.isClassLike(container.parent) || container.parent.kind === 168) { if (container.flags & 64) { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || - container.kind === 146; + return container.kind === 144 || + container.kind === 143 || + container.kind === 146 || + container.kind === 147; } else { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || + return container.kind === 144 || + container.kind === 143 || container.kind === 146 || + container.kind === 147 || + container.kind === 142 || container.kind === 141 || - container.kind === 140 || - container.kind === 144; + container.kind === 145; } } } @@ -17609,7 +17814,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138) { + if (declaration.kind === 139) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17642,7 +17847,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 && node.parent.initializer === node) { + if (node.parent.kind === 139 && node.parent.initializer === node) { return true; } node = node.parent; @@ -17651,8 +17856,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 144 || - functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { + functionDecl.kind === 145 || + functionDecl.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -17671,7 +17876,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 172) { + if (template.parent.kind === 173) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17782,13 +17987,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 240) { + if (attribute.kind === 241) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 241) { + else if (attribute.kind === 242) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -17806,40 +18011,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 213: - case 138: + case 214: + case 139: + case 142: case 141: - case 140: - case 165: - return getContextualTypeForInitializerExpression(node); - case 176: - case 206: - return getContextualTypeForReturnExpression(node); - case 186: - return getContextualTypeForYieldOperand(parent); - case 170: - case 171: - return getContextualTypeForArgument(parent, node); - case 173: - case 191: - return getTypeFromTypeNode(parent.type); - case 183: - return getContextualTypeForBinaryOperand(node); - case 247: - return getContextualTypeForObjectLiteralElement(parent); case 166: - return getContextualTypeForElementExpression(node); - case 184: - return getContextualTypeForConditionalOperand(node); - case 192: - ts.Debug.assert(parent.parent.kind === 185); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 177: + case 207: + return getContextualTypeForReturnExpression(node); + case 187: + return getContextualTypeForYieldOperand(parent); + case 171: + case 172: + return getContextualTypeForArgument(parent, node); case 174: + case 192: + return getTypeFromTypeNode(parent.type); + case 184: + return getContextualTypeForBinaryOperand(node); + case 248: + return getContextualTypeForObjectLiteralElement(parent); + case 167: + return getContextualTypeForElementExpression(node); + case 185: + return getContextualTypeForConditionalOperand(node); + case 193: + ts.Debug.assert(parent.parent.kind === 186); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 175: return getContextualType(parent); - case 242: + case 243: return getContextualType(parent); - case 240: case 241: + case 242: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -17854,7 +18059,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 175 || node.kind === 176; + return node.kind === 176 || node.kind === 177; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -17862,7 +18067,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -17902,13 +18107,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 183 && parent.operatorToken.kind === 56 && parent.left === node) { + if (parent.kind === 184 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 247) { + if (parent.kind === 248) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 166) { + if (parent.kind === 167) { return isAssignmentTarget(parent); } return false; @@ -17918,8 +18123,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 165 && !!node.initializer) || - (node.kind === 183 && node.operatorToken.kind === 56); + return (node.kind === 166 && !!node.initializer) || + (node.kind === 184 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -17928,7 +18133,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 187) { + if (inDestructuringPattern && e.kind === 188) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -17940,7 +18145,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 187; + hasSpreadElement = hasSpreadElement || e.kind === 188; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -17951,7 +18156,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 164 || pattern.kind === 166)) { + if (pattern && (pattern.kind === 165 || pattern.kind === 167)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -17959,7 +18164,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 189) { + if (patternElement.kind !== 190) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -17974,7 +18179,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 137 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -18005,31 +18210,31 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 163 || contextualType.pattern.kind === 167); + (contextualType.pattern.kind === 164 || contextualType.pattern.kind === 168); var typeFlags = 0; var patternWithComputedProperties = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 247 || - memberDecl.kind === 248 || + if (memberDecl.kind === 248 || + memberDecl.kind === 249 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 247) { + if (memberDecl.kind === 248) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 143) { + else if (memberDecl.kind === 144) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 248); + ts.Debug.assert(memberDecl.kind === 249); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 247 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 248 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 248 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 249 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -18056,7 +18261,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); + ts.Debug.assert(memberDecl.kind === 146 || memberDecl.kind === 147); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -18114,13 +18319,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 242: + case 243: checkJsxExpression(child); break; - case 235: + case 236: checkJsxElement(child); break; - case 236: + case 237: checkJsxSelfClosingElement(child); break; } @@ -18131,7 +18336,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135) { + if (tagName.kind === 136) { return false; } else { @@ -18225,6 +18430,7 @@ var ts; if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } + return unknownSymbol; } } function lookupClassTag(node) { @@ -18295,17 +18501,21 @@ var ts; var sym = getJsxElementTagSymbol(node); if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); - var callSignature = getSingleCallSignature(getTypeOfSymbol(sym)); - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType) && (paramType.flags & 80896)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } var elemClassType = getJsxGlobalElementClassType(); + if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { + var elemType = getTypeOfSymbol(sym); + var callSignatures = elemType && getSignaturesOfType(elemType, 0); + var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return links.resolvedJsxType = paramType; + } + } if (elemClassType) { checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } @@ -18403,11 +18613,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 240) { + if (node.attributes[i].kind === 241) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 241); + ts.Debug.assert(node.attributes[i].kind === 242); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -18433,7 +18643,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 141; + return s.valueDeclaration ? s.valueDeclaration.kind : 142; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; @@ -18442,10 +18652,10 @@ var ts; var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (left.kind === 95) { - var errorNode = node.kind === 168 ? + var errorNode = node.kind === 169 ? node.name : node.right; - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 143) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 144) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -18514,7 +18724,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 168 + var left = node.kind === 169 ? node.expression : node.left; var type = checkExpression(left); @@ -18526,10 +18736,47 @@ var ts; } return true; } + function getForInVariableSymbol(node) { + var initializer = node.initializer; + if (initializer.kind === 215) { + var variable = initializer.declarations[0]; + if (variable && !ts.isBindingPattern(variable.name)) { + return getSymbolOfNode(variable); + } + } + else if (initializer.kind === 69) { + return getResolvedSymbol(initializer); + } + return undefined; + } + function hasNumericPropertyNames(type) { + return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0); + } + function isForInVariableForNumericPropertyNames(expr) { + var e = skipParenthesizedNodes(expr); + if (e.kind === 69) { + var symbol = getResolvedSymbol(e); + if (symbol.flags & 3) { + var child = expr; + var node = expr.parent; + while (node) { + if (node.kind === 203 && + child === node.statement && + getForInVariableSymbol(node) === symbol && + hasNumericPropertyNames(checkExpression(node.expression))) { + return true; + } + child = node; + node = node.parent; + } + } + } + return false; + } function checkIndexedAccess(node) { if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 171 && node.parent.expression === node) { + var sourceFile = ts.getSourceFileOfNode(node); + if (node.parent.kind === 172 && 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); @@ -18566,7 +18813,7 @@ var ts; } } if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { return numberIndexType; @@ -18577,7 +18824,9 @@ var ts; return stringIndexType; } if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + 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; } @@ -18588,7 +18837,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 169 || indexArgumentExpression.kind === 168) { + if (indexArgumentExpression.kind === 170 || indexArgumentExpression.kind === 169) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -18631,10 +18880,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 172) { + if (node.kind === 173) { checkExpression(node.template); } - else if (node.kind !== 139) { + else if (node.kind !== 140) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18685,7 +18934,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 187) { + if (arg && arg.kind === 188) { return i; } } @@ -18697,11 +18946,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 172) { + if (node.kind === 173) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 185) { + if (tagExpression.template.kind === 186) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -18713,7 +18962,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 139) { + else if (node.kind === 140) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -18721,7 +18970,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 171); + ts.Debug.assert(callExpression.kind === 172); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -18774,7 +19023,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 !== 189) { + if (arg === undefined || arg.kind !== 190) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -18823,7 +19072,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 !== 189) { + if (arg === undefined || arg.kind !== 190) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -18842,16 +19091,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 172) { + if (node.kind === 173) { var template = node.template; args = [undefined]; - if (template.kind === 185) { + if (template.kind === 186) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 139) { + else if (node.kind === 140) { return undefined; } else { @@ -18860,21 +19109,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139) { + if (node.kind === 140) { switch (node.parent.kind) { - case 216: - case 188: + case 217: + case 189: return 1; - case 141: + case 142: return 2; - case 143: - case 145: + case 144: case 146: + case 147: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 138: + case 139: return 3; } } @@ -18883,48 +19132,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 216) { + if (node.kind === 217) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 138) { + if (node.kind === 139) { node = node.parent; - if (node.kind === 144) { + if (node.kind === 145) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { + if (node.kind === 142 || + node.kind === 144 || + node.kind === 146 || + node.kind === 147) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 216) { + if (node.kind === 217) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 138) { + if (node.kind === 139) { node = node.parent; - if (node.kind === 144) { + if (node.kind === 145) { return anyType; } } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { + if (node.kind === 142 || + node.kind === 144 || + node.kind === 146 || + node.kind === 147) { var element = node; switch (element.name.kind) { case 69: case 8: case 9: return getStringLiteralTypeForText(element.name.text); - case 136: + case 137: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; @@ -18941,20 +19190,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 216) { + if (node.kind === 217) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 138) { + if (node.kind === 139) { return numberType; } - if (node.kind === 141) { + if (node.kind === 142) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143 || - node.kind === 145 || - node.kind === 146) { + if (node.kind === 144 || + node.kind === 146 || + node.kind === 147) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -18975,26 +19224,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 139) { + if (node.kind === 140) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 172) { + else if (argIndex === 0 && node.kind === 173) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 139 || - (argIndex === 0 && node.kind === 172)) { + if (node.kind === 140 || + (argIndex === 0 && node.kind === 173)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139) { + if (node.kind === 140) { return node.expression; } - else if (argIndex === 0 && node.kind === 172) { + else if (argIndex === 0 && node.kind === 173) { return node.template; } else { @@ -19002,8 +19251,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 172; - var isDecorator = node.kind === 139; + var isTaggedTemplate = node.kind === 173; + var isDecorator = node.kind === 140; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -19235,16 +19484,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 216: - case 188: + case 217: + case 189: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141: + case 142: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143: - case 145: + case 144: case 146: + case 147: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -19272,16 +19521,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 170) { + if (node.kind === 171) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 171) { + else if (node.kind === 172) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 172) { + else if (node.kind === 173) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 139) { + else if (node.kind === 140) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -19303,12 +19552,12 @@ var ts; if (node.expression.kind === 95) { return voidType; } - if (node.kind === 171) { + if (node.kind === 172) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 144 && - declaration.kind !== 148 && - declaration.kind !== 153) { + declaration.kind !== 145 && + declaration.kind !== 149 && + declaration.kind !== 154) { var funcSymbol = checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16)) { return getInferredClassType(funcSymbol); @@ -19362,7 +19611,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189) { + if (element.kind !== 190) { if (element.name.kind === 69) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -19396,7 +19645,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 194) { + if (func.body.kind !== 195) { 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); @@ -19501,7 +19750,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 194 || !(func.flags & 524288)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 || !(func.flags & 524288)) { return; } var hasExplicitReturn = func.flags & 1048576; @@ -19521,18 +19770,14 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 175) { + if (!hasGrammarError && node.kind === 176) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); @@ -19560,18 +19805,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { + if (produceDiagnostics && node.kind !== 144 && node.kind !== 143) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -19580,7 +19822,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 194) { + if (node.body.kind === 195) { checkSourceElement(node.body); } else { @@ -19615,13 +19857,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 168: { + case 169: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 169: + case 170: return true; - case 174: + case 175: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -19630,11 +19872,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 69: - case 168: { + case 169: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; } - case 169: { + case 170: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -19644,7 +19886,7 @@ var ts; } return false; } - case 174: + case 175: return isConstVariableReference(n.expression); default: return false; @@ -19774,9 +20016,9 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 247 || p.kind === 248) { + if (p.kind === 248 || p.kind === 249) { var name_13 = p.name; - if (name_13.kind === 136) { + if (name_13.kind === 137) { checkComputedPropertyName(name_13); } if (isComputedNonLiteralName(name_13)) { @@ -19789,7 +20031,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - if (p.kind === 248) { + if (p.kind === 249) { checkDestructuringAssignment(p, type); } else { @@ -19811,8 +20053,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189) { - if (e.kind !== 187) { + if (e.kind !== 190) { + if (e.kind !== 188) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19837,7 +20079,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 183 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 184 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19851,7 +20093,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 248) { + if (exprOrAssignment.kind === 249) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -19861,14 +20103,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 183 && target.operatorToken.kind === 56) { + if (target.kind === 184 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 167) { + if (target.kind === 168) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 166) { + if (target.kind === 167) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19885,7 +20127,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 167 || left.kind === 166)) { + if (operator === 56 && (left.kind === 168 || left.kind === 167)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -20109,14 +20351,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -20139,7 +20381,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 135) { + if (node.kind === 136) { type = checkQualifiedName(node); } else { @@ -20147,9 +20389,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 168 && node.parent.expression === node) || - (node.parent.kind === 169 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 169 && node.parent.expression === node) || + (node.parent.kind === 170 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 136) && 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); } @@ -20175,7 +20417,7 @@ var ts; return booleanType; case 8: return checkNumericLiteral(node); - case 185: + case 186: return checkTemplateExpression(node); case 9: return checkStringLiteralExpression(node); @@ -20183,58 +20425,58 @@ var ts; return stringType; case 10: return globalRegExpType; - case 166: - return checkArrayLiteral(node, contextualMapper); case 167: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 168: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 169: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 170: + return checkIndexedAccess(node); case 171: - return checkCallExpression(node); case 172: - return checkTaggedTemplateExpression(node); - case 174: - return checkExpression(node.expression, contextualMapper); - case 188: - return checkClassExpression(node); - case 175: - case 176: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 178: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 173: - case 191: - return checkAssertion(node); - case 177: - return checkDeleteExpression(node); - case 179: - return checkVoidExpression(node); - case 180: - return checkAwaitExpression(node); - case 181: - return checkPrefixUnaryExpression(node); - case 182: - return checkPostfixUnaryExpression(node); - case 183: - return checkBinaryExpression(node, contextualMapper); - case 184: - return checkConditionalExpression(node, contextualMapper); - case 187: - return checkSpreadElementExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 175: + return checkExpression(node.expression, contextualMapper); case 189: + return checkClassExpression(node); + case 176: + case 177: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 179: + return checkTypeOfExpression(node); + case 174: + case 192: + return checkAssertion(node); + case 178: + return checkDeleteExpression(node); + case 180: + return checkVoidExpression(node); + case 181: + return checkAwaitExpression(node); + case 182: + return checkPrefixUnaryExpression(node); + case 183: + return checkPostfixUnaryExpression(node); + case 184: + return checkBinaryExpression(node, contextualMapper); + case 185: + return checkConditionalExpression(node, contextualMapper); + case 188: + return checkSpreadElementExpression(node, contextualMapper); + case 190: return undefinedType; - case 186: + case 187: return checkYieldExpression(node); - case 242: + case 243: return checkJsxExpression(node); - case 235: - return checkJsxElement(node); case 236: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 237: + return checkJsxSelfClosingElement(node); + case 238: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -20255,7 +20497,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 56) { func = ts.getContainingFunction(node); - if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 145 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -20270,9 +20512,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 143 || - node.kind === 215 || - node.kind === 175; + return node.kind === 144 || + node.kind === 216 || + node.kind === 176; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -20286,104 +20528,97 @@ var ts; } return -1; } - function isInLegalParameterTypePredicatePosition(node) { - switch (node.parent.kind) { - case 176: - case 147: - case 215: - case 175: - case 152: - case 143: - case 142: - return node === node.parent.type; + function checkTypePredicate(node) { + var parent = getTypePredicateParent(node); + if (!parent) { + return; + } + var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); + if (!returnType || !(returnType.flags & 134217728)) { + return; + } + var parameterName = node.parameterName; + if (parameterName.kind === 162) { + getTypeFromThisTypeNode(parameterName); + } + else { + var typePredicate = returnType.predicate; + if (typePredicate.parameterIndex >= 0) { + if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type); + } + } + else if (parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { + var name_14 = _a[_i].name; + if ((name_14.kind === 164 || + name_14.kind === 165) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + hasReportedError = true; + break; + } + } + if (!hasReportedError) { + error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } } - return false; } - function isInLegalThisTypePredicatePosition(node) { - if (isInLegalParameterTypePredicatePosition(node)) { - return true; - } + function getTypePredicateParent(node) { switch (node.parent.kind) { - case 141: - case 140: - case 145: - return node === node.parent.type; + case 177: + case 148: + case 216: + case 176: + case 153: + case 144: + case 143: + var parent_6 = node.parent; + if (node === parent_6.type) { + return parent_6; + } + } + } + function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var name_15 = _a[_i].name; + if (name_15.kind === 69 && + name_15.text === predicateVariableName) { + error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); + return true; + } + else if (name_15.kind === 165 || + name_15.kind === 164) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + return true; + } + } } - return false; } function checkSignatureDeclaration(node) { - if (node.kind === 149) { + if (node.kind === 150) { checkGrammarIndexSignature(node); } - else if (node.kind === 152 || node.kind === 215 || node.kind === 153 || - node.kind === 147 || node.kind === 144 || - node.kind === 148) { + else if (node.kind === 153 || node.kind === 216 || node.kind === 154 || + node.kind === 148 || node.kind === 145 || + node.kind === 149) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - if (!returnType || !(returnType.flags & 134217728)) { - return; - } - var typePredicate = returnType.predicate; - var typePredicateNode = node.type; - checkSourceElement(typePredicateNode); - if (ts.isIdentifierTypePredicate(typePredicate)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 163 || - param.name.kind === 164) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 164 || - element.name.kind === 163) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - } - else { - checkSourceElement(node.type); - } - } + checkSourceElement(node.type); if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 148: + case 149: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 147: + case 148: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -20405,7 +20640,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 217) { + if (node.kind === 218) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -20468,7 +20703,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 170 && n.expression.kind === 95; + return n.kind === 171 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -20489,12 +20724,12 @@ var ts; if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 175 && n.kind !== 215) { + else if (n.kind !== 176 && n.kind !== 216) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 141 && + return n.kind === 142 && !(n.flags & 64) && !!n.initializer; } @@ -20514,7 +20749,7 @@ var ts; var superCallStatement; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 197 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 198 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -20540,7 +20775,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 145) { + if (node.kind === 146) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { if (node.flags & 1048576) { if (compilerOptions.noImplicitReturns) { @@ -20552,11 +20787,11 @@ var ts; } } } - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 145 ? 146 : 145; + var otherKind = node.kind === 146 ? 147 : 146; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 56) !== (otherAccessor.flags & 56))) { @@ -20573,7 +20808,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 167) { + if (node.parent.kind !== 168) { checkSourceElement(node.body); } else { @@ -20655,9 +20890,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 217) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); - var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 218) { + ts.Debug.assert(signatureDeclarationNode.kind === 148 || signatureDeclarationNode.kind === 149); + var signatureKind = signatureDeclarationNode.kind === 148 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -20675,9 +20910,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 217 && - n.parent.kind !== 216 && - n.parent.kind !== 188 && + if (n.parent.kind !== 218 && + n.parent.kind !== 217 && + n.parent.kind !== 189 && ts.isInAmbientContext(n)) { if (!(flags & 4)) { flags |= 2; @@ -20754,7 +20989,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 === 143 || node.kind === 142) && + var reportError = (node.kind === 144 || node.kind === 143) && (node.flags & 64) !== (subsequentNode.flags & 64); if (reportError) { var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -20788,11 +21023,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 217 || node.parent.kind === 155 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 218 || node.parent.kind === 156 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 215 || node.kind === 143 || node.kind === 142 || node.kind === 144) { + if (node.kind === 216 || node.kind === 144 || node.kind === 143 || node.kind === 145) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20905,16 +21140,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 217: + case 218: return 2097152; - case 220: - return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 + case 221: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 216: - case 219: + case 217: + case 220: return 2097152 | 1048576; - case 223: + case 224: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -21045,22 +21280,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 216: + case 217: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 141: + case 142: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 143: - case 145: + case 144: case 146: + case 147: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -21069,9 +21304,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 151) { + if (node && node.kind === 152) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 ? 793056 : 1536; + var meaning = root.parent.kind === 152 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -21105,28 +21340,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 216: + case 217: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 143: - case 145: + case 144: case 146: + case 147: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 141: - case 138: + case 142: + case 139: checkTypeAnnotationAsExpression(node); break; } } - emitDecorate = true; - if (node.kind === 138) { - emitParam = true; - } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { @@ -21141,16 +21372,13 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - if (node.name && node.name.kind === 136) { + if (node.name && node.name.kind === 137) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.forEach(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(getSourceFile(declaration)) ? + var firstDeclaration = ts.forEach(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)) ? declaration : undefined; }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -21176,7 +21404,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 194) { + if (node.kind === 195) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -21195,19 +21423,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 141 || - node.kind === 140 || + if (node.kind === 142 || + node.kind === 141 || + node.kind === 144 || node.kind === 143 || - node.kind === 142 || - node.kind === 145 || - node.kind === 146) { + node.kind === 146 || + node.kind === 147) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 139 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -21255,11 +21483,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 220 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 221 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 250 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 251 && 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)); } } @@ -21267,7 +21495,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 213 && !node.initializer) { + if (node.kind === 214 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -21277,25 +21505,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 214); - var container = varDeclList.parent.kind === 195 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215); + var container = varDeclList.parent.kind === 196 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 194 && ts.isFunctionLike(container.parent) || + (container.kind === 195 && ts.isFunctionLike(container.parent) || + container.kind === 222 || container.kind === 221 || - container.kind === 220 || - container.kind === 250); + container.kind === 251); if (!namesShareScope) { - var name_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + var name_16 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 138) { + if (ts.getRootDeclaration(node).kind !== 139) { return; } var func = ts.getContainingFunction(node); @@ -21304,7 +21532,7 @@ var ts; if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138) { + if (referencedSymbol.valueDeclaration.kind === 139) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -21324,26 +21552,26 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 136) { + if (node.name.kind === 137) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 165) { - if (node.propertyName && node.propertyName.kind === 136) { + if (node.kind === 166) { + if (node.propertyName && node.propertyName.kind === 137) { checkComputedPropertyName(node.propertyName); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 139 && 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) { + if (node.initializer && node.parent.parent.kind !== 203) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -21352,7 +21580,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { - if (node.initializer) { + if (node.initializer && node.parent.parent.kind !== 203) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -21366,9 +21594,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 141 && node.kind !== 140) { + if (node.kind !== 142 && node.kind !== 141) { checkExportsOnMergedDeclarations(node); - if (node.kind === 213 || node.kind === 165) { + if (node.kind === 214 || node.kind === 166) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -21389,7 +21617,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 167) { + if (node.modifiers && node.parent.kind === 168) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -21408,7 +21636,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 196) { + if (node.thenStatement.kind === 197) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -21425,12 +21653,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 214) { + if (node.initializer && node.initializer.kind === 215) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -21445,13 +21673,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 166 || varExpr.kind === 167) { + if (varExpr.kind === 167 || varExpr.kind === 168) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -21466,7 +21694,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { 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); @@ -21476,7 +21704,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 166 || varExpr.kind === 167) { + if (varExpr.kind === 167 || varExpr.kind === 168) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -21644,7 +21872,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); + return !!(node.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -21662,10 +21890,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 146) { + if (func.kind === 147) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 144) { + else if (func.kind === 145) { if (!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); } @@ -21701,7 +21929,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 244 && !hasDuplicateDefaultClause) { + if (clause.kind === 245 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21713,7 +21941,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 243) { + if (produceDiagnostics && clause.kind === 244) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var expressionTypeIsAssignableToCaseType = (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, 258)) || @@ -21732,7 +21960,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 209 && current.label.text === node.label.text) { + if (current.kind === 210 && 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; @@ -21826,7 +22054,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 137 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21901,7 +22129,6 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; @@ -21975,7 +22202,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { - if (derivedClassDecl.kind === 188) { + if (derivedClassDecl.kind === 189) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -22019,7 +22246,7 @@ var ts; } } function isAccessor(kind) { - return kind === 145 || kind === 146; + return kind === 146 || kind === 147; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -22085,7 +22312,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 217); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -22183,7 +22410,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 181: + case 182: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -22194,7 +22421,7 @@ var ts; case 50: return ~value_1; } return undefined; - case 183: + case 184: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -22219,11 +22446,11 @@ var ts; return undefined; case 8: return +e.text; - case 174: + case 175: return evalConstant(e.expression); case 69: + case 170: case 169: - case 168: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -22234,7 +22461,7 @@ var ts; } else { var expression; - if (e.kind === 169) { + if (e.kind === 170) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -22251,7 +22478,7 @@ var ts; if (current.kind === 69) { break; } - else if (current.kind === 168) { + else if (current.kind === 169) { current = current.expression; } else { @@ -22310,7 +22537,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 219) { + if (declaration.kind !== 220) { return false; } var enumDeclaration = declaration; @@ -22333,8 +22560,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 === 216 || - (declaration.kind === 215 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 217 || + (declaration.kind === 216 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -22356,7 +22583,12 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 9; + var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); + var inAmbientContext = ts.isInAmbientContext(node); + if (isGlobalAugmentation && !inAmbientContext) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); + } + var isAmbientExternalModule = ts.isAmbientModule(node); var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -22364,7 +22596,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9) { + if (!inAmbientContext && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -22374,7 +22606,7 @@ var ts; var symbol = getSymbolOfNode(node); if (symbol.flags & 512 && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) + && !inAmbientContext && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { @@ -22385,29 +22617,102 @@ 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, 216); + var mergedClass = ts.getDeclarationOfKind(symbol, 217); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; } } if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + if (ts.isExternalModuleAugmentation(node)) { + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + if (checkBody) { + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + checkModuleAugmentationElement(statement, isGlobalAugmentation); + } + } } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + else if (isGlobalSourceFile(node.parent)) { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + else { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else { + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } } } } checkSourceElement(node.body); } + function checkModuleAugmentationElement(node, isGlobalAugmentation) { + switch (node.kind) { + case 196: + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + checkModuleAugmentationElement(decl, isGlobalAugmentation); + } + break; + case 230: + case 231: + grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); + break; + case 224: + if (node.moduleReference.kind !== 9) { + error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + break; + } + case 225: + grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); + break; + case 166: + case 214: + var name_17 = node.name; + if (ts.isBindingPattern(name_17)) { + for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + var el = _c[_b]; + checkModuleAugmentationElement(el, isGlobalAugmentation); + } + break; + } + case 217: + case 220: + case 216: + case 218: + case 221: + case 219: + var symbol = getSymbolOfNode(node); + if (symbol) { + var reportError = !(symbol.flags & 33554432); + if (!reportError) { + if (isGlobalAugmentation) { + reportError = symbol.parent !== undefined; + } + else { + reportError = ts.isExternalModuleAugmentation(symbol.parent.valueDeclaration); + } + } + if (reportError) { + error(node, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + } + } + break; + } + } function getFirstIdentifier(node) { while (true) { - if (node.kind === 135) { + if (node.kind === 136) { node = node.left; } - else if (node.kind === 168) { + else if (node.kind === 169) { node = node.expression; } else { @@ -22423,16 +22728,18 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 221 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 250 && !inAmbientExternalModule) { - error(moduleName, node.kind === 230 ? + var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 && !inAmbientExternalModule) { + error(moduleName, node.kind === 231 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; + if (!isTopLevelInExternalModuleAugmentation(node)) { + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } } return true; } @@ -22444,7 +22751,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 232 ? + var message = node.kind === 233 ? 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)); @@ -22470,7 +22777,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226) { + if (importClause.namedBindings.kind === 227) { checkImportBinding(importClause.namedBindings); } else { @@ -22521,8 +22828,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 221 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 250 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -22535,22 +22842,29 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 250 && node.parent.kind !== 221 && node.parent.kind !== 220) { + if (node.parent.kind !== 251 && node.parent.kind !== 222 && node.parent.kind !== 221) { return grammarErrorOnFirstToken(node, errorMessage); } } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); + var exportedName = node.propertyName || node.name; + var symbol = resolveName(exportedName, exportedName.text, 107455 | 793056 | 1536 | 8388608, undefined, undefined); + if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); + } + else { + markExportAsReferenced(node); + } } } function checkExportAssignment(node) { if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 250 ? node.parent : node.parent.parent; - if (container.kind === 220 && container.name.kind === 69) { + var container = node.parent.kind === 251 ? node.parent : node.parent.parent; + if (container.kind === 221 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -22588,7 +22902,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports["export="]; if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + if (!isTopLevelInExternalModuleAugmentation(declaration)) { + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } } var exports_2 = getExportsOfModule(moduleSymbol); for (var id in exports_2) { @@ -22609,21 +22925,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 215 || !!declaration.body; - } - } - function checkTypePredicate(node) { - var parameterName = node.parameterName; - if (parameterName.kind === 69 && !isInLegalParameterTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - else if (parameterName.kind === 161) { - if (!isInLegalThisTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods); - } - else { - getTypeFromThisTypeNode(parameterName); - } + return declaration.kind !== 216 || !!declaration.body; } } function checkSourceElement(node) { @@ -22633,118 +22935,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 220: - case 216: + case 221: case 217: - case 215: + case 218: + case 216: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 137: - return checkTypeParameter(node); case 138: + return checkTypeParameter(node); + case 139: return checkParameter(node); + case 142: case 141: - case 140: return checkPropertyDeclaration(node); - case 152: case 153: - case 147: + case 154: case 148: - return checkSignatureDeclaration(node); case 149: return checkSignatureDeclaration(node); - case 143: - case 142: - return checkMethodDeclaration(node); - case 144: - return checkConstructorDeclaration(node); - case 145: - case 146: - return checkAccessorDeclaration(node); - case 151: - return checkTypeReferenceNode(node); case 150: + return checkSignatureDeclaration(node); + case 144: + case 143: + return checkMethodDeclaration(node); + case 145: + return checkConstructorDeclaration(node); + case 146: + case 147: + return checkAccessorDeclaration(node); + case 152: + return checkTypeReferenceNode(node); + case 151: return checkTypePredicate(node); - case 154: - return checkTypeQuery(node); case 155: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 156: - return checkArrayType(node); + return checkTypeLiteral(node); case 157: - return checkTupleType(node); + return checkArrayType(node); case 158: + return checkTupleType(node); case 159: - return checkUnionOrIntersectionType(node); case 160: + return checkUnionOrIntersectionType(node); + case 161: return checkSourceElement(node.type); - case 215: - return checkFunctionDeclaration(node); - case 194: - case 221: - return checkBlock(node); - case 195: - return checkVariableStatement(node); - case 197: - return checkExpressionStatement(node); - case 198: - return checkIfStatement(node); - case 199: - return checkDoStatement(node); - case 200: - return checkWhileStatement(node); - case 201: - return checkForStatement(node); - case 202: - return checkForInStatement(node); - case 203: - return checkForOfStatement(node); - case 204: - case 205: - return checkBreakOrContinueStatement(node); - case 206: - return checkReturnStatement(node); - case 207: - return checkWithStatement(node); - case 208: - return checkSwitchStatement(node); - case 209: - return checkLabeledStatement(node); - case 210: - return checkThrowStatement(node); - case 211: - return checkTryStatement(node); - case 213: - return checkVariableDeclaration(node); - case 165: - return checkBindingElement(node); case 216: - return checkClassDeclaration(node); - case 217: - return checkInterfaceDeclaration(node); - case 218: - return checkTypeAliasDeclaration(node); - case 219: - return checkEnumDeclaration(node); - case 220: - return checkModuleDeclaration(node); - case 224: - return checkImportDeclaration(node); - case 223: - return checkImportEqualsDeclaration(node); - case 230: - return checkExportDeclaration(node); - case 229: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 195: + case 222: + return checkBlock(node); case 196: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 198: + return checkExpressionStatement(node); + case 199: + return checkIfStatement(node); + case 200: + return checkDoStatement(node); + case 201: + return checkWhileStatement(node); + case 202: + return checkForStatement(node); + case 203: + return checkForInStatement(node); + case 204: + return checkForOfStatement(node); + case 205: + case 206: + return checkBreakOrContinueStatement(node); + case 207: + return checkReturnStatement(node); + case 208: + return checkWithStatement(node); + case 209: + return checkSwitchStatement(node); + case 210: + return checkLabeledStatement(node); + case 211: + return checkThrowStatement(node); case 212: + return checkTryStatement(node); + case 214: + return checkVariableDeclaration(node); + case 166: + return checkBindingElement(node); + case 217: + return checkClassDeclaration(node); + case 218: + return checkInterfaceDeclaration(node); + case 219: + return checkTypeAliasDeclaration(node); + case 220: + return checkEnumDeclaration(node); + case 221: + return checkModuleDeclaration(node); + case 225: + return checkImportDeclaration(node); + case 224: + return checkImportEqualsDeclaration(node); + case 231: + return checkExportDeclaration(node); + case 230: + return checkExportAssignment(node); + case 197: checkGrammarStatementInAmbientContext(node); return; - case 233: + case 213: + checkGrammarStatementInAmbientContext(node); + return; + case 234: return checkMissingDeclaration(node); } } @@ -22757,17 +23059,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 175: case 176: + case 177: + case 144: case 143: - case 142: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 145: case 146: + case 147: checkAccessorDeferred(node); break; - case 188: + case 189: checkClassExpressionDeferred(node); break; } @@ -22787,10 +23089,6 @@ var ts; } } checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - emitAwaiter = false; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); @@ -22803,21 +23101,6 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) { - links.flags |= 8; - } - if (emitDecorate) { - links.flags |= 16; - } - if (emitParam) { - links.flags |= 32; - } - if (emitAwaiter) { - links.flags |= 64; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2)) { - links.flags |= 128; - } links.flags |= 1; } } @@ -22851,7 +23134,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 207 && node.parent.statement === node) { + if (node.parent.kind === 208 && node.parent.statement === node) { return true; } node = node.parent; @@ -22873,28 +23156,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 250: + case 251: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 220: + case 221: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 219: + case 220: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 188: + case 189: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 216: case 217: + case 218: if (!(memberFlags & 64)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 175: + case 176: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -22933,36 +23216,36 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 137: - case 216: + case 138: case 217: case 218: case 219: + case 220: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 135) { + while (node.parent && node.parent.kind === 136) { node = node.parent; } - return node.parent && node.parent.kind === 151; + return node.parent && node.parent.kind === 152; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 168) { + while (node.parent && node.parent.kind === 169) { node = node.parent; } - return node.parent && node.parent.kind === 190; + return node.parent && node.parent.kind === 191; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135) { + while (nodeOnRightSide.parent.kind === 136) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 223) { + if (nodeOnRightSide.parent.kind === 224) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22974,10 +23257,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 229) { + if (entityName.parent.kind === 230) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 168) { + if (entityName.kind !== 169) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -22987,7 +23270,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 190) { + if (entityName.parent.kind === 191) { meaning = 793056; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -22999,9 +23282,9 @@ var ts; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 237) || - (entityName.parent.kind === 236) || - (entityName.parent.kind === 239)) { + else if ((entityName.parent.kind === 238) || + (entityName.parent.kind === 237) || + (entityName.parent.kind === 240)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -23012,14 +23295,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 168) { + else if (entityName.kind === 169) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 135) { + else if (entityName.kind === 136) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -23028,14 +23311,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 ? 793056 : 1536; + var meaning = entityName.parent.kind === 152 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 240) { + else if (entityName.parent.kind === 241) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 150) { + if (entityName.parent.kind === 151) { return resolveEntityName(entityName, 1); } return undefined; @@ -23049,12 +23332,12 @@ var ts; } if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 229 + return node.parent.kind === 230 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 165 && - node.parent.parent.kind === 163 && + else if (node.parent.kind === 166 && + node.parent.parent.kind === 164 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -23065,30 +23348,30 @@ var ts; } switch (node.kind) { case 69: - case 168: - case 135: + case 169: + case 136: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 161: + case 162: return getTypeFromTypeNode(node).symbol; case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144) { + if (constructorDeclaration && constructorDeclaration.kind === 145) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 224 || node.parent.kind === 230) && + ((node.parent.kind === 225 || node.parent.kind === 231) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 169 && node.parent.argumentExpression === node) { + if (node.parent.kind === 170 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -23102,11 +23385,16 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 248) { - return resolveEntityName(location.name, 107455); + if (location && location.kind === 249) { + return resolveEntityName(location.name, 107455 | 8388608); } return undefined; } + function getExportSpecifierLocalTargetSymbol(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536 | 8388608); + } function getTypeOfNode(node) { if (isInsideWithStatementBody(node)) { return unknownType; @@ -23173,9 +23461,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var name_15 = symbol.name; + var name_18 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); + var symbol = getPropertyOfType(t, name_18); if (symbol) { symbols.push(symbol); } @@ -23224,11 +23512,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 250) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 251) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 220 || n.kind === 219) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 221 || n.kind === 220) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -23241,11 +23529,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 194: - case 222: - case 201: + case 195: + case 223: case 202: case 203: + case 204: return true; } return false; @@ -23271,22 +23559,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 223: - case 225: + case 224: case 226: - case 228: - case 232: + case 227: + case 229: + case 233: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 230: + case 231: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 229: + case 230: return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 250 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 251 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -23334,7 +23622,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 249) { + if (node.kind === 250) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -23450,21 +23738,34 @@ var ts; } function getExternalModuleFileFromDeclaration(declaration) { var specifier = ts.getExternalModuleName(declaration); - var moduleSymbol = getSymbolAtLocation(specifier); + var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 250); + return ts.getDeclarationOfKind(moduleSymbol, 251); } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { ts.bindSourceFile(file, compilerOptions); }); + var augmentations; ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } + if (file.moduleAugmentations) { + (augmentations || (augmentations = [])).push(file.moduleAugmentations); + } }); + if (augmentations) { + for (var _i = 0, augmentations_1 = augmentations; _i < augmentations_1.length; _i++) { + var list = augmentations_1[_i]; + for (var _a = 0, list_2 = list; _a < list_2.length; _a++) { + var augmentation = list_2[_a]; + mergeModuleAugmentation(augmentation); + } + } + } addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); @@ -23529,14 +23830,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 143 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 144 && !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 === 145 || node.kind === 146) { + else if (node.kind === 146 || node.kind === 147) { 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); @@ -23546,38 +23847,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 145: case 146: - case 144: - case 141: - case 140: - case 143: + case 147: + case 145: case 142: - case 149: - case 220: + case 141: + case 144: + case 143: + case 150: + case 221: + case 225: case 224: - case 223: + case 231: case 230: - case 229: - case 138: - break; - case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && - node.parent.kind !== 221 && node.parent.kind !== 250) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 139: break; case 216: - case 217: - case 195: - case 218: - if (node.modifiers && node.parent.kind !== 221 && node.parent.kind !== 250) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 222 && node.parent.kind !== 251) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 217: + case 218: + case 196: case 219: + if (node.modifiers && node.parent.kind !== 222 && node.parent.kind !== 251) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 220: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && - node.parent.kind !== 221 && node.parent.kind !== 250) { + node.parent.kind !== 222 && node.parent.kind !== 251) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23593,7 +23894,7 @@ var ts; var modifier = _a[_i]; switch (modifier.kind) { case 74: - if (node.kind !== 219 && node.parent.kind === 216) { + if (node.kind !== 220 && node.parent.kind === 217) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); } break; @@ -23621,7 +23922,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 === 221 || node.parent.kind === 250) { + else if (node.parent.kind === 222 || node.parent.kind === 251) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 128) { @@ -23641,10 +23942,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 === 221 || node.parent.kind === 250) { + else if (node.parent.kind === 222 || node.parent.kind === 251) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -23666,10 +23967,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 === 216) { + else if (node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 2; @@ -23681,13 +23982,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 === 216) { + else if (node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 221) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 4; @@ -23697,11 +23998,11 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 216) { - if (node.kind !== 143) { + if (node.kind !== 217) { + if (node.kind !== 144) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 216 && node.parent.flags & 128)) { + if (!(node.parent.kind === 217 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 64) { @@ -23720,7 +24021,7 @@ var ts; else if (flags & 4 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 138) { + else if (node.kind === 139) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -23728,7 +24029,7 @@ var ts; break; } } - if (node.kind === 144) { + if (node.kind === 145) { if (flags & 64) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -23746,10 +24047,10 @@ var ts; } return; } - else if ((node.kind === 224 || node.kind === 223) && flags & 4) { + else if ((node.kind === 225 || node.kind === 224) && flags & 4) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 && (flags & 56) && ts.isBindingPattern(node.name)) { + else if (node.kind === 139 && (flags & 56) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256) { @@ -23761,10 +24062,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 143: - case 215: - case 175: + case 144: + case 216: case 176: + case 177: if (!node.asteriskToken) { return false; } @@ -23829,7 +24130,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 176) { + if (node.kind === 177) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23896,7 +24197,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 189) { + if (arg.kind === 190) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23967,19 +24268,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 136) { + if (node.kind !== 137) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 183 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 184 && computedPropertyName.expression.operatorToken.kind === 24) { 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 === 215 || - node.kind === 175 || - node.kind === 143); + ts.Debug.assert(node.kind === 216 || + node.kind === 176 || + node.kind === 144); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -24003,58 +24304,58 @@ var ts; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; var _loop_1 = function(prop) { - var name_16 = prop.name; - if (prop.kind === 189 || - name_16.kind === 136) { - checkGrammarComputedPropertyName(name_16); + var name_19 = prop.name; + if (prop.kind === 190 || + name_19.kind === 137) { + checkGrammarComputedPropertyName(name_19); return "continue"; } - if (prop.kind === 248 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 249 && !inDestructuring && prop.objectAssignmentInitializer) { return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 || prop.kind !== 143) { + if (mod.kind !== 118 || prop.kind !== 144) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); var currentKind = void 0; - if (prop.kind === 247 || prop.kind === 248) { + if (prop.kind === 248 || prop.kind === 249) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8) { - checkGrammarNumericLiteral(name_16); + if (name_19.kind === 8) { + checkGrammarNumericLiteral(name_19); } currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = Property; } - else if (prop.kind === 145) { + else if (prop.kind === 146) { currentKind = GetAccessor; } - else if (prop.kind === 146) { + else if (prop.kind === 147) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = currentKind; } else { - var existingKind = seen[name_16.text]; + var existingKind = seen[name_19.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; + seen[name_19.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; @@ -24069,19 +24370,19 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 241) { + if (attr.kind === 242) { continue; } var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; + var name_20 = jsxAttr.name; + if (!ts.hasProperty(seen, name_20.text)) { + seen[name_20.text] = true; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 242 && !initializer.expression) { + if (initializer && initializer.kind === 243 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -24090,7 +24391,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 214) { + if (forInOrOfStatement.initializer.kind === 215) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -24098,20 +24399,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 202 + var diagnostic = forInOrOfStatement.kind === 203 ? 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 === 202 + var diagnostic = forInOrOfStatement.kind === 203 ? 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 === 202 + var diagnostic = forInOrOfStatement.kind === 203 ? 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); @@ -24134,10 +24435,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 145 && accessor.parameters.length) { + else if (kind === 146 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 146) { + else if (kind === 147) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -24172,12 +24473,12 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 167) { + if (node.parent.kind === 168) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -24191,10 +24492,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 === 217) { + else if (node.parent.kind === 218) { 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 === 155) { + else if (node.parent.kind === 156) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -24205,9 +24506,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 209: + case 210: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 204 + var isMisplacedContinueLabel = node.kind === 205 && !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); @@ -24215,8 +24516,8 @@ var ts; return false; } break; - case 208: - if (node.kind === 205 && !node.label) { + case 209: + if (node.kind === 206 && !node.label) { return false; } break; @@ -24229,13 +24530,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 205 + var message = node.kind === 206 ? 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 === 205 + var message = node.kind === 206 ? 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); @@ -24247,7 +24548,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 164 || node.name.kind === 163) { + if (node.name.kind === 165 || node.name.kind === 164) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -24256,7 +24557,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 202 && node.parent.parent.kind !== 203) { + if (node.parent.parent.kind !== 203 && node.parent.parent.kind !== 204) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -24285,7 +24586,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 189) { + if (element.kind !== 190) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -24302,15 +24603,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 198: case 199: case 200: - case 207: case 201: + case 208: case 202: case 203: + case 204: return false; - case 209: + case 210: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -24366,7 +24667,7 @@ var ts; return true; } } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24374,7 +24675,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 155) { + else if (node.parent.kind === 156) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24387,12 +24688,12 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 217 || - node.kind === 218 || + if (node.kind === 218 || + node.kind === 219 || + node.kind === 225 || node.kind === 224 || - node.kind === 223 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || (node.flags & 4) || (node.flags & (2 | 512))) { return false; @@ -24402,7 +24703,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 === 195) { + if (ts.isDeclaration(decl) || decl.kind === 196) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24421,7 +24722,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 === 194 || node.parent.kind === 221 || node.parent.kind === 250) { + if (node.parent.kind === 195 || node.parent.kind === 222 || node.parent.kind === 251) { 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); @@ -24457,8 +24758,9 @@ var ts; getSourceMapData: function () { return undefined; }, setSourceFile: function (sourceFile) { }, emitStart: function (range) { }, - emitEnd: function (range) { }, + emitEnd: function (range, stopOverridingSpan) { }, emitPos: function (pos) { }, + changeEmitSourcePos: function () { }, getText: function () { return undefined; }, getSourceMappingURL: function () { return undefined; }, initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, @@ -24472,6 +24774,8 @@ var ts; var compilerOptions = host.getCompilerOptions(); var currentSourceFile; var sourceMapDir; + var stopOverridingSpan = false; + var modifyLastSourcePos = false; var sourceMapSourceIndex; var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan; @@ -24483,6 +24787,7 @@ var ts; emitPos: emitPos, emitStart: emitStart, emitEnd: emitEnd, + changeEmitSourcePos: changeEmitSourcePos, getText: getText, getSourceMappingURL: getSourceMappingURL, initialize: initialize, @@ -24546,6 +24851,29 @@ var ts; lastEncodedNameIndex = undefined; sourceMapData = undefined; } + function updateLastEncodedAndRecordedSpans() { + if (modifyLastSourcePos) { + modifyLastSourcePos = false; + lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; + lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; + sourceMapData.sourceMapDecodedMappings.pop(); + lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? + sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : + undefined; + var sourceMapMappings = sourceMapData.sourceMapMappings; + var lenthToSet = sourceMapMappings.length - 1; + for (; lenthToSet >= 0; lenthToSet--) { + var currentChar = sourceMapMappings.charAt(lenthToSet); + if (currentChar === ",") { + break; + } + if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { + break; + } + } + sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); + } + } function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { return; @@ -24567,6 +24895,7 @@ var ts; sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); if (lastRecordedSourceMapSpan.nameIndex >= 0) { + ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } @@ -24596,19 +24925,29 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; + stopOverridingSpan = false; } - else { + else if (!stopOverridingSpan) { lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } + updateLastEncodedAndRecordedSpans(); + } + function getStartPos(range) { + var rangeHasDecorators = !!range.decorators; + return range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1; } function emitStart(range) { - var rangeHasDecorators = !!range.decorators; - emitPos(range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1); + emitPos(getStartPos(range)); } - function emitEnd(range) { + function emitEnd(range, stopOverridingEnd) { emitPos(range.end); + stopOverridingSpan = stopOverridingEnd; + } + function changeEmitSourcePos() { + ts.Debug.assert(!modifyLastSourcePos); + modifyLastSourcePos = true; } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -24695,6 +25034,7 @@ var ts; var writeTextOfNode; var writer = createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; + var resultHasExternalModuleIndicator; var currentText; var currentLineMap; var currentIdentifiers; @@ -24725,6 +25065,7 @@ var ts; } }); } + resultHasExternalModuleIndicator = false; if (!isBundledEmit || !ts.isExternalModule(sourceFile)) { noDeclare = false; emitSourceFile(sourceFile); @@ -24743,7 +25084,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 224); + ts.Debug.assert(aliasEmitInfo.node.kind === 225); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -24760,6 +25101,10 @@ var ts; allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo); moduleElementDeclarationEmitInfo = []; } + if (!isBundledEmit && ts.isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) { + write("export {};"); + writeLine(); + } }); return { reportedDeclarationError: reportedDeclarationError, @@ -24806,10 +25151,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 213) { + if (declaration.kind === 214) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 227 || declaration.kind === 228 || declaration.kind === 225) { + else if (declaration.kind === 228 || declaration.kind === 229 || declaration.kind === 226) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24820,7 +25165,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 224) { + if (moduleElementEmitInfo.node.kind === 225) { moduleElementEmitInfo.isVisible = true; } else { @@ -24828,12 +25173,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 220) { + if (nodeToCheck.kind === 221) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 220) { + if (nodeToCheck.kind === 221) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24936,35 +25281,35 @@ var ts; case 120: case 131: case 103: - case 161: case 162: + case 163: return writeTextOfNode(currentText, type); - case 190: + case 191: return emitExpressionWithTypeArguments(type); - case 151: - return emitTypeReference(type); - case 154: - return emitTypeQuery(type); - case 156: - return emitArrayType(type); - case 157: - return emitTupleType(type); - case 158: - return emitUnionType(type); - case 159: - return emitIntersectionType(type); - case 160: - return emitParenType(type); case 152: - case 153: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 155: + return emitTypeQuery(type); + case 157: + return emitArrayType(type); + case 158: + return emitTupleType(type); + case 159: + return emitUnionType(type); + case 160: + return emitIntersectionType(type); + case 161: + return emitParenType(type); + case 153: + case 154: + return emitSignatureDeclarationWithJsDocComments(type); + case 156: return emitTypeLiteral(type); case 69: return emitEntityName(type); - case 135: + case 136: return emitEntityName(type); - case 150: + case 151: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -24972,21 +25317,21 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 135 ? entityName.left : entityName.expression; - var right = entityName.kind === 135 ? entityName.right : entityName.name; + var left = entityName.kind === 136 ? entityName.left : entityName.expression; + var right = entityName.kind === 136 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 223 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 224 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 168); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 169); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -25060,9 +25405,9 @@ var ts; var count = 0; while (true) { count++; - var name_18 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_18)) { - return name_18; + var name_21 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_21)) { + return name_21; } } } @@ -25103,10 +25448,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 223 || - (node.parent.kind === 250 && isCurrentFileExternalModule)) { + else if (node.kind === 224 || + (node.parent.kind === 251 && isCurrentFileExternalModule)) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 250) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -25115,7 +25460,7 @@ var ts; }); } else { - if (node.kind === 224) { + if (node.kind === 225) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -25133,37 +25478,37 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 215: - return writeFunctionDeclaration(node); - case 195: - return writeVariableStatement(node); - case 217: - return writeInterfaceDeclaration(node); case 216: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 196: + return writeVariableStatement(node); case 218: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 217: + return writeClassDeclaration(node); case 219: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 220: + return writeEnumDeclaration(node); + case 221: return writeModuleDeclaration(node); - case 223: - return writeImportEqualsDeclaration(node); case 224: + return writeImportEqualsDeclaration(node); + case 225: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 250) { + if (node.parent.kind === 251) { if (node.flags & 2) { write("export "); } if (node.flags & 512) { write("default "); } - else if (node.kind !== 217 && !noDeclare) { + else if (node.kind !== 218 && !noDeclare) { write("declare "); } } @@ -25210,7 +25555,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 226) { + if (namedBindings.kind === 227) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -25236,7 +25581,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 226) { + if (node.importClause.namedBindings.kind === 227) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -25253,11 +25598,15 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 221; var moduleSpecifier; - if (parent.kind === 223) { + if (parent.kind === 224) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } + else if (parent.kind === 221) { + moduleSpecifier = parent.name; + } else { var node = parent; moduleSpecifier = node.moduleSpecifier; @@ -25306,14 +25655,24 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 65536) { - write("namespace "); + if (ts.isGlobalScopeAugmentation(node)) { + write("global "); } else { - write("module "); + if (node.flags & 65536) { + write("namespace "); + } + else { + write("module "); + } + if (ts.isExternalModuleAugmentation(node)) { + emitExternalModuleSpecifier(node); + } + else { + writeTextOfNode(currentText, node.name); + } } - writeTextOfNode(currentText, node.name); - while (node.body.kind !== 221) { + while (node.body.kind !== 222) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -25378,7 +25737,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 16); + return node.parent.kind === 144 && (node.parent.flags & 16); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -25388,15 +25747,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - (node.parent.parent && node.parent.parent.kind === 155)) { - ts.Debug.assert(node.parent.kind === 143 || - node.parent.kind === 142 || - node.parent.kind === 152 || + if (node.parent.kind === 153 || + node.parent.kind === 154 || + (node.parent.parent && node.parent.parent.kind === 156)) { + ts.Debug.assert(node.parent.kind === 144 || + node.parent.kind === 143 || node.parent.kind === 153 || - node.parent.kind === 147 || - node.parent.kind === 148); + node.parent.kind === 154 || + node.parent.kind === 148 || + node.parent.kind === 149); emitType(node.constraint); } else { @@ -25406,31 +25765,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 216: + case 217: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 217: + case 218: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 148: + case 149: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 144: case 143: - case 142: if (node.parent.flags & 64) { 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 === 216) { + else if (node.parent.parent.kind === 217) { 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 215: + case 216: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -25463,7 +25822,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 216) { + if (node.parent.parent.kind === 217) { 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; @@ -25543,16 +25902,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 213 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 214 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { + if ((node.kind === 142 || node.kind === 141) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { + if ((node.kind === 142 || node.kind === 141) && node.parent.kind === 156) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 16)) { @@ -25561,14 +25920,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 213) { + if (node.kind === 214) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 === 141 || node.kind === 140) { + else if (node.kind === 142 || node.kind === 141) { if (node.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -25576,7 +25935,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 === 216) { + else if (node.parent.kind === 217) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25602,7 +25961,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189) { + if (element.kind !== 190) { elements.push(element); } } @@ -25668,7 +26027,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 146 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25681,7 +26040,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 145 + return accessor.kind === 146 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -25690,7 +26049,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146) { + if (accessorWithTypeAnnotation.kind === 147) { if (accessorWithTypeAnnotation.parent.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -25736,17 +26095,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 215) { + if (node.kind === 216) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 143) { + else if (node.kind === 144) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 215) { + if (node.kind === 216) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 144) { + else if (node.kind === 145) { write("constructor"); } else { @@ -25765,31 +26124,31 @@ var ts; function emitSignatureDeclaration(node) { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - if (node.kind === 148 || node.kind === 153) { + if (node.kind === 149 || node.kind === 154) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 149) { + if (node.kind === 150) { write("["); } else { write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149) { + if (node.kind === 150) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { + var isFunctionTypeOrConstructorType = node.kind === 153 || node.kind === 154; + if (isFunctionTypeOrConstructorType || node.parent.kind === 156) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 144 && !(node.flags & 16)) { + else if (node.kind !== 145 && !(node.flags & 16)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25800,23 +26159,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 148: + case 149: diagnosticMessage = symbolAccesibilityResult.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 147: + case 148: diagnosticMessage = symbolAccesibilityResult.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 149: + case 150: diagnosticMessage = symbolAccesibilityResult.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 144: case 143: - case 142: if (node.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -25824,7 +26183,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 === 216) { + else if (node.parent.kind === 217) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -25837,7 +26196,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 215: + case 216: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25869,9 +26228,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - node.parent.parent.kind === 155) { + if (node.parent.kind === 153 || + node.parent.kind === 154 || + node.parent.parent.kind === 156) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 16)) { @@ -25887,22 +26246,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 144: + case 145: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 148: + case 149: return symbolAccesibilityResult.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 147: + case 148: return symbolAccesibilityResult.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 144: case 143: - case 142: if (node.parent.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -25910,7 +26269,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 === 216) { + else if (node.parent.parent.kind === 217) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -25922,7 +26281,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 215: + case 216: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25933,12 +26292,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 163) { + if (bindingPattern.kind === 164) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 164) { + else if (bindingPattern.kind === 165) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25949,10 +26308,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 189) { + if (bindingElement.kind === 190) { write(" "); } - else if (bindingElement.kind === 165) { + else if (bindingElement.kind === 166) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -25974,39 +26333,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 215: - case 220: - case 223: - case 217: case 216: - case 218: - case 219: - return emitModuleElement(node, isModuleElementVisible(node)); - case 195: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 221: case 224: + case 218: + case 217: + case 219: + case 220: + return emitModuleElement(node, isModuleElementVisible(node)); + case 196: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 225: return emitModuleElement(node, !node.importClause); - case 230: + case 231: return emitExportDeclaration(node); + case 145: case 144: case 143: - case 142: return writeFunctionDeclaration(node); - case 148: - case 147: case 149: + case 148: + case 150: return emitSignatureDeclarationWithJsDocComments(node); - case 145: case 146: + case 147: return emitAccessorDeclaration(node); + case 142: case 141: - case 140: return emitPropertyDeclaration(node); - case 249: - return emitEnumMemberDeclaration(node); - case 229: - return emitExportAssignment(node); case 250: + return emitEnumMemberDeclaration(node); + case 230: + return emitExportAssignment(node); + case 251: return emitSourceFile(node); } } @@ -26333,7 +26692,7 @@ var ts; 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};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -26421,6 +26780,7 @@ var ts; var sourceMapData; var isOwnFileEmit; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, _a[5] = emitES6Module, _a[2] = emitAMDModule, @@ -26499,19 +26859,19 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_19)) { + var name_22 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_22)) { tempFlags |= flags; - return name_19; + return name_22; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; + var name_23 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_23)) { + return name_23; } } } @@ -26549,17 +26909,17 @@ var ts; switch (node.kind) { case 69: return makeUniqueName(node.text); + case 221: case 220: - case 219: return generateNameForModuleOrEnum(node); - case 224: - case 230: + case 225: + case 231: return generateNameForImportOrExportDeclaration(node); - case 215: case 216: - case 229: + case 217: + case 230: return generateNameForExportDefault(); - case 188: + case 189: return generateNameForClassExpression(); } } @@ -26799,10 +27159,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 185) { + if (node.template.kind === 186) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 183 + var needsParens = templateSpan.expression.kind === 184 && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26826,7 +27186,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 174 + var needsParens = templateSpan.expression.kind !== 175 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -26846,11 +27206,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 170: case 171: - return parent.expression === template; case 172: - case 174: + return parent.expression === template; + case 173: + case 175: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -26858,7 +27218,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 183: + case 184: switch (expression.operatorToken.kind) { case 37: case 39: @@ -26870,8 +27230,8 @@ var ts; default: return -1; } - case 186: - case 184: + case 187: + case 185: return -1; default: return 1; @@ -26927,37 +27287,37 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 241; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 242; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 241) { - if (i_1 === 0) { + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].kind === 242) { + if (i === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_1 > 0) { + if (i > 0) { write(", "); } - emit(attrs[i_1].expression); + emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 240); + ts.Debug.assert(attrs[i].kind === 241); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_1 > 0) { + if (i > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_1]); + emitJsxAttribute(attrs[i]); } } if (haveOpenedObjectLiteral) @@ -26966,7 +27326,7 @@ var ts; } else { write("{"); - for (var i = 0; i < attrs.length; i++) { + for (var i = 0, n = attrs.length; i < n; i++) { if (i > 0) { write(", "); } @@ -26977,10 +27337,10 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 242 && !(children[i].expression)) { + if (children[i].kind === 243 && !(children[i].expression)) { continue; } - if (children[i].kind === 238) { + if (children[i].kind === 239) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -26997,11 +27357,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 235) { + if (node.kind === 236) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 236); + ts.Debug.assert(node.kind === 237); emitJsxElement(node); } } @@ -27023,11 +27383,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 241) { + if (attribs[i].kind === 242) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 240); + ts.Debug.assert(attribs[i].kind === 241); emitJsxAttribute(attribs[i]); } } @@ -27035,11 +27395,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 236)) { + if (node.attributes.length > 0 || (node.kind === 237)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 236) { + if (node.kind === 237) { write("/>"); } else { @@ -27058,20 +27418,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 235) { + if (node.kind === 236) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 236); + ts.Debug.assert(node.kind === 237); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 165); + ts.Debug.assert(node.kind !== 166); if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 136) { + else if (node.kind === 137) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -27102,62 +27462,62 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 166: - case 191: - case 183: - case 170: - case 243: - case 136: + case 167: + case 192: case 184: - case 139: - case 177: - case 199: - case 169: - case 229: - case 197: - case 190: - case 201: + case 171: + case 244: + case 137: + case 185: + case 140: + case 178: + case 200: + case 170: + case 230: + case 198: + case 191: case 202: case 203: - case 198: - case 239: - case 236: + case 204: + case 199: + case 240: case 237: - case 241: + case 238: case 242: - case 171: - case 174: - case 182: - case 181: - case 206: - case 248: - case 187: - case 208: + case 243: case 172: - case 192: - case 210: - case 173: - case 178: - case 179: - case 200: - case 207: - case 186: - return true; - case 165: - case 249: - case 138: - case 247: - case 141: - case 213: - return parent.initializer === node; - case 168: - return parent.expression === node; - case 176: case 175: + case 183: + case 182: + case 207: + case 249: + case 188: + case 209: + case 173: + case 193: + case 211: + case 174: + case 179: + case 180: + case 201: + case 208: + case 187: + return true; + case 166: + case 250: + case 139: + case 248: + case 142: + case 214: + return parent.initializer === node; + case 169: + return parent.expression === node; + case 177: + case 176: return parent.body === node; - case 223: + case 224: return parent.moduleReference === node; - case 135: + case 136: return parent.left === node; } return false; @@ -27169,7 +27529,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 250) { + if (container.kind === 251) { if (modulekind !== 5 && modulekind !== 4) { write("exports."); } @@ -27183,15 +27543,15 @@ var ts; if (modulekind !== 5) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 225) { + if (declaration.kind === 226) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 228) { + else if (declaration.kind === 229) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_21 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_21); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); if (languageVersion === 0 && identifier === "default") { write("[\"default\"]"); } @@ -27220,13 +27580,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 165: - case 216: - case 219: - case 213: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + var parent_7 = node.parent; + switch (parent_7.kind) { + case 166: + case 217: + case 220: + case 214: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } return false; @@ -27234,8 +27594,8 @@ var ts; function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { - var name_22 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_22); + var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_25); return; } } @@ -27335,10 +27695,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 183 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 184 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 184 && node.parent.condition === node) { + else if (node.parent.kind === 185 && node.parent.condition === node) { return true; } return false; @@ -27346,11 +27706,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69: - case 166: - case 168: + case 167: case 169: case 170: - case 174: + case 171: + case 175: return false; } return true; @@ -27367,17 +27727,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 187) { + if (e.kind === 188) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 166) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 187) { + while (i < length && elements[i].kind !== 188) { i++; } write("["); @@ -27400,7 +27760,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 187; + return node.kind === 188; } function emitArrayLiteral(node) { var elements = node.elements; @@ -27461,7 +27821,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 145 || property.kind === 146) { + if (property.kind === 146 || property.kind === 147) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -27512,13 +27872,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 247) { + if (property.kind === 248) { emit(property.initializer); } - else if (property.kind === 248) { + else if (property.kind === 249) { emitExpressionIdentifier(property.name); } - else if (property.kind === 143) { + else if (property.kind === 144) { emitFunctionDeclaration(property); } else { @@ -27550,7 +27910,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136) { + if (properties[i].name.kind === 137) { numInitialNonComputedProperties = i; break; } @@ -27564,35 +27924,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(183, startsOnNewLine); + var result = ts.createSynthesizedNode(184, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(168); + var result = ts.createSynthesizedNode(169); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(169); + var result = ts.createSynthesizedNode(170); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 173 || expr.kind === 191) { + while (expr.kind === 174 || expr.kind === 192) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 171 && + expr.kind !== 172 && expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(174); + var node = ts.createSynthesizedNode(175); node.expression = expr; return node; } @@ -27619,7 +27979,7 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 250; + return container && container.kind !== 251; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentText, node.name); @@ -27637,7 +27997,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 168 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 169 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -27648,7 +28008,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 168 || node.kind === 169 + return node.kind === 169 || node.kind === 170 ? resolver.getConstantValue(node) : undefined; } @@ -27728,7 +28088,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 135: + case 136: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -27746,10 +28106,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 187; }); + return ts.forEach(elements, function (e) { return e.kind === 188; }); } function skipParentheses(node) { - while (node.kind === 174 || node.kind === 173 || node.kind === 191) { + while (node.kind === 175 || node.kind === 174 || node.kind === 192) { node = node.expression; } return node; @@ -27770,12 +28130,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 168) { + if (expr.kind === 169) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 169) { + else if (expr.kind === 170) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -27816,7 +28176,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 168 && node.expression.expression.kind === 95; + superCall = node.expression.kind === 169 && node.expression.expression.kind === 95; } if (superCall && languageVersion < 2) { write(".call("); @@ -27867,21 +28227,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 176) { - if (node.expression.kind === 173 || node.expression.kind === 191) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 177) { + if (node.expression.kind === 174 || node.expression.kind === 192) { var operand = node.expression.expression; - while (operand.kind === 173 || operand.kind === 191) { + while (operand.kind === 174 || operand.kind === 192) { operand = operand.expression; } - if (operand.kind !== 181 && + if (operand.kind !== 182 && + operand.kind !== 180 && operand.kind !== 179 && operand.kind !== 178 && - operand.kind !== 177 && - operand.kind !== 182 && - operand.kind !== 171 && - !(operand.kind === 170 && node.parent.kind === 171) && - !(operand.kind === 175 && node.parent.kind === 170) && - !(operand.kind === 8 && node.parent.kind === 168)) { + operand.kind !== 183 && + operand.kind !== 172 && + !(operand.kind === 171 && node.parent.kind === 172) && + !(operand.kind === 176 && node.parent.kind === 171) && + !(operand.kind === 8 && node.parent.kind === 169)) { emit(operand); return; } @@ -27910,7 +28270,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 213 || node.parent.kind === 165); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 || node.parent.kind === 166); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27925,7 +28285,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 181) { + if (node.operand.kind === 182) { var operand = node.operand; if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { write(" "); @@ -27968,10 +28328,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 250) { + if (current.kind === 251) { return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 221) { + else if (ts.isFunctionLike(current) || current.kind === 222) { return false; } else { @@ -27987,14 +28347,14 @@ var ts; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169, false); + synthesizedLHS = ts.createSynthesizedNode(170, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 && leftHandSideExpression.argumentExpression.kind !== 9) { var tempArgumentExpression = createAndRecordTempVariable(268435456); synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true, leftHandSideExpression.expression); } else { synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; @@ -28004,7 +28364,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(168, false); + synthesizedLHS = ts.createSynthesizedNode(169, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -28032,8 +28392,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 56 && - (node.left.kind === 167 || node.left.kind === 166)) { - emitDestructuring(node, node.parent.kind === 197); + (node.left.kind === 168 || node.left.kind === 167)) { + emitDestructuring(node, node.parent.kind === 198); } else { var exportChanged = node.operatorToken.kind >= 56 && @@ -28085,7 +28445,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 194) { + if (node && node.kind === 195) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -28099,12 +28459,12 @@ var ts; } emitToken(15, node.pos); increaseIndent(); - if (node.kind === 221) { - ts.Debug.assert(node.parent.kind === 220); + if (node.kind === 222) { + ts.Debug.assert(node.parent.kind === 221); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 221) { + if (node.kind === 222) { emitTempDeclarations(true); } decreaseIndent(); @@ -28112,7 +28472,7 @@ var ts; emitToken(16, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 194) { + if (node.kind === 195) { write(" "); emit(node); } @@ -28124,7 +28484,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 176); + emitParenthesizedIf(node.expression, node.expression.kind === 177); write(";"); } function emitIfStatement(node) { @@ -28137,7 +28497,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80, node.thenStatement.end); - if (node.elseStatement.kind === 198) { + if (node.elseStatement.kind === 199) { write(" "); emit(node.elseStatement); } @@ -28157,7 +28517,7 @@ var ts; else { emitNormalLoopBody(node, true); } - if (node.statement.kind === 194) { + if (node.statement.kind === 195) { write(" "); } else { @@ -28181,7 +28541,7 @@ var ts; emitNormalLoopBody(node, true); } } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { + function tryEmitStartOfVariableDeclarationList(decl) { if (shouldHoistVariable(decl, true)) { return false; } @@ -28192,31 +28552,20 @@ var ts; } return false; } - var tokenKind = 102; + emitStart(decl); if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 108; + write("let "); } else if (ts.isConst(decl)) { - tokenKind = 74; + write("const "); + } + else { + write("var "); } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); } else { - switch (tokenKind) { - case 102: - write("var "); - break; - case 108: - write("let "); - break; - case 74: - write("const "); - break; - } + write("var "); } return true; } @@ -28248,7 +28597,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 209) { + if (node.parent.kind === 210) { emitLabelAndColon(node.parent); } loopEmitter(node, loop); @@ -28258,10 +28607,11 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 201: case 202: case 203: - if (node.initializer.kind === 214) { + case 204: + var initializer = node.initializer; + if (initializer && initializer.kind === 215) { loopInitializer = node.initializer; } break; @@ -28274,7 +28624,7 @@ var ts; collectNames(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 194; + var bodyIsBlock = node.statement.kind === 195; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); @@ -28371,7 +28721,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 194) { + else if (node.statement.kind === 195) { emitLines(node.statement.statements); } else { @@ -28467,9 +28817,9 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 214) { + if (node.initializer && node.initializer.kind === 215) { var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { emitCommaList(variableDeclarationList.declarations); } @@ -28493,7 +28843,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 203) { + if (languageVersion < 2 && node.kind === 204) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -28504,17 +28854,17 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + tryEmitStartOfVariableDeclarationList(variableDeclarationList); emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 202) { + if (node.kind === 203) { write(" in "); } else { @@ -28550,24 +28900,24 @@ var ts; emitNodeWithoutSourceMap(node.expression); emitEnd(node.expression); write("; "); - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write(" < "); emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); - emitEnd(node.initializer); + emitEnd(node.expression); write("; "); - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write("++"); - emitEnd(node.initializer); + emitEnd(node.expression); emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 214) { + if (node.initializer.kind === 215) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -28589,7 +28939,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); - if (node.initializer.kind === 166 || node.initializer.kind === 167) { + if (node.initializer.kind === 167 || node.initializer.kind === 168) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -28611,12 +28961,12 @@ var ts; } function emitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 205 ? 2 : 4; + var jump = node.kind === 206 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { if (!node.label) { - if (node.kind === 205) { + if (node.kind === 206) { convertedLoopState.nonLocalJumps |= 2; write("return \"break\";"); } @@ -28627,7 +28977,7 @@ var ts; } else { var labelMarker; - if (node.kind === 205) { + if (node.kind === 206) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -28640,7 +28990,7 @@ var ts; return; } } - emitToken(node.kind === 205 ? 70 : 75, node.pos); + emitToken(node.kind === 206 ? 70 : 75, node.pos); emitOptional(" ", node.label); write(";"); } @@ -28705,7 +29055,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 243) { + if (node.kind === 244) { write("case "); emit(node.expression); write(":"); @@ -28774,7 +29124,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 220); + } while (node && node.kind !== 221); return node; } function emitContainingModuleName(node) { @@ -28799,13 +29149,13 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(179); + var result = ts.createSynthesizedNode(180); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 250) { - ts.Debug.assert(!!(node.flags & 512) || node.kind === 229); + if (node.parent.kind === 251) { + ts.Debug.assert(!!(node.flags & 512) || node.kind === 230); if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!isEs6Module) { if (languageVersion !== 0) { @@ -28890,7 +29240,7 @@ var ts; emitEnd(specifier.name); write(";"); } - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment, nodeForSourceMap) { if (shouldEmitCommaBeforeAssignment) { write(", "); } @@ -28900,63 +29250,75 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 213 || name.parent.kind === 165); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 || name.parent.kind === 166); + emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); + withTemporaryNoSourceMap(function () { + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + }); + emitEnd(nodeForSourceMap, true); if (exportChanged) { write(")"); } } - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment, sourceMapNode) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment, sourceMapNode || expression.parent); return identifier; } + function isFirstVariableDeclaration(root) { + return root.kind === 214 && + root.parent.kind === 215 && + root.parent.declarations[0] === root; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 213) { + if (root.kind === 214) { var isExported = ts.getCombinedNodeFlags(root) & 2; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 138) { + else if (root.kind === 139) { canDefineTempVariablesInPlace = true; } - if (root.kind === 183) { + if (root.kind === 184) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); + if (isFirstVariableDeclaration(root)) { + sourceMap.changeEmitSourcePos(); + } emitBindingElement(root, value); } - function ensureIdentifier(expr, reuseIdentifierExpressions) { + function ensureIdentifier(expr, reuseIdentifierExpressions, sourceMapNode) { if (expr.kind === 69 && reuseIdentifierExpressions) { return expr; } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0, sourceMapNode); emitCount++; return identifier; } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(183); + function createDefaultValueCheck(value, defaultValue, sourceMapNode) { + value = ensureIdentifier(value, true, sourceMapNode); + var equals = ts.createSynthesizedNode(184); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(184); + var cond = ts.createSynthesizedNode(185); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53); cond.whenTrue = whenTrue; @@ -28971,9 +29333,9 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 136; + var nameIsComputed = propName.kind === 137; if (nameIsComputed) { - index = ensureIdentifier(propName.expression, false); + index = ensureIdentifier(propName.expression, false, propName); } else { index = ts.createSynthesizedNode(propName.kind); @@ -28984,7 +29346,7 @@ var ts; : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(170); + var call = ts.createSynthesizedNode(171); var sliceIdentifier = ts.createSynthesizedNode(69); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -28992,56 +29354,56 @@ var ts; call.arguments[0] = createNumericLiteral(sliceIndex); return call; } - function emitObjectLiteralAssignment(target, value) { + function emitObjectLiteralAssignment(target, value, sourceMapNode) { var properties = target.properties; if (properties.length !== 1) { - value = ensureIdentifier(value, true); + value = ensureIdentifier(value, true, sourceMapNode); } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 247 || p.kind === 248) { + if (p.kind === 248 || p.kind === 249) { var propName = p.name; - var target_1 = p.kind === 248 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 249 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } } - function emitArrayLiteralAssignment(target, value) { + function emitArrayLiteralAssignment(target, value, sourceMapNode) { var elements = target.elements; if (elements.length !== 1) { - value = ensureIdentifier(value, true); + value = ensureIdentifier(value, true, sourceMapNode); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189) { - if (e.kind !== 187) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + if (e.kind !== 190) { + if (e.kind !== 188) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + emitDestructuringAssignment(e.expression, createSliceCall(value, i), e); } } } } - function emitDestructuringAssignment(target, value) { - if (target.kind === 248) { + function emitDestructuringAssignment(target, value, sourceMapNode) { + if (target.kind === 249) { if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 183 && target.operatorToken.kind === 56) { - value = createDefaultValueCheck(value, target.right); + else if (target.kind === 184 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 167) { - emitObjectLiteralAssignment(target, value); + if (target.kind === 168) { + emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 166) { - emitArrayLiteralAssignment(target, value); + else if (target.kind === 167) { + emitArrayLiteralAssignment(target, value, sourceMapNode); } else { - emitAssignment(target, value, emitCount > 0); + emitAssignment(target, value, emitCount > 0, sourceMapNode); emitCount++; } } @@ -29052,24 +29414,24 @@ var ts; emit(value); } else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); + emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 174) { + if (root.parent.kind !== 175) { write("("); } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); + value = ensureIdentifier(value, true, root); + emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 174) { + if (root.parent.kind !== 175) { write(")"); } } } function emitBindingElement(target, value) { if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + value = value ? createDefaultValueCheck(value, target.initializer, target) : target.initializer; } else if (!value) { value = createVoidZero(); @@ -29079,15 +29441,15 @@ var ts; var elements = pattern.elements; var numElements = elements.length; if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); + value = ensureIdentifier(value, numElements !== 0, target); } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 163) { + if (pattern.kind === 164) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 189) { + else if (element.kind !== 190) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -29098,7 +29460,7 @@ var ts; } } else { - emitAssignment(target.name, value, emitCount > 0); + emitAssignment(target.name, value, emitCount > 0, target); emitCount++; } } @@ -29119,8 +29481,8 @@ var ts; var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 8192); if (isLetDefinedInLoop && - node.parent.parent.kind !== 202 && - node.parent.parent.kind !== 203) { + node.parent.parent.kind !== 203 && + node.parent.parent.kind !== 204) { initializer = createVoidZero(); } } @@ -29138,7 +29500,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 189) { + if (node.kind === 190) { return; } var name = node.name; @@ -29150,7 +29512,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 213 && node.parent.kind !== 165)) { + if (!node.parent || (node.parent.kind !== 214 && node.parent.kind !== 166)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -29158,7 +29520,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 2) && modulekind === 5 && - node.parent.kind === 250; + node.parent.kind === 251; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -29203,12 +29565,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); + var name_26 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_26); + emit(name_26); } else { emit(node.name); @@ -29307,12 +29669,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 145 ? "get " : "set "); + write(node.kind === 146 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 176 && languageVersion >= 2; + return node.kind === 177 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -29323,10 +29685,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 175) { + if (node.kind === 176) { return !!node.name; } - if (node.kind === 215) { + if (node.kind === 216) { return !!node.name || modulekind !== 5; } } @@ -29335,12 +29697,12 @@ var ts; return emitCommentsOnNotEmittedNode(node); } var kind = node.kind, parent = node.parent; - if (kind !== 143 && - kind !== 142 && + if (kind !== 144 && + kind !== 143 && parent && - parent.kind !== 247 && - parent.kind !== 170 && - parent.kind !== 166) { + parent.kind !== 248 && + parent.kind !== 171 && + parent.kind !== 167) { emitLeadingComments(node); } emitStart(node); @@ -29361,11 +29723,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 && kind === 215 && parent === currentSourceFile && node.name) { + if (modulekind !== 5 && kind === 216 && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 143 && kind !== 142) { + if (kind !== 144 && kind !== 143) { emitTrailingComments(node); } } @@ -29397,7 +29759,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 176; + var isArrowFunction = node.kind === 177; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; if (!isArrowFunction) { write(" {"); @@ -29438,7 +29800,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 194) { + if (node.body.kind === 195) { emitBlockFunctionBody(node, node.body); } else { @@ -29490,10 +29852,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 173) { + while (current.kind === 174) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 167); + emitParenthesizedIf(body, current.kind === 168); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -29563,9 +29925,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 197) { + if (statement && statement.kind === 198) { var expr = statement.expression; - if (expr && expr.kind === 170) { + if (expr && expr.kind === 171) { var func = expr.expression; if (func && func.kind === 95) { return statement; @@ -29596,7 +29958,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 136) { + else if (memberName.kind === 137) { emitComputedPropertyName(memberName); } else { @@ -29608,7 +29970,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { + if (member.kind === 142 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { properties.push(member); } } @@ -29648,11 +30010,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 193) { + if (member.kind === 194) { writeLine(); write(";"); } - else if (member.kind === 143 || node.kind === 142) { + else if (member.kind === 144 || node.kind === 143) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -29669,7 +30031,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 145 || member.kind === 146) { + else if (member.kind === 146 || member.kind === 147) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -29719,22 +30081,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 143 || node.kind === 142) && !member.body) { + if ((member.kind === 144 || node.kind === 143) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 143 || - member.kind === 145 || - member.kind === 146) { + else if (member.kind === 144 || + member.kind === 146 || + member.kind === 147) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 64) { write("static "); } - if (member.kind === 145) { + if (member.kind === 146) { write("get "); } - else if (member.kind === 146) { + else if (member.kind === 147) { write("set "); } if (member.asteriskToken) { @@ -29745,7 +30107,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 193) { + else if (member.kind === 194) { writeLine(); write(";"); } @@ -29770,10 +30132,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 144 && !member.body) { + if (member.kind === 145 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 141 && member.initializer && (member.flags & 64) === 0) { + if (member.kind === 142 && member.initializer && (member.flags & 64) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -29877,7 +30239,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 216) { + if (node.kind === 217) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); @@ -29894,7 +30256,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 188; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -29957,7 +30319,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 250) { + else if (node.parent.kind !== 251) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -29969,7 +30331,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 216) { + if (node.kind === 217) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -30029,11 +30391,11 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 216) { + if (node.kind === 217) { write(";"); } emitEnd(node); - if (node.kind === 216) { + if (node.kind === 217) { emitExportMemberAssignment(node); } } @@ -30100,7 +30462,7 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 143) { + if (member.kind === 144) { functionLikeMember = member; } } @@ -30126,7 +30488,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0) { - if (member.kind !== 141) { + if (member.kind !== 142) { write(", null"); } else { @@ -30161,45 +30523,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 143: - case 145: + case 144: case 146: - case 141: + case 147: + case 142: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 143: + case 144: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 216: - case 143: - case 146: + case 217: + case 144: + case 147: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 216: + case 217: write("Function"); return; - case 141: + case 142: emitSerializedTypeNode(node.type); return; - case 138: - emitSerializedTypeNode(node.type); - return; - case 145: + case 139: emitSerializedTypeNode(node.type); return; case 146: + emitSerializedTypeNode(node.type); + return; + case 147: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -30215,23 +30577,23 @@ var ts; case 103: write("void 0"); return; - case 160: + case 161: emitSerializedTypeNode(node.type); return; - case 152: case 153: + case 154: write("Function"); return; - case 156: case 157: + case 158: write("Array"); return; - case 150: + case 151: case 120: write("Boolean"); return; case 130: - case 162: + case 163: write("String"); return; case 128: @@ -30240,15 +30602,15 @@ var ts; case 131: write("Symbol"); return; - case 151: + case 152: emitSerializedTypeReferenceNode(node); return; - case 154: case 155: - case 158: + case 156: case 159: + case 160: case 117: - case 161: + case 162: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -30312,7 +30674,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 216) { + if (node.kind === 217) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -30328,10 +30690,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 156) { + if (parameterType.kind === 157) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 152 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -30403,7 +30765,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 219))) { + if (!(node.flags & 2) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -30483,7 +30845,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 220) { + if (moduleDeclaration.body.kind === 221) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -30506,7 +30868,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -30524,7 +30886,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 221) { + if (node.body.kind === 222) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -30595,16 +30957,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 223) { + if (node.kind === 224) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 226) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 224 && node.importClause && !!node.importClause.name; + return node.kind === 225 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -30631,7 +30993,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 226) { + if (node.importClause.namedBindings.kind === 227) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -30657,7 +31019,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 223 && (node.flags & 2) !== 0; + var isExportedImport = node.kind === 224 && (node.flags & 2) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2) { emitLeadingComments(node); @@ -30669,7 +31031,7 @@ var ts; write(" = "); } else { - var isNakedImport = 224 && !node.importClause; + var isNakedImport = 225 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -30836,8 +31198,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 215 && - expression.kind !== 216) { + if (expression.kind !== 216 && + expression.kind !== 217) { write(";"); } emitEnd(node); @@ -30874,18 +31236,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 224: + case 225: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 223: - if (node.moduleReference.kind === 234 && resolver.isReferencedAliasDeclaration(node)) { + case 224: + if (node.moduleReference.kind === 235 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 230: + case 231: if (node.moduleSpecifier) { if (!node.exportClause) { if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { @@ -30900,12 +31262,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_27 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_27] || (exportSpecifiers[name_27] = [])).push(specifier); } } break; - case 229: + case 230: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -30930,18 +31292,18 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 224 && node.importClause) { + if (node.kind === 225 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 230 && node.moduleSpecifier) { + if (node.kind === 231 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode, emitRelativePathAsModuleName) { if (emitRelativePathAsModuleName) { - var name_25 = getExternalModuleNameFromDeclaration(host, resolver, importNode); - if (name_25) { - return "\"" + name_25 + "\""; + var name_28 = getExternalModuleNameFromDeclaration(host, resolver, importNode); + if (name_28) { + return "\"" + name_28 + "\""; } } var moduleName = ts.getExternalModuleName(importNode); @@ -30958,8 +31320,8 @@ var ts; var started = false; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; - var skipNode = importNode.kind === 230 || - (importNode.kind === 224 && !importNode.importClause); + var skipNode = importNode.kind === 231 || + (importNode.kind === 225 && !importNode.importClause); if (skipNode) { continue; } @@ -30984,7 +31346,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 230 && externalImport.exportClause) { + if (externalImport.kind === 231 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -31013,7 +31375,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 230) { + if (externalImport.kind !== 231) { continue; } var exportDecl = externalImport; @@ -31087,11 +31449,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; i++) { var local = hoistedVars[i]; - var name_26 = local.kind === 69 + var name_29 = local.kind === 69 ? local : local.name; - if (name_26) { - var text = ts.unescapeIdentifier(name_26.text); + if (name_29) { + var text = ts.unescapeIdentifier(name_29.text); if (ts.hasProperty(seen, text)) { continue; } @@ -31102,7 +31464,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 216 || local.kind === 220 || local.kind === 219) { + if (local.kind === 217 || local.kind === 221 || local.kind === 220) { emitDeclarationName(local); } else { @@ -31136,21 +31498,21 @@ var ts; if (node.flags & 4) { return; } - if (node.kind === 215) { + if (node.kind === 216) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 216) { + if (node.kind === 217) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 219) { + if (node.kind === 220) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -31159,7 +31521,7 @@ var ts; } return; } - if (node.kind === 220) { + if (node.kind === 221) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -31168,17 +31530,17 @@ var ts; } return; } - if (node.kind === 213 || node.kind === 165) { + if (node.kind === 214 || node.kind === 166) { if (shouldHoistVariable(node, false)) { - var name_27 = node.name; - if (name_27.kind === 69) { + var name_30 = node.name; + if (name_30.kind === 69) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_27); + hoistedVars.push(name_30); } else { - ts.forEachChild(name_27, visit); + ts.forEachChild(name_30, visit); } } return; @@ -31204,7 +31566,7 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 24576) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 250; + ts.getEnclosingBlockScopeContainer(node).kind === 251; } function isCurrentFileSystemExternalModule() { return modulekind === 4 && isCurrentFileExternalModule; @@ -31242,29 +31604,29 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 224: + case 225: if (!entry.importClause) { break; } - case 223: + case 224: ts.Debug.assert(importVariableName !== ""); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 230: + case 231: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { writeLine(); write(exportFunctionForFile + "({"); writeLine(); increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; i_2++) { - if (i_2 !== 0) { + for (var i_1 = 0, len = entry.exportClause.elements.length; i_1 < len; i_1++) { + if (i_1 !== 0) { write(","); writeLine(); } - var e = entry.exportClause.elements[i_2]; + var e = entry.exportClause.elements[i_1]; write("\""); emitNodeWithCommentsAndWithoutSourcemap(e.name); write("\": " + parameterName + "[\""); @@ -31296,10 +31658,10 @@ var ts; for (var i = startIndex; i < node.statements.length; i++) { var statement = node.statements[i]; switch (statement.kind) { - case 215: - case 224: + case 216: + case 225: continue; - case 230: + case 231: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -31307,7 +31669,7 @@ var ts; } } continue; - case 223: + case 224: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { continue; } @@ -31623,22 +31985,22 @@ var ts; } function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + if ((languageVersion < 2) && (!extendsEmitted && node.flags & 4194304)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + if (!decorateEmitted && node.flags & 8388608) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + if (!paramEmitted && node.flags & 16777216) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + if (!awaiterEmitted && node.flags & 33554432) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -31706,30 +32068,43 @@ var ts; emitJavaScriptWorker(node); } } + function changeSourceMapEmit(writer) { + sourceMap = writer; + emitStart = writer.emitStart; + emitEnd = writer.emitEnd; + emitPos = writer.emitPos; + setSourceFile = writer.setSourceFile; + } + function withTemporaryNoSourceMap(callback) { + var prevSourceMap = sourceMap; + setSourceMapWriterEmit(ts.getNullSourceMapWriter()); + callback(); + setSourceMapWriterEmit(prevSourceMap); + } function isSpecializedCommentHandling(node) { switch (node.kind) { - case 217: - case 215: - case 224: - case 223: case 218: - case 229: + case 216: + case 225: + case 224: + case 219: + case 230: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 195: + case 196: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 220: + case 221: return shouldEmitModuleDeclaration(node); - case 219: + case 220: return shouldEmitEnumDeclaration(node); } ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 194 && + if (node.kind !== 195 && node.parent && - node.parent.kind === 176 && + node.parent.kind === 177 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -31740,13 +32115,13 @@ var ts; switch (node.kind) { case 69: return emitIdentifier(node); - case 138: + case 139: return emitParameter(node); + case 144: case 143: - case 142: return emitMethod(node); - case 145: case 146: + case 147: return emitAccessor(node); case 97: return emitThis(node); @@ -31766,142 +32141,142 @@ var ts; case 13: case 14: return emitLiteral(node); - case 185: - return emitTemplateExpression(node); - case 192: - return emitTemplateSpan(node); - case 235: - case 236: - return emitJsxElement(node); - case 238: - return emitJsxText(node); - case 242: - return emitJsxExpression(node); - case 135: - return emitQualifiedName(node); - case 163: - return emitObjectBindingPattern(node); - case 164: - return emitArrayBindingPattern(node); - case 165: - return emitBindingElement(node); - case 166: - return emitArrayLiteral(node); - case 167: - return emitObjectLiteral(node); - case 247: - return emitPropertyAssignment(node); - case 248: - return emitShorthandPropertyAssignment(node); - case 136: - return emitComputedPropertyName(node); - case 168: - return emitPropertyAccess(node); - case 169: - return emitIndexedAccess(node); - case 170: - return emitCallExpression(node); - case 171: - return emitNewExpression(node); - case 172: - return emitTaggedTemplateExpression(node); - case 173: - return emit(node.expression); - case 191: - return emit(node.expression); - case 174: - return emitParenExpression(node); - case 215: - case 175: - case 176: - return emitFunctionDeclaration(node); - case 177: - return emitDeleteExpression(node); - case 178: - return emitTypeOfExpression(node); - case 179: - return emitVoidExpression(node); - case 180: - return emitAwaitExpression(node); - case 181: - return emitPrefixUnaryExpression(node); - case 182: - return emitPostfixUnaryExpression(node); - case 183: - return emitBinaryExpression(node); - case 184: - return emitConditionalExpression(node); - case 187: - return emitSpreadElementExpression(node); case 186: - return emitYieldExpression(node); - case 189: - return; - case 194: - case 221: - return emitBlock(node); - case 195: - return emitVariableStatement(node); - case 196: - return write(";"); - case 197: - return emitExpressionStatement(node); - case 198: - return emitIfStatement(node); - case 199: - return emitDoStatement(node); - case 200: - return emitWhileStatement(node); - case 201: - return emitForStatement(node); - case 203: - case 202: - return emitForInOrForOfStatement(node); - case 204: - case 205: - return emitBreakOrContinueStatement(node); - case 206: - return emitReturnStatement(node); - case 207: - return emitWithStatement(node); - case 208: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 193: + return emitTemplateSpan(node); + case 236: + case 237: + return emitJsxElement(node); + case 239: + return emitJsxText(node); case 243: - case 244: - return emitCaseOrDefaultClause(node); - case 209: - return emitLabeledStatement(node); - case 210: - return emitThrowStatement(node); - case 211: - return emitTryStatement(node); - case 246: - return emitCatchClause(node); - case 212: - return emitDebuggerStatement(node); - case 213: - return emitVariableDeclaration(node); - case 188: - return emitClassExpression(node); - case 216: - return emitClassDeclaration(node); - case 217: - return emitInterfaceDeclaration(node); - case 219: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 136: + return emitQualifiedName(node); + case 164: + return emitObjectBindingPattern(node); + case 165: + return emitArrayBindingPattern(node); + case 166: + return emitBindingElement(node); + case 167: + return emitArrayLiteral(node); + case 168: + return emitObjectLiteral(node); + case 248: + return emitPropertyAssignment(node); case 249: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 137: + return emitComputedPropertyName(node); + case 169: + return emitPropertyAccess(node); + case 170: + return emitIndexedAccess(node); + case 171: + return emitCallExpression(node); + case 172: + return emitNewExpression(node); + case 173: + return emitTaggedTemplateExpression(node); + case 174: + return emit(node.expression); + case 192: + return emit(node.expression); + case 175: + return emitParenExpression(node); + case 216: + case 176: + case 177: + return emitFunctionDeclaration(node); + case 178: + return emitDeleteExpression(node); + case 179: + return emitTypeOfExpression(node); + case 180: + return emitVoidExpression(node); + case 181: + return emitAwaitExpression(node); + case 182: + return emitPrefixUnaryExpression(node); + case 183: + return emitPostfixUnaryExpression(node); + case 184: + return emitBinaryExpression(node); + case 185: + return emitConditionalExpression(node); + case 188: + return emitSpreadElementExpression(node); + case 187: + return emitYieldExpression(node); + case 190: + return; + case 195: + case 222: + return emitBlock(node); + case 196: + return emitVariableStatement(node); + case 197: + return write(";"); + case 198: + return emitExpressionStatement(node); + case 199: + return emitIfStatement(node); + case 200: + return emitDoStatement(node); + case 201: + return emitWhileStatement(node); + case 202: + return emitForStatement(node); + case 204: + case 203: + return emitForInOrForOfStatement(node); + case 205: + case 206: + return emitBreakOrContinueStatement(node); + case 207: + return emitReturnStatement(node); + case 208: + return emitWithStatement(node); + case 209: + return emitSwitchStatement(node); + case 244: + case 245: + return emitCaseOrDefaultClause(node); + case 210: + return emitLabeledStatement(node); + case 211: + return emitThrowStatement(node); + case 212: + return emitTryStatement(node); + case 247: + return emitCatchClause(node); + case 213: + return emitDebuggerStatement(node); + case 214: + return emitVariableDeclaration(node); + case 189: + return emitClassExpression(node); + case 217: + return emitClassDeclaration(node); + case 218: + return emitInterfaceDeclaration(node); case 220: - return emitModuleDeclaration(node); - case 224: - return emitImportDeclaration(node); - case 223: - return emitImportEqualsDeclaration(node); - case 230: - return emitExportDeclaration(node); - case 229: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 250: + return emitEnumMember(node); + case 221: + return emitModuleDeclaration(node); + case 225: + return emitImportDeclaration(node); + case 224: + return emitImportEqualsDeclaration(node); + case 231: + return emitExportDeclaration(node); + case 230: + return emitExportAssignment(node); + case 251: return emitSourceFileNode(node); } } @@ -31931,7 +32306,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 250 || node.pos !== node.parent.pos) { + if (node.parent.kind === 251 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -31943,7 +32318,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 250 || node.end !== node.parent.end) { + if (node.parent.kind === 251 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -32329,7 +32704,23 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + : (function (moduleNames, containingFile) { + var resolvedModuleNames = []; + var lookup = {}; + for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { + var moduleName = moduleNames_1[_i]; + var resolvedName = void 0; + if (ts.hasProperty(lookup, moduleName)) { + resolvedName = lookup[moduleName]; + } + else { + resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule; + lookup[moduleName] = resolvedName; + } + resolvedModuleNames.push(resolvedName); + } + return resolvedModuleNames; + }); var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { @@ -32431,8 +32822,11 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { return false; } + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + return false; + } if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); for (var i = 0; i < moduleNames.length; i++) { var newResolution = resolutions[i]; @@ -32569,44 +32963,44 @@ var ts; return false; } switch (node.kind) { - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 216: + case 217: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 245: + case 246: var heritageClause = node; if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 217: + case 218: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 143: - case 142: case 144: + case 143: case 145: case 146: - case 175: - case 215: + case 147: case 176: - case 215: + case 216: + case 177: + case 216: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -32614,20 +33008,20 @@ var ts; return true; } break; - case 195: + case 196: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 213: + case 214: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 170: case 171: + case 172: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -32635,7 +33029,7 @@ var ts; return true; } break; - case 138: + case 139: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -32651,17 +33045,17 @@ var ts; return true; } break; - case 141: + case 142: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219: + case 220: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 173: + case 174: 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 139: + case 140: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -32737,51 +33131,64 @@ var ts; function moduleNameIsEqualTo(a, b) { return a.text === b.text; } + function getTextOfLiteral(literal) { + return literal.text; + } function collectExternalModuleReferences(file) { if (file.imports) { return; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); + var isExternalModuleFile = ts.isExternalModule(file); var imports; + var moduleAugmentations; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; - collect(node, true, false); + collectModuleReferences(node, false); + if (isJavaScriptFile) { + collectRequireCalls(node); + } } file.imports = imports || emptyArray; + file.moduleAugmentations = moduleAugmentations || emptyArray; return; - function collect(node, allowRelativeModuleNames, collectOnlyRequireCalls) { - if (!collectOnlyRequireCalls) { - switch (node.kind) { - case 224: - case 223: - case 230: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } + function collectModuleReferences(node, inAmbientModule) { + switch (node.kind) { + case 225: + case 224: + case 231: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; - case 220: - if (node.name.kind === 9 && (node.flags & 4 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - collect(node, false, collectOnlyRequireCalls); - }); - } + } + if (!moduleNameExpr.text) { break; - } + } + if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 221: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 || ts.isDeclarationFile(file))) { + var moduleName = node.name; + if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { + (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + } + else if (!inAmbientModule) { + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + collectModuleReferences(statement, true); + } + } + } } - if (isJavaScriptFile) { - if (ts.isRequireCall(node)) { - (imports || (imports = [])).push(node.arguments[0]); - } - else { - ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames, true); }); - } + } + function collectRequireCalls(node) { + if (ts.isRequireCall(node)) { + (imports || (imports = [])).push(node.arguments[0]); + } + else { + ts.forEachChild(node, collectRequireCalls); } } } @@ -32887,14 +33294,17 @@ var ts; } function processImportedModules(file, basePath) { collectExternalModuleReferences(file); - if (file.imports.length) { + if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); - for (var i = 0; i < file.imports.length; i++) { + for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { + var shouldAddFile = resolution && + !options.noResolve && + i < file.imports.length; + if (shouldAddFile) { var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { @@ -33117,6 +33527,9 @@ var ts; startNode.getStart(sourceFile); return ts.createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } + function textSpanEndingAtNextToken(startNode, previousTokenToFindNextEndToken) { + return textSpan(startNode, ts.findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent)); + } function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { return spanInNode(node); @@ -33134,104 +33547,90 @@ var ts; } function spanInNode(node) { if (node) { - if (ts.isExpression(node)) { - if (node.parent.kind === 199) { - return spanInPreviousNode(node); - } - if (node.parent.kind === 139) { - return spanInNode(node.parent); - } - if (node.parent.kind === 201) { - return textSpan(node); - } - if (node.parent.kind === 183 && node.parent.operatorToken.kind === 24) { - return textSpan(node); - } - if (node.parent.kind === 176 && node.parent.body === node) { - return textSpan(node); - } - } switch (node.kind) { - case 195: + case 196: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 213: - case 141: - case 140: - return spanInVariableDeclaration(node); - case 138: - return spanInParameterDeclaration(node); - case 215: - case 143: + case 214: case 142: - case 145: - case 146: + case 141: + return spanInVariableDeclaration(node); + case 139: + return spanInParameterDeclaration(node); + case 216: case 144: - case 175: + case 143: + case 146: + case 147: + case 145: case 176: + case 177: return spanInFunctionDeclaration(node); - case 194: + case 195: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 221: + case 222: return spanInBlock(node); - case 246: + case 247: return spanInBlock(node.block); - case 197: - return textSpan(node.expression); - case 206: - return textSpan(node.getChildAt(0), node.expression); - case 200: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 199: - return spanInNode(node.statement); - case 212: - return textSpan(node.getChildAt(0)); case 198: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 209: - return spanInNode(node.statement); - case 205: - case 204: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 207: + return textSpan(node.getChildAt(0), node.expression); case 201: - return spanInForStatement(node); - case 202: - case 203: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 208: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 243: - case 244: - return spanInNode(node.statements[0]); - case 211: - return spanInBlock(node.tryBlock); + return textSpanEndingAtNextToken(node, node.expression); + case 200: + return spanInNode(node.statement); + case 213: + return textSpan(node.getChildAt(0)); + case 199: + return textSpanEndingAtNextToken(node, node.expression); case 210: + return spanInNode(node.statement); + case 206: + case 205: + return textSpan(node.getChildAt(0), node.label); + case 202: + return spanInForStatement(node); + case 203: + return textSpanEndingAtNextToken(node, node.expression); + case 204: + return spanInInitializerOfForLike(node); + case 209: + return textSpanEndingAtNextToken(node, node.expression); + case 244: + case 245: + return spanInNode(node.statements[0]); + case 212: + return spanInBlock(node.tryBlock); + case 211: return textSpan(node, node.expression); - case 229: - return textSpan(node, node.expression); - case 223: - return textSpan(node, node.moduleReference); - case 224: - return textSpan(node, node.moduleSpecifier); case 230: + return textSpan(node, node.expression); + case 224: + return textSpan(node, node.moduleReference); + case 225: return textSpan(node, node.moduleSpecifier); - case 220: + case 231: + return textSpan(node, node.moduleSpecifier); + case 221: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 216: - case 219: - case 249: - case 170: - case 171: - return textSpan(node); - case 207: - return spanInNode(node.statement); - case 139: - return spanInNodeArray(node.parent.decorators); case 217: + case 220: + case 250: + case 166: + return textSpan(node); + case 208: + return spanInNode(node.statement); + case 140: + return spanInNodeArray(node.parent.decorators); + case 164: + case 165: + return spanInBindingPattern(node); case 218: + case 219: return undefined; case 23: case 1: @@ -33242,6 +33641,8 @@ var ts; return spanInOpenBraceToken(node); case 16: return spanInCloseBraceToken(node); + case 20: + return spanInCloseBracketToken(node); case 17: return spanInOpenParenToken(node); case 18: @@ -33257,48 +33658,108 @@ var ts; case 72: case 85: return spanInNextNode(node); + case 135: + return spanInOfKeyword(node); default: - if (node.parent.kind === 247 && node.parent.name === node) { + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); + } + if ((node.kind === 69 || + node.kind == 188 || + node.kind === 248 || + node.kind === 249) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + return textSpan(node); + } + if (node.kind === 184) { + var binaryExpression = node; + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); + } + if (binaryExpression.operatorToken.kind === 56 && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { + return textSpan(node); + } + if (binaryExpression.operatorToken.kind === 24) { + return spanInNode(binaryExpression.left); + } + } + if (ts.isExpression(node)) { + switch (node.parent.kind) { + case 200: + return spanInPreviousNode(node); + case 140: + return spanInNode(node.parent); + case 202: + case 204: + return textSpan(node); + case 184: + if (node.parent.operatorToken.kind === 24) { + return textSpan(node); + } + break; + case 177: + if (node.parent.body === node) { + return textSpan(node); + } + break; + } + } + if (node.parent.kind === 248 && + node.parent.name === node && + !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 173 && node.parent.type === node) { - return spanInNode(node.parent.expression); + if (node.parent.kind === 174 && 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 === 214 || + node.parent.kind === 139)) { + var paramOrVarDecl = node.parent; + if (paramOrVarDecl.initializer === node || + paramOrVarDecl.type === node || + ts.isAssignmentOperator(node.kind)) { + return spanInPreviousNode(node); + } + } + if (node.parent.kind === 184) { + var binaryExpression = node.parent; + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && + (binaryExpression.right === node || + binaryExpression.operatorToken === node)) { + return spanInPreviousNode(node); + } + } return spanInNode(node.parent); } } + function textSpanFromVariableDeclaration(variableDeclaration) { + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] === variableDeclaration) { + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + else { + return textSpan(variableDeclaration); + } + } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 202 || - variableDeclaration.parent.parent.kind === 203) { + if (variableDeclaration.parent.parent.kind === 203) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 195; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 201 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); - var declarations = isParentVariableStatement - ? variableDeclaration.parent.parent.declarationList.declarations - : isDeclarationOfForStatement - ? variableDeclaration.parent.parent.initializer.declarations - : undefined; - if (variableDeclaration.initializer || (variableDeclaration.flags & 2)) { - if (declarations && declarations[0] === variableDeclaration) { - if (isParentVariableStatement) { - return textSpan(variableDeclaration.parent, variableDeclaration); - } - else { - ts.Debug.assert(isDeclarationOfForStatement); - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - } - else { - return textSpan(variableDeclaration); - } + if (ts.isBindingPattern(variableDeclaration.name)) { + return spanInBindingPattern(variableDeclaration.name); } - else if (declarations && declarations[0] !== variableDeclaration) { - var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); - return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); + if (variableDeclaration.initializer || + (variableDeclaration.flags & 2) || + variableDeclaration.parent.parent.kind === 204) { + return textSpanFromVariableDeclaration(variableDeclaration); + } + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] !== variableDeclaration) { + return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); } } function canHaveSpanInParameterDeclaration(parameter) { @@ -33306,7 +33767,10 @@ var ts; !!(parameter.flags & 8) || !!(parameter.flags & 16); } function spanInParameterDeclaration(parameter) { - if (canHaveSpanInParameterDeclaration(parameter)) { + if (ts.isBindingPattern(parameter.name)) { + return spanInBindingPattern(parameter.name); + } + else if (canHaveSpanInParameterDeclaration(parameter)) { return textSpan(parameter); } else { @@ -33322,7 +33786,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 2) || - (functionDeclaration.parent.kind === 216 && functionDeclaration.kind !== 144); + (functionDeclaration.parent.kind === 217 && functionDeclaration.kind !== 145); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -33342,31 +33806,34 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 220: + case 221: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 200: - case 198: - case 202: + case 201: + case 199: case 203: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 201: + case 202: + case 204: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } + function spanInInitializerOfForLike(forLikeStaement) { + if (forLikeStaement.initializer.kind === 215) { + var variableDeclarationList = forLikeStaement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } + } + else { + return spanInNode(forLikeStaement.initializer); + } + } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 214) { - var variableDeclarationList = forStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } - } - else { - return spanInNode(forStatement.initializer); - } + return spanInInitializerOfForLike(forStatement); } if (forStatement.condition) { return textSpan(forStatement.condition); @@ -33375,84 +33842,142 @@ var ts; return textSpan(forStatement.incrementor); } } + function spanInBindingPattern(bindingPattern) { + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + if (bindingPattern.parent.kind === 166) { + return textSpan(bindingPattern.parent); + } + return textSpanFromVariableDeclaration(bindingPattern.parent); + } + function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { + ts.Debug.assert(node.kind !== 165 && node.kind !== 164); + var elements = node.kind === 167 ? + node.elements : + node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + return textSpan(node.parent.kind === 184 ? node.parent : node); + } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 219: + case 220: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 216: + case 217: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 222: + case 223: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 221: + case 222: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 219: - case 216: + case 220: + case 217: return textSpan(node); - case 194: + case 195: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 246: + case 247: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 222: + case 223: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; + case 164: + var bindingPattern = node.parent; + return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + var objectLiteral = node.parent; + return textSpan(ts.lastOrUndefined(objectLiteral.properties) || objectLiteral); + } + return spanInNode(node.parent); + } + } + function spanInCloseBracketToken(node) { + switch (node.parent.kind) { + case 165: + var bindingPattern = node.parent; + return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); + default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + var arrayLiteral = node.parent; + return textSpan(ts.lastOrUndefined(arrayLiteral.elements) || arrayLiteral); + } return spanInNode(node.parent); } } function spanInOpenParenToken(node) { - if (node.parent.kind === 199) { + if (node.parent.kind === 200 || + node.parent.kind === 171 || + node.parent.kind === 172) { return spanInPreviousNode(node); } + if (node.parent.kind === 175) { + return spanInNextNode(node); + } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 175: - case 215: case 176: - case 143: - case 142: - case 145: - case 146: + case 216: + case 177: case 144: - case 200: - case 199: + case 143: + case 146: + case 147: + case 145: case 201: + case 200: + case 202: + case 204: + case 171: + case 172: + case 175: return spanInPreviousNode(node); default: return spanInNode(node.parent); } } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 247) { + if (ts.isFunctionLike(node.parent) || + node.parent.kind === 248 || + node.parent.kind === 139) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 173) { - return spanInNode(node.parent.expression); + if (node.parent.kind === 174) { + return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 199) { - return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); + if (node.parent.kind === 200) { + return textSpanEndingAtNextToken(node, node.parent.expression); + } + return spanInNode(node.parent); + } + function spanInOfKeyword(node) { + if (node.parent.kind === 204) { + return spanInNextNode(node); } return spanInNode(node.parent); } @@ -33529,7 +34054,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 176; + return ts.isFunctionBlock(node) && node.parent.kind !== 177; } var depth = 0; var maxDepth = 20; @@ -33541,26 +34066,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 194: + case 195: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_7.kind === 199 || - parent_7.kind === 202 || - parent_7.kind === 203 || - parent_7.kind === 201 || - parent_7.kind === 198 || - parent_7.kind === 200 || - parent_7.kind === 207 || - parent_7.kind === 246) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 200 || + parent_8.kind === 203 || + parent_8.kind === 204 || + parent_8.kind === 202 || + parent_8.kind === 199 || + parent_8.kind === 201 || + parent_8.kind === 208 || + parent_8.kind === 247) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 211) { - var tryStatement = parent_7; + if (parent_8.kind === 212) { + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -33580,23 +34105,23 @@ var ts; }); break; } - case 221: { + case 222: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 216: case 217: - case 219: - case 167: - case 222: { + case 218: + case 220: + case 168: + case 223: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 166: + case 167: var openBracket = ts.findChildOfKind(n, 19, sourceFile); var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -33623,10 +34148,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_31 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_31); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_31); if (!matches) { continue; } @@ -33637,14 +34162,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_31); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_31, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -33681,7 +34206,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 136) { + else if (declaration.name.kind === 137) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -33698,7 +34223,7 @@ var ts; } return true; } - if (expression.kind === 168) { + if (expression.kind === 169) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -33709,7 +34234,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 136) { + if (declaration.name.kind === 137) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -33771,14 +34296,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 220: + case 221: do { current = current.parent; - } while (current.kind === 220); - case 216: - case 219: + } while (current.kind === 221); case 217: - case 215: + case 220: + case 218: + case 216: indent++; } current = current.parent; @@ -33789,26 +34314,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 195: + case 196: ts.forEach(node.declarationList.declarations, visit); break; - case 163: case 164: + case 165: ts.forEach(node.elements, visit); break; - case 230: + case 231: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 224: + case 225: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226) { + if (importClause.namedBindings.kind === 227) { childNodes.push(importClause.namedBindings); } else { @@ -33817,20 +34342,20 @@ var ts; } } break; - case 165: - case 213: + case 166: + case 214: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 216: - case 219: case 217: case 220: - case 215: - case 223: - case 228: - case 232: + case 218: + case 221: + case 216: + case 224: + case 229: + case 233: childNodes.push(node); break; } @@ -33865,17 +34390,17 @@ var ts; for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; switch (node.kind) { - case 216: - case 219: case 217: + case 220: + case 218: topLevelNodes.push(node); break; - case 220: + case 221: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 215: + case 216: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -33886,9 +34411,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 215) { - if (functionDeclaration.body && functionDeclaration.body.kind === 194) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 215 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 216) { + if (functionDeclaration.body && functionDeclaration.body.kind === 195) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 216 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -33941,7 +34466,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 138: + case 139: if (ts.isBindingPattern(node.name)) { break; } @@ -33949,34 +34474,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 144: case 143: - case 142: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 145: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 146: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 149: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 249: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 147: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 148: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 141: - case 140: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 150: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 250: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 215: + case 148: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 149: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 142: + case 141: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 216: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 213: - case 165: + case 214: + case 166: var variableDeclarationNode; - var name_29; - if (node.kind === 165) { - name_29 = node.name; + var name_32; + if (node.kind === 166) { + name_32 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 213) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 214) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -33984,24 +34509,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_32 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.variableElement); } - case 144: + case 145: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 232: - case 228: - case 223: - case 225: + case 233: + case 229: + case 224: case 226: + case 227: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -34031,27 +34556,27 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 250: + case 251: return createSourceFileItem(node); - case 216: - return createClassItem(node); - case 219: - return createEnumItem(node); case 217: - return createIterfaceItem(node); + return createClassItem(node); case 220: + return createEnumItem(node); + case 218: + return createIterfaceItem(node); + case 221: return createModuleItem(node); - case 215: + case 216: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { - if (moduleDeclaration.name.kind === 9) { + if (ts.isAmbientModule(moduleDeclaration)) { return getTextOfNode(moduleDeclaration.name); } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 220) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 221) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -34063,7 +34588,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 194) { + if (node.body && node.body.kind === 195) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -34084,7 +34609,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 144 && member; + return member.kind === 145 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -34105,19 +34630,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 137; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 220) { + while (node.body.kind === 221) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 250 + return node.kind === 251 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -34572,14 +35097,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 170) { + if (argumentInfo.invocation.kind !== 171) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 69 ? expression - : expression.kind === 168 + : expression.kind === 169 ? expression.name : undefined; if (!name || !name.text) { @@ -34608,7 +35133,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 170 || node.parent.kind === 171) { + if (node.parent.kind === 171 || node.parent.kind === 172) { var callExpression = node.parent; if (node.kind === 25 || node.kind === 17) { @@ -34639,23 +35164,23 @@ var ts; }; } } - else if (node.kind === 11 && node.parent.kind === 172) { + else if (node.kind === 11 && node.parent.kind === 173) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 12 && node.parent.parent.kind === 172) { + else if (node.kind === 12 && node.parent.parent.kind === 173) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 185); + ts.Debug.assert(templateExpression.kind === 186); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 192 && node.parent.parent.parent.kind === 172) { + else if (node.parent.kind === 193 && node.parent.parent.parent.kind === 173) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 185); + ts.Debug.assert(templateExpression.kind === 186); if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -34719,7 +35244,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 185) { + if (template.kind === 186) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -34728,7 +35253,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 250; n = n.parent) { + for (var n = node; n.kind !== 251; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -34908,39 +35433,39 @@ var ts; return false; } switch (n.kind) { - case 216: case 217: - case 219: - case 167: - case 163: - case 155: - case 194: - case 221: + case 218: + case 220: + case 168: + case 164: + case 156: + case 195: case 222: + case 223: return nodeEndsWith(n, 16, sourceFile); - case 246: + case 247: return isCompletedNode(n.block, sourceFile); - case 171: + case 172: if (!n.arguments) { return true; } - case 170: - case 174: - case 160: + case 171: + case 175: + case 161: return nodeEndsWith(n, 18, sourceFile); - case 152: case 153: + case 154: return isCompletedNode(n.type, sourceFile); - case 144: case 145: case 146: - case 215: - case 175: - case 143: - case 142: - case 148: case 147: + case 216: case 176: + case 144: + case 143: + case 149: + case 148: + case 177: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -34948,62 +35473,62 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 18, sourceFile); - case 220: + case 221: return n.body && isCompletedNode(n.body, sourceFile); - case 198: + case 199: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 197: + case 198: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 23); - case 166: - case 164: - case 169: - case 136: - case 157: + case 167: + case 165: + case 170: + case 137: + case 158: return nodeEndsWith(n, 20, sourceFile); - case 149: + case 150: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20, sourceFile); - case 243: case 244: + case 245: return false; - case 201: case 202: case 203: - case 200: + case 204: + case 201: return isCompletedNode(n.statement, sourceFile); - case 199: + case 200: var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 154: + case 155: return isCompletedNode(n.exprName, sourceFile); - case 178: - case 177: case 179: - case 186: + case 178: + case 180: case 187: + case 188: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 172: + case 173: return isCompletedNode(n.template, sourceFile); - case 185: + case 186: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 192: + case 193: return ts.nodeIsPresent(n.literal); - case 181: + case 182: return isCompletedNode(n.operand, sourceFile); - case 183: - return isCompletedNode(n.right, sourceFile); case 184: + return isCompletedNode(n.right, sourceFile); + case 185: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -35046,7 +35571,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 273 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 274 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -35126,7 +35651,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 238) { + if (isToken(n) || n.kind === 239) { return n; } var children = n.getChildren(); @@ -35134,16 +35659,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 238) { + if (isToken(n) || n.kind === 239) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 238)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 239)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 238 && start === child.end); + (child.kind === 239 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -35153,7 +35678,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 250); + ts.Debug.assert(startNode !== undefined || n.kind === 251); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -35170,7 +35695,7 @@ var ts; ts.findPrecedingToken = findPrecedingToken; function isInString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); - return token && (token.kind === 9 || token.kind === 162) && position > token.getStart(); + return token && (token.kind === 9 || token.kind === 163) && position > token.getStart(); } ts.isInString = isInString; function isInComment(sourceFile, position) { @@ -35253,17 +35778,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 151 || node.kind === 170) { + if (node.kind === 152 || node.kind === 171) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 216 || node.kind === 217) { + if (ts.isFunctionLike(node) || node.kind === 217 || node.kind === 218) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 134; + return n.kind >= 0 && n.kind <= 135; } ts.isToken = isToken; function isWord(kind) { @@ -35279,7 +35804,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 162 + || kind === 163 || kind === 10 || ts.isTemplateLiteralKind(kind)) { return true; @@ -35322,11 +35847,30 @@ var ts; return true; } ts.compareDataObjects = compareDataObjects; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { + if (node.kind === 167 || + node.kind === 168) { + if (node.parent.kind === 184 && + node.parent.left === node && + node.parent.operatorToken.kind === 56) { + return true; + } + if (node.parent.kind === 204 && + node.parent.initializer === node) { + return true; + } + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 248 ? node.parent.parent : node.parent)) { + return true; + } + } + return false; + } + ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; })(ts || (ts = {})); var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 139; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -35507,7 +36051,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 228 || location.parent.kind === 232) && + (location.parent.kind === 229 || location.parent.kind === 233) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -35609,10 +36153,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 241: + case 238: case 240: case 237: - case 239: - case 236: return node.kind === 69; } } @@ -36084,41 +36628,41 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_33 in o) { + if (o[name_33] === rule) { + return name_33; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 201; + return context.contextNode.kind === 202; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 183: case 184: - case 191: - case 150: - case 158: + case 185: + case 192: + case 151: case 159: + case 160: return true; - case 165: - case 218: - case 223: - case 213: - case 138: - case 249: + case 166: + case 219: + case 224: + case 214: + case 139: + case 250: + case 142: case 141: - case 140: return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 202: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; case 203: - return context.currentTokenSpan.kind === 134 || context.nextTokenSpan.kind === 134; + return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + case 204: + return context.currentTokenSpan.kind === 135 || context.nextTokenSpan.kind === 135; } return false; }; @@ -36126,7 +36670,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 184; + return context.contextNode.kind === 185; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -36151,86 +36695,86 @@ var ts; return true; } switch (node.kind) { - case 194: + case 195: + case 223: + case 168: case 222: - case 167: - case 221: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 215: + case 216: + case 144: case 143: - case 142: - case 145: case 146: case 147: - case 175: - case 144: + case 148: case 176: - case 217: + case 145: + case 177: + case 218: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 215 || context.contextNode.kind === 175; + return context.contextNode.kind === 216 || context.contextNode.kind === 176; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 216: - case 188: case 217: - case 219: - case 155: + case 189: + case 218: case 220: + case 156: + case 221: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 216: - case 220: - case 219: - case 194: - case 246: + case 217: case 221: - case 208: + case 220: + case 195: + case 247: + case 222: + case 209: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 198: - case 208: - case 201: + case 199: + case 209: case 202: case 203: + case 204: + case 201: + case 212: case 200: - case 211: - case 199: - case 207: - case 246: + case 208: + case 247: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 167; + return context.contextNode.kind === 168; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 170; + return context.contextNode.kind === 171; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 172; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -36242,7 +36786,7 @@ var ts; return context.nextTokenSpan.kind !== 20; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 177; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -36260,41 +36804,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 139; + return node.kind === 140; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 214 && + return context.currentTokenParent.kind === 215 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 220; + return context.contextNode.kind === 221; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 155; + return context.contextNode.kind === 156; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 151: - case 173: - case 216: - case 188: + case 152: + case 174: case 217: - case 215: - case 175: + case 189: + case 218: + case 216: case 176: + case 177: + case 144: case 143: - case 142: - case 147: case 148: - case 170: + case 149: case 171: - case 190: + case 172: + case 191: return true; default: return false; @@ -36305,13 +36849,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 173; + return context.contextNode.kind === 174; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 179; + return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 180; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 186 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 187 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -36333,7 +36877,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 134 + 1; + this.mapRowLength = 135 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -36509,7 +37053,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 134; token++) { + for (var token = 0; token <= 135; token++) { result.push(token); } return result; @@ -36551,9 +37095,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 134); + TokenRange.Keywords = TokenRange.FromRange(70, 135); TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 134, 116, 124]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 135, 116, 124]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); @@ -36740,17 +37284,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 216: case 217: + case 218: return ts.rangeContainsRange(parent.members, node); - case 220: - var body = parent.body; - return body && body.kind === 194 && ts.rangeContainsRange(body.statements, node); - case 250: - case 194: case 221: + var body = parent.body; + return body && body.kind === 195 && ts.rangeContainsRange(body.statements, node); + case 251: + case 195: + case 222: return ts.rangeContainsRange(parent.statements, node); - case 246: + case 247: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36905,18 +37449,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 216: return 73; - case 217: return 107; - case 215: return 87; - case 219: return 219; - case 145: return 123; - case 146: return 129; - case 143: + case 217: return 73; + case 218: return 107; + case 216: return 87; + case 220: return 220; + case 146: return 123; + case 147: return 129; + case 144: if (node.asteriskToken) { return 37; } - case 141: - case 138: + case 142: + case 139: return node.name.kind; } } @@ -37029,7 +37573,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 139 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 140 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -37332,20 +37876,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 194: - case 221: + case 195: + case 222: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 144: - case 215: - case 175: - case 143: - case 142: + case 145: + case 216: case 176: + case 144: + case 143: + case 177: if (node.typeParameters === list) { return 25; } @@ -37353,8 +37897,8 @@ var ts; return 17; } break; - case 170: case 171: + case 172: if (node.typeArguments === list) { return 25; } @@ -37362,7 +37906,7 @@ var ts; return 17; } break; - case 151: + case 152: if (node.typeArguments === list) { return 25; } @@ -37463,7 +38007,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 183) { + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 184) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -37561,7 +38105,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 250 || !parentAndChildShareLine); + (parent.kind === 251 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -37585,7 +38129,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 198 && parent.elseStatement === child) { + if (parent.kind === 199 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -37597,23 +38141,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 151: + case 152: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 167: + case 168: return node.parent.properties; - case 166: + case 167: return node.parent.elements; - case 215: - case 175: + case 216: case 176: + case 177: + case 144: case 143: - case 142: - case 147: - case 148: { + case 148: + case 149: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -37624,8 +38168,8 @@ var ts; } break; } - case 171: - case 170: { + case 172: + case 171: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -37653,8 +38197,8 @@ var ts; if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 170 || - node.parent.kind === 171) && + if (node.parent && (node.parent.kind === 171 || + node.parent.kind === 172) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -37672,10 +38216,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 170: case 171: - case 168: + case 172: case 169: + case 170: node = node.expression; break; default: @@ -37729,45 +38273,45 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 197: - case 216: - case 188: + case 198: case 217: - case 219: + case 189: case 218: - case 166: - case 194: - case 221: + case 220: + case 219: case 167: - case 155: - case 157: - case 222: - case 244: - case 243: - case 174: - case 168: - case 170: - case 171: case 195: - case 213: - case 229: - case 206: - case 184: - case 164: - case 163: - case 237: - case 236: - case 242: - case 142: - case 147: - case 148: - case 138: - case 152: - case 153: - case 160: + case 222: + case 168: + case 156: + case 158: + case 223: + case 245: + case 244: + case 175: + case 169: + case 171: case 172: - case 180: - case 227: + case 196: + case 214: + case 230: + case 207: + case 185: + case 165: + case 164: + case 238: + case 237: + case 243: + case 143: + case 148: + case 149: + case 139: + case 153: + case 154: + case 161: + case 173: + case 181: + case 228: return true; } return false; @@ -37775,22 +38319,22 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 199: case 200: - case 202: - case 203: case 201: - case 198: - case 215: - case 175: - case 143: + case 203: + case 204: + case 202: + case 199: + case 216: case 176: case 144: + case 177: case 145: case 146: - return childKind !== 194; - case 235: - return childKind !== 239; + case 147: + return childKind !== 195; + case 236: + return childKind !== 240; } return indentByDefault; } @@ -37925,7 +38469,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(273, nodes.pos, nodes.end, 2048, this); + var list = createNode(274, nodes.pos, nodes.end, 2048, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -37944,7 +38488,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 135) { + if (this.kind >= 136) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -37991,7 +38535,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 135 ? child : child.getFirstToken(sourceFile); + return child.kind < 136 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -37999,7 +38543,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 135 ? child : child.getLastToken(sourceFile); + return child.kind < 136 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -38041,7 +38585,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 138) { + if (canUseParsedParamTagComments && declaration.kind === 139) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -38049,13 +38593,13 @@ var ts; } }); } - if (declaration.kind === 220 && declaration.body.kind === 220) { + if (declaration.kind === 221 && declaration.body.kind === 221) { return; } - while (declaration.kind === 220 && declaration.parent.kind === 220) { + while (declaration.kind === 221 && declaration.parent.kind === 221) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 213 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -38366,9 +38910,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 136) { + if (declaration.name.kind === 137) { var expr = declaration.name.expression; - if (expr.kind === 168) { + if (expr.kind === 169) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -38388,9 +38932,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 215: + case 216: + case 144: case 143: - case 142: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -38407,62 +38951,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 216: case 217: case 218: case 219: case 220: - case 223: - case 232: - case 228: - case 223: - case 225: - case 226: - case 145: - case 146: - case 155: - addDeclaration(node); - case 144: - case 195: - case 214: - case 163: - case 164: case 221: + case 224: + case 233: + case 229: + case 224: + case 226: + case 227: + case 146: + case 147: + case 156: + addDeclaration(node); + case 145: + case 196: + case 215: + case 164: + case 165: + case 222: ts.forEachChild(node, visit); break; - case 194: + case 195: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 138: + case 139: if (!(node.flags & 56)) { break; } - case 213: - case 165: + case 214: + case 166: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 249: + case 250: + case 142: case 141: - case 140: addDeclaration(node); break; - case 230: + case 231: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 224: + case 225: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226) { + if (importClause.namedBindings.kind === 227) { addDeclaration(importClause.namedBindings); } else { @@ -38598,6 +39142,9 @@ var ts; ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; return ClassificationTypeNames; }()); ts.ClassificationTypeNames = ClassificationTypeNames; @@ -38613,14 +39160,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 175) { + if (declaration.kind === 176) { return true; } - if (declaration.kind !== 213 && declaration.kind !== 215) { + if (declaration.kind !== 214 && declaration.kind !== 216) { return false; } - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 250 || parent_8.kind === 221) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + if (parent_9.kind === 251 || parent_9.kind === 222) { return false; } } @@ -38829,16 +39376,10 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames) { - return useCaseSensitivefileNames - ? (function (fileName) { return fileName; }) - : (function (fileName) { return fileName.toLowerCase(); }); - } - ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { if (currentDirectory === void 0) { currentDirectory = ""; } var buckets = {}; - var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); + var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + +"|" + settings.allowJs; } @@ -39151,7 +39692,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 209 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 210 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -39160,16 +39701,16 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 69 && - (node.parent.kind === 205 || node.parent.kind === 204) && + (node.parent.kind === 206 || node.parent.kind === 205) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 69 && - node.parent.kind === 209 && + node.parent.kind === 210 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 209; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 210; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -39180,25 +39721,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 135 && node.parent.right === node; + return node.parent.kind === 136 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 168 && node.parent.name === node; + return node && node.parent && node.parent.kind === 169 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 170 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 171 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 171 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 172 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 220 && node.parent.name === node; + return node.parent.kind === 221 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 69 && @@ -39206,22 +39747,22 @@ var ts; } function isNameOfPropertyAssignment(node) { return (node.kind === 69 || node.kind === 9 || node.kind === 8) && - (node.parent.kind === 247 || node.parent.kind === 248) && node.parent.name === node; + (node.parent.kind === 248 || node.parent.kind === 249) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 141: - case 140: - case 247: - case 249: - case 143: case 142: - case 145: + case 141: + case 248: + case 250: + case 144: + case 143: case 146: - case 220: + case 147: + case 221: return node.parent.name === node; - case 169: + case 170: return node.parent.argumentExpression === node; } } @@ -39259,7 +39800,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 70; i <= 134; i++) { + for (var i = 70; i <= 135; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -39274,17 +39815,17 @@ var ts; return undefined; } switch (node.kind) { - case 250: + case 251: + case 144: case 143: - case 142: - case 215: - case 175: - case 145: - case 146: case 216: + case 176: + case 146: + case 147: case 217: - case 219: + case 218: case 220: + case 221: return node; } } @@ -39292,38 +39833,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 220: return ScriptElementKind.moduleElement; - case 216: return ScriptElementKind.classElement; - case 217: return ScriptElementKind.interfaceElement; - case 218: return ScriptElementKind.typeElement; - case 219: return ScriptElementKind.enumElement; - case 213: + case 221: return ScriptElementKind.moduleElement; + case 217: return ScriptElementKind.classElement; + case 218: return ScriptElementKind.interfaceElement; + case 219: return ScriptElementKind.typeElement; + case 220: return ScriptElementKind.enumElement; + case 214: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 215: return ScriptElementKind.functionElement; - case 145: return ScriptElementKind.memberGetAccessorElement; - case 146: return ScriptElementKind.memberSetAccessorElement; + case 216: return ScriptElementKind.functionElement; + case 146: return ScriptElementKind.memberGetAccessorElement; + case 147: return ScriptElementKind.memberSetAccessorElement; + case 144: case 143: - case 142: return ScriptElementKind.memberFunctionElement; + case 142: case 141: - case 140: return ScriptElementKind.memberVariableElement; - case 149: return ScriptElementKind.indexSignatureElement; - case 148: return ScriptElementKind.constructSignatureElement; - case 147: return ScriptElementKind.callSignatureElement; - case 144: return ScriptElementKind.constructorImplementationElement; - case 137: return ScriptElementKind.typeParameterElement; - case 249: return ScriptElementKind.variableElement; - case 138: return (node.flags & 56) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 223: - case 228: - case 225: - case 232: + case 150: return ScriptElementKind.indexSignatureElement; + case 149: return ScriptElementKind.constructSignatureElement; + case 148: return ScriptElementKind.callSignatureElement; + case 145: return ScriptElementKind.constructorImplementationElement; + case 138: return ScriptElementKind.typeParameterElement; + case 250: return ScriptElementKind.variableElement; + case 139: return (node.flags & 56) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 224: + case 229: case 226: + case 233: + case 227: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -39360,7 +39901,7 @@ var ts; host.log(message); } } - var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -39552,9 +40093,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 271: - case 269: + case 272: case 270: + case 271: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -39589,13 +40130,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_9 = contextToken.parent, kind = contextToken.kind; + var parent_10 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_9.kind === 168) { + if (parent_10.kind === 169) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 135) { + else if (parent_10.kind === 136) { node = contextToken.parent.left; isRightOfDot = true; } @@ -39608,8 +40149,9 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 && contextToken.parent.kind === 239) { + else if (kind === 39 && contextToken.parent.kind === 240) { isStartingCloseTag = true; + location = contextToken; } } } @@ -39633,7 +40175,10 @@ var ts; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; - symbols = [typeChecker.getSymbolAtLocation(tagName)]; + var tagSymbol = typeChecker.getSymbolAtLocation(tagName); + if (!typeChecker.isUnknownSymbol(tagSymbol)) { + symbols = [tagSymbol]; + } isMemberCompletion = true; isNewIdentifierLocation = false; } @@ -39647,7 +40192,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 135 || node.kind === 168) { + if (node.kind === 69 || node.kind === 136 || node.kind === 169) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -39693,7 +40238,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 236) || (jsxContainer.kind === 237)) { + if ((jsxContainer.kind === 237) || (jsxContainer.kind === 238)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -39733,15 +40278,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 238) { + if (contextToken.kind === 239) { return true; } if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 237) { + if (contextToken.parent.kind === 238) { return true; } - if (contextToken.parent.kind === 239 || contextToken.parent.kind === 236) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 235; + if (contextToken.parent.kind === 240 || contextToken.parent.kind === 237) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 236; } } return false; @@ -39751,40 +40296,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24: - return containingNodeKind === 170 - || containingNodeKind === 144 - || containingNodeKind === 171 - || containingNodeKind === 166 - || containingNodeKind === 183 - || containingNodeKind === 152; + return containingNodeKind === 171 + || containingNodeKind === 145 + || containingNodeKind === 172 + || containingNodeKind === 167 + || containingNodeKind === 184 + || containingNodeKind === 153; case 17: - return containingNodeKind === 170 - || containingNodeKind === 144 - || containingNodeKind === 171 - || containingNodeKind === 174 - || containingNodeKind === 160; + return containingNodeKind === 171 + || containingNodeKind === 145 + || containingNodeKind === 172 + || containingNodeKind === 175 + || containingNodeKind === 161; case 19: - return containingNodeKind === 166 - || containingNodeKind === 149 - || containingNodeKind === 136; + return containingNodeKind === 167 + || containingNodeKind === 150 + || containingNodeKind === 137; case 125: case 126: return true; case 21: - return containingNodeKind === 220; + return containingNodeKind === 221; case 15: - return containingNodeKind === 216; + return containingNodeKind === 217; case 56: - return containingNodeKind === 213 - || containingNodeKind === 183; + return containingNodeKind === 214 + || containingNodeKind === 184; case 12: - return containingNodeKind === 185; + return containingNodeKind === 186; case 13: - return containingNodeKind === 192; + return containingNodeKind === 193; case 112: case 110: case 111: - return containingNodeKind === 141; + return containingNodeKind === 142; } switch (previousToken.getText()) { case "public": @@ -39797,7 +40342,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 162 + || contextToken.kind === 163 || contextToken.kind === 10 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_7 = contextToken.getStart(); @@ -39816,12 +40361,12 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 167) { + if (objectLikeContainer.kind === 168) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 163) { + else if (objectLikeContainer.kind === 164) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { @@ -39847,9 +40392,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 227 ? - 224 : - 230; + var declarationKind = namedImportsOrExports.kind === 228 ? + 225 : + 231; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -39870,9 +40415,9 @@ var ts; switch (contextToken.kind) { case 15: case 24: - var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 167 || parent_10.kind === 163)) { - return parent_10; + var parent_11 = contextToken.parent; + if (parent_11 && (parent_11.kind === 168 || parent_11.kind === 164)) { + return parent_11; } break; } @@ -39885,8 +40430,8 @@ var ts; case 15: case 24: switch (contextToken.parent.kind) { - case 227: - case 231: + case 228: + case 232: return contextToken.parent; } } @@ -39895,34 +40440,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_11 = contextToken.parent; + var parent_12 = contextToken.parent; switch (contextToken.kind) { case 26: case 39: case 69: - case 240: case 241: - if (parent_11 && (parent_11.kind === 236 || parent_11.kind === 237)) { - return parent_11; + case 242: + if (parent_12 && (parent_12.kind === 237 || parent_12.kind === 238)) { + return parent_12; } - else if (parent_11.kind === 240) { - return parent_11.parent; + else if (parent_12.kind === 241) { + return parent_12.parent; } break; case 9: - if (parent_11 && ((parent_11.kind === 240) || (parent_11.kind === 241))) { - return parent_11.parent; + if (parent_12 && ((parent_12.kind === 241) || (parent_12.kind === 242))) { + return parent_12.parent; } break; case 16: - if (parent_11 && - parent_11.kind === 242 && - parent_11.parent && - (parent_11.parent.kind === 240)) { - return parent_11.parent.parent; + if (parent_12 && + parent_12.kind === 243 && + parent_12.parent && + (parent_12.parent.kind === 241)) { + return parent_12.parent.parent; } - if (parent_11 && parent_11.kind === 241) { - return parent_11.parent; + if (parent_12 && parent_12.kind === 242) { + return parent_12.parent; } break; } @@ -39931,16 +40476,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 175: case 176: - case 215: + case 177: + case 216: + case 144: case 143: - case 142: - case 145: case 146: case 147: case 148: case 149: + case 150: return true; } return false; @@ -39949,54 +40494,54 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24: - return containingNodeKind === 213 || - containingNodeKind === 214 || - containingNodeKind === 195 || - containingNodeKind === 219 || + return containingNodeKind === 214 || + containingNodeKind === 215 || + containingNodeKind === 196 || + containingNodeKind === 220 || isFunction(containingNodeKind) || - containingNodeKind === 216 || - containingNodeKind === 188 || containingNodeKind === 217 || - containingNodeKind === 164 || - containingNodeKind === 218; + containingNodeKind === 189 || + containingNodeKind === 218 || + containingNodeKind === 165 || + containingNodeKind === 219; case 21: - return containingNodeKind === 164; - case 54: return containingNodeKind === 165; + case 54: + return containingNodeKind === 166; case 19: - return containingNodeKind === 164; + return containingNodeKind === 165; case 17: - return containingNodeKind === 246 || + return containingNodeKind === 247 || isFunction(containingNodeKind); case 15: - return containingNodeKind === 219 || - containingNodeKind === 217 || - containingNodeKind === 155; - case 23: - return containingNodeKind === 140 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 217 || - contextToken.parent.parent.kind === 155); - case 25: - return containingNodeKind === 216 || - containingNodeKind === 188 || - containingNodeKind === 217 || + return containingNodeKind === 220 || containingNodeKind === 218 || + containingNodeKind === 156; + case 23: + return containingNodeKind === 141 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 218 || + contextToken.parent.parent.kind === 156); + case 25: + return containingNodeKind === 217 || + containingNodeKind === 189 || + containingNodeKind === 218 || + containingNodeKind === 219 || isFunction(containingNodeKind); case 113: - return containingNodeKind === 141; + return containingNodeKind === 142; case 22: - return containingNodeKind === 138 || + return containingNodeKind === 139 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 164); + contextToken.parent.parent.kind === 165); case 112: case 110: case 111: - return containingNodeKind === 138; + return containingNodeKind === 139; case 116: - return containingNodeKind === 228 || - containingNodeKind === 232 || - containingNodeKind === 226; + return containingNodeKind === 229 || + containingNodeKind === 233 || + containingNodeKind === 227; case 73: case 81: case 107: @@ -40045,8 +40590,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_34 = element.propertyName || element.name; + exisingImportsOrExports[name_34.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -40060,17 +40605,17 @@ var ts; var existingMemberNames = {}; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 247 && - m.kind !== 248 && - m.kind !== 165 && - m.kind !== 143) { + if (m.kind !== 248 && + m.kind !== 249 && + m.kind !== 166 && + m.kind !== 144) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 165 && m.propertyName) { + if (m.kind === 166 && m.propertyName) { if (m.propertyName.kind === 69) { existingName = m.propertyName.text; } @@ -40089,7 +40634,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 240) { + if (attr.kind === 241) { seenNames[attr.name.text] = true; } } @@ -40114,7 +40659,19 @@ var ts; } else { if (!symbols || symbols.length === 0) { - return undefined; + if (sourceFile.languageVariant === 1 && + location.parent && location.parent.kind === 240) { + var tagName = location.parent.parent.openingElement.tagName; + entries.push({ + name: tagName.text, + kind: undefined, + kindModifiers: undefined, + sortText: "0" + }); + } + else { + return undefined; + } } getCompletionEntriesFromSymbols(symbols, entries); } @@ -40126,10 +40683,10 @@ var ts; var entries = []; var target = program.getCompilerOptions().target; var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!uniqueNames[name_32]) { - uniqueNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + for (var name_35 in nameTable) { + if (!uniqueNames[name_35]) { + uniqueNames[name_35] = name_35; + var displayName = getCompletionEntryDisplayName(name_35, target, true); if (displayName) { var entry = { name: displayName, @@ -40218,7 +40775,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 188) ? + return ts.getDeclarationOfKind(symbol, 189) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -40314,14 +40871,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 168) { + if (location.parent && location.parent.kind === 169) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 170 || location.kind === 171) { + if (location.kind === 171 || location.kind === 172) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -40333,7 +40890,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 171 || callExpression.expression.kind === 95; + var useConstructSignatures = callExpression.kind === 172 || callExpression.expression.kind === 95; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -40381,21 +40938,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 144)) { + (location.kind === 121 && location.parent.kind === 145)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 144 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 145 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 144) { + if (functionDeclaration.kind === 145) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -40404,7 +40961,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 188)) { + if (ts.getDeclarationOfKind(symbol, 189)) { pushTypePart(ScriptElementKind.localClassElement); } else { @@ -40444,7 +41001,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 220); + var declaration = ts.getDeclarationOfKind(symbol, 221); var isNamespace = declaration && declaration.name && declaration.name.kind === 69; displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); displayParts.push(ts.spacePart()); @@ -40465,17 +41022,17 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 137); + var declaration = ts.getDeclarationOfKind(symbol, 138); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 148) { + if (declaration.kind === 149) { displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 147 && declaration.name) { + else if (declaration.kind !== 148 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); @@ -40492,7 +41049,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 249) { + if (declaration.kind === 250) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -40508,7 +41065,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 223) { + if (declaration.kind === 224) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -40635,13 +41192,13 @@ var ts; } var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { + if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 69: - case 168: - case 135: + case 169: + case 136: case 97: - case 161: + case 162: case 95: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -40714,8 +41271,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 144) || - (!selectConstructors && (d.kind === 215 || d.kind === 143 || d.kind === 142))) { + if ((selectConstructors && d.kind === 145) || + (!selectConstructors && (d.kind === 216 || d.kind === 144 || d.kind === 143))) { declarations.push(d); if (d.body) definition = d; @@ -40770,7 +41327,7 @@ var ts; symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 248) { + if (node.parent.kind === 249) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -40843,7 +41400,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 69 || node.kind === 97 || - node.kind === 161 || + node.kind === 162 || node.kind === 95 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -40895,75 +41452,75 @@ var ts; switch (node.kind) { case 88: case 80: - if (hasKind(node.parent, 198)) { + if (hasKind(node.parent, 199)) { return getIfElseOccurrences(node.parent); } break; case 94: - if (hasKind(node.parent, 206)) { + if (hasKind(node.parent, 207)) { return getReturnOccurrences(node.parent); } break; case 98: - if (hasKind(node.parent, 210)) { + if (hasKind(node.parent, 211)) { return getThrowOccurrences(node.parent); } break; case 72: - if (hasKind(parent(parent(node)), 211)) { + if (hasKind(parent(parent(node)), 212)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 100: case 85: - if (hasKind(parent(node), 211)) { + if (hasKind(parent(node), 212)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 96: - if (hasKind(node.parent, 208)) { + if (hasKind(node.parent, 209)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 71: case 77: - if (hasKind(parent(parent(parent(node))), 208)) { + if (hasKind(parent(parent(parent(node))), 209)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 70: case 75: - if (hasKind(node.parent, 205) || hasKind(node.parent, 204)) { + if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 86: - if (hasKind(node.parent, 201) || - hasKind(node.parent, 202) || - hasKind(node.parent, 203)) { + if (hasKind(node.parent, 202) || + hasKind(node.parent, 203) || + hasKind(node.parent, 204)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 104: case 79: - if (hasKind(node.parent, 200) || hasKind(node.parent, 199)) { + if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 121: - if (hasKind(node.parent, 144)) { + if (hasKind(node.parent, 145)) { return getConstructorOccurrences(node.parent); } break; case 123: case 129: - if (hasKind(node.parent, 145) || hasKind(node.parent, 146)) { + if (hasKind(node.parent, 146) || hasKind(node.parent, 147)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 195)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 196)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -40975,10 +41532,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210) { + if (node.kind === 211) { statementAccumulator.push(node); } - else if (node.kind === 211) { + else if (node.kind === 212) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -40998,17 +41555,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 250) { - return parent_12; + var parent_13 = child.parent; + if (ts.isFunctionBlock(parent_13) || parent_13.kind === 251) { + return parent_13; } - if (parent_12.kind === 211) { - var tryStatement = parent_12; + if (parent_13.kind === 212) { + var tryStatement = parent_13; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_12; + child = parent_13; } return undefined; } @@ -41017,7 +41574,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 || node.kind === 204) { + if (node.kind === 206 || node.kind === 205) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -41032,15 +41589,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 208: - if (statement.kind === 204) { + case 209: + if (statement.kind === 205) { continue; } - case 201: case 202: case 203: + case 204: + case 201: case 200: - case 199: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -41057,24 +41614,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 216 || - container.kind === 188 || - (declaration.kind === 138 && hasKind(container, 144)))) { + if (!(container.kind === 217 || + container.kind === 189 || + (declaration.kind === 139 && hasKind(container, 145)))) { return undefined; } } else if (modifier === 113) { - if (!(container.kind === 216 || container.kind === 188)) { + if (!(container.kind === 217 || container.kind === 189)) { return undefined; } } else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 221 || container.kind === 250)) { + if (!(container.kind === 222 || container.kind === 251)) { return undefined; } } else if (modifier === 115) { - if (!(container.kind === 216 || declaration.kind === 216)) { + if (!(container.kind === 217 || declaration.kind === 217)) { return undefined; } } @@ -41085,8 +41642,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 221: - case 250: + case 222: + case 251: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -41094,15 +41651,15 @@ var ts; nodes = container.statements; } break; - case 144: + case 145: nodes = container.parameters.concat(container.parent.members); break; - case 216: - case 188: + case 217: + case 189: nodes = container.members; if (modifierFlag & 56) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 144 && member; + return member.kind === 145 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -41155,8 +41712,8 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 145); tryPushAccessorKeyword(accessorDeclaration.symbol, 146); + tryPushAccessorKeyword(accessorDeclaration.symbol, 147); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); @@ -41178,7 +41735,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 199) { + if (loopNode.kind === 200) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 104)) { @@ -41199,13 +41756,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 201: case 202: case 203: - case 199: + case 204: case 200: + case 201: return getLoopBreakContinueOccurrences(owner); - case 208: + case 209: return getSwitchCaseDefaultOccurrences(owner); } } @@ -41255,7 +41812,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 194))) { + if (!(func && hasKind(func.body, 195))) { return undefined; } var keywords = []; @@ -41269,7 +41826,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 198) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 199) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -41280,7 +41837,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 198)) { + if (!hasKind(ifStatement.elseStatement, 199)) { break; } ifStatement = ifStatement.elseStatement; @@ -41384,7 +41941,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 || node.kind === 161) { + if (node.kind === 97 || node.kind === 162) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95) { @@ -41436,10 +41993,8 @@ var ts; textSpan: ts.createTextSpan(declarations[0].getStart(), 0) }; } - function isImportOrExportSpecifierImportSymbol(symbol) { - return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 228 || declaration.kind === 232; - }); + function isImportSpecifierSymbol(symbol) { + return (symbol.flags & 8388608) && !!ts.getDeclarationOfKind(symbol, 229); } function getInternedName(symbol, location, declarations) { if (ts.isImportOrExportSpecifierName(location)) { @@ -41451,13 +42006,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 175 || valueDeclaration.kind === 188)) { + if (valueDeclaration && (valueDeclaration.kind === 176 || valueDeclaration.kind === 189)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 216); + return ts.getAncestor(privateDeclaration, 217); } } if (symbol.flags & 8388608) { @@ -41478,7 +42033,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 250 && !ts.isExternalModule(container)) { + if (container.kind === 251 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -41625,13 +42180,13 @@ var ts; } var staticFlag = 64; switch (searchSpaceNode.kind) { - case 141: - case 140: - case 143: case 142: + case 141: case 144: + case 143: case 145: case 146: + case 147: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -41659,32 +42214,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 64; switch (searchSpaceNode.kind) { + case 144: case 143: - case 142: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 142: case 141: - case 140: - case 144: case 145: case 146: + case 147: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 250: + case 251: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 215: - case 175: + case 216: + case 176: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 250) { + if (searchSpaceNode.kind === 251) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -41710,31 +42265,31 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 && node.kind !== 161)) { + if (!node || (node.kind !== 97 && node.kind !== 162)) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 175: - case 215: + case 176: + case 216: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 144: case 143: - case 142: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 188: - case 216: + case 189: + case 217: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 250: - if (container.kind === 250 && !ts.isExternalModule(container)) { + case 251: + if (container.kind === 251 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -41744,9 +42299,12 @@ var ts; } function populateSearchSymbolSet(symbol, location) { var result = [symbol]; - if (isImportOrExportSpecifierImportSymbol(symbol)) { + if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } + if (location.parent.kind === 233) { + result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent)); + } if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); @@ -41756,7 +42314,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 138 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -41765,19 +42323,25 @@ var ts; result.push(rootSymbol); } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, {}); } }); return result; } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol && symbol.flags & (32 | 64)) { + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { + if (!symbol) { + return; + } + if (ts.hasProperty(previousIterationSymbolsCache, symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 216) { + if (declaration.kind === 217) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 217) { + else if (declaration.kind === 218) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -41791,7 +42355,8 @@ var ts; if (propertySymbol) { result.push(propertySymbol); } - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); + previousIterationSymbolsCache[symbol.name] = symbol; + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); } } } @@ -41800,12 +42365,18 @@ var ts; if (searchSymbols.indexOf(referenceSymbol) >= 0) { return referenceSymbol; } - if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + if (isImportSpecifierSymbol(referenceSymbol)) { var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; } } + if (referenceLocation.parent.kind === 233) { + var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } + } if (isNameOfPropertyAssignment(referenceLocation)) { return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); @@ -41817,7 +42388,7 @@ var ts; } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, {}); return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; @@ -41827,17 +42398,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_36 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_36); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_36); if (symbol) { result_4.push(symbol); } @@ -41846,7 +42417,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_36); if (symbol_1) { return [symbol_1]; } @@ -41891,10 +42462,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 182 || parent.kind === 181) { + if (parent.kind === 183 || parent.kind === 182) { return true; } - else if (parent.kind === 183 && parent.left === node) { + else if (parent.kind === 184 && parent.left === node) { var operator = parent.operatorToken.kind; return 56 <= operator && operator <= 68; } @@ -41924,34 +42495,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 138: - case 213: - case 165: + case 139: + case 214: + case 166: + case 142: case 141: - case 140: - case 247: case 248: case 249: - case 143: - case 142: + case 250: case 144: + case 143: case 145: case 146: - case 215: - case 175: - case 176: - case 246: - return 1; - case 137: - case 217: - case 218: - case 155: - return 2; + case 147: case 216: + case 176: + case 177: + case 247: + return 1; + case 138: + case 218: case 219: - return 1 | 2; + case 156: + return 2; + case 217: case 220: - if (node.name.kind === 9) { + return 1 | 2; + case 221: + if (ts.isAmbientModule(node)) { return 4 | 1; } else if (ts.getModuleInstanceState(node) === 1) { @@ -41960,14 +42531,14 @@ var ts; else { return 4; } - case 227: case 228: - case 223: - case 224: case 229: + case 224: + case 225: case 230: + case 231: return 1 | 2 | 4; - case 250: + case 251: return 4 | 1; } return 1 | 2 | 4; @@ -41976,10 +42547,10 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 151 || - (node.parent.kind === 190 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 152 || + (node.parent.kind === 191 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 97 && !ts.isExpression(node)) || - node.kind === 161; + node.kind === 162; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -41987,47 +42558,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 168) { - while (root.parent && root.parent.kind === 168) { + if (root.parent.kind === 169) { + while (root.parent && root.parent.kind === 169) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 190 && root.parent.parent.kind === 245) { + if (!isLastClause && root.parent.kind === 191 && root.parent.parent.kind === 246) { var decl = root.parent.parent.parent; - return (decl.kind === 216 && root.parent.parent.token === 106) || - (decl.kind === 217 && root.parent.parent.token === 83); + return (decl.kind === 217 && root.parent.parent.token === 106) || + (decl.kind === 218 && root.parent.parent.token === 83); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 135) { - while (root.parent && root.parent.kind === 135) { + if (root.parent.kind === 136) { + while (root.parent && root.parent.kind === 136) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 151 && !isLastClause; + return root.parent.kind === 152 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 135) { + while (node.parent.kind === 136) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 135 && + if (node.parent.kind === 136 && node.parent.right === node && - node.parent.parent.kind === 223) { + node.parent.parent.kind === 224) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 229) { + if (node.parent.kind === 230) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -42061,16 +42632,16 @@ var ts; return; } switch (node.kind) { - case 168: - case 135: + case 169: + case 136: case 9: - case 162: + case 163: case 84: case 99: case 93: case 95: case 97: - case 161: + case 162: case 69: break; default: @@ -42082,7 +42653,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 220 && + if (nodeForStartPos.parent.parent.kind === 221 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -42109,10 +42680,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 220: - case 216: + case 221: case 217: - case 215: + case 218: + case 216: cancellationToken.throwIfCancellationRequested(); } } @@ -42160,7 +42731,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 220 && + return declaration.kind === 221 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -42207,6 +42778,9 @@ var ts; case 19: return ClassificationTypeNames.jsxOpenTagName; case 20: return ClassificationTypeNames.jsxCloseTagName; case 21: return ClassificationTypeNames.jsxSelfClosingTagName; + case 22: return ClassificationTypeNames.jsxAttribute; + case 23: return ClassificationTypeNames.jsxText; + case 24: return ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -42296,16 +42870,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 269: + case 270: processJSDocParameterTag(tag); break; - case 272: + case 273: processJSDocTemplateTag(tag); break; - case 271: + case 272: processElement(tag.typeExpression); break; - case 270: + case 271: processElement(tag.typeExpression); break; } @@ -42340,7 +42914,8 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - for (var i = start; i < end; i++) { + var i; + for (i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { break; } @@ -42360,11 +42935,11 @@ var ts; pushClassification(start, end - start, type); } } - function classifyToken(token) { + function classifyTokenOrJsxText(token) { if (ts.nodeIsMissing(token)) { return; } - var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenStart = token.kind === 239 ? token.pos : classifyLeadingTriviaAndGetTokenStart(token); var tokenWidth = token.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -42386,16 +42961,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 56) { - if (token.parent.kind === 213 || - token.parent.kind === 141 || - token.parent.kind === 138) { + if (token.parent.kind === 214 || + token.parent.kind === 142 || + token.parent.kind === 139 || + token.parent.kind === 241) { return 5; } } - if (token.parent.kind === 183 || - token.parent.kind === 181 || + if (token.parent.kind === 184 || token.parent.kind === 182 || - token.parent.kind === 184) { + token.parent.kind === 183 || + token.parent.kind === 185) { return 5; } } @@ -42404,8 +42980,8 @@ var ts; else if (tokenKind === 8) { return 4; } - else if (tokenKind === 9 || tokenKind === 162) { - return 6; + else if (tokenKind === 9 || tokenKind === 163) { + return token.parent.kind === 241 ? 24 : 6; } else if (tokenKind === 10) { return 6; @@ -42413,54 +42989,61 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } + else if (tokenKind === 239) { + return 23; + } else if (tokenKind === 69) { if (token) { switch (token.parent.kind) { - case 216: + case 217: if (token.parent.name === token) { return 11; } return; - case 137: + case 138: if (token.parent.name === token) { return 15; } return; - case 217: + case 218: if (token.parent.name === token) { return 13; } return; - case 219: + case 220: if (token.parent.name === token) { return 12; } return; - case 220: + case 221: if (token.parent.name === token) { return 14; } return; - case 138: + case 139: if (token.parent.name === token) { return 17; } return; - case 237: + case 238: if (token.parent.tagName === token) { return 19; } return; - case 239: + case 240: if (token.parent.tagName === token) { return 20; } return; - case 236: + case 237: if (token.parent.tagName === token) { return 21; } return; + case 241: + if (token.parent.name === token) { + return 22; + } } } return 2; @@ -42475,8 +43058,8 @@ var ts; var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; - if (ts.isToken(child)) { - classifyToken(child); + if (ts.isToken(child) || child.kind === 239) { + classifyTokenOrJsxText(child); } else { processElement(child); @@ -42572,16 +43155,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 215: - case 143: - case 144: case 216: - case 195: + case 144: + case 145: + case 217: + case 196: break findOwner; - case 250: + case 251: return undefined; - case 220: - if (commentOwner.parent.kind === 220) { + case 221: + if (commentOwner.parent.kind === 221) { return undefined; } break findOwner; @@ -42615,7 +43198,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 195) { + if (commentOwner.kind === 196) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -42625,17 +43208,17 @@ var ts; return emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 174) { + while (rightHandSide.kind === 175) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 175: case 176: + case 177: return rightHandSide.parameters; - case 188: + case 189: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 144) { + if (member.kind === 145) { return member.parameters; } } @@ -42815,7 +43398,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 234 || + node.parent.kind === 235 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -42828,7 +43411,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 169 && + node.parent.kind === 170 && node.parent.argumentExpression === node; } function createClassifier() { @@ -43010,7 +43593,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 9 || token === 162) { + if (token === 9 || token === 163) { var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; @@ -43124,7 +43707,7 @@ var ts; } } function isKeyword(token) { - return token >= 70 && token <= 134; + return token >= 70 && token <= 135; } function classFromKind(token) { if (isKeyword(token)) { @@ -43140,7 +43723,7 @@ var ts; case 8: return 4; case 9: - case 162: + case 163: return 6; case 10: return 7; @@ -44241,8 +44824,8 @@ var ts; var newResolutions = {}; var resolvedModules = []; var compilerOptions = this.getCompilationSettings(); - for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { - var moduleName = moduleNames_1[_i]; + for (var _i = 0, moduleNames_2 = moduleNames; _i < moduleNames_2.length; _i++) { + var moduleName = moduleNames_2[_i]; var resolution = ts.lookUp(newResolutions, moduleName); if (!resolution) { var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); @@ -44913,7 +45496,7 @@ var ts; info.setFormatOptions(this.getFormatCodeOptions()); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { - info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); }); + info.fileWatcher = this.host.watchFile(ts.toPath(fileName, fileName, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), function (_) { _this.watchedFileChanged(fileName); }); } } } @@ -45095,7 +45678,7 @@ var ts; } } project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(project); }); + project.projectFileWatcher = this.host.watchFile(ts.toPath(configFilename, configFilename, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), function (_) { return _this.watchedProjectConfigFileChanged(project); }); this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename)); project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(configFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); return { success: true, project: project }; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 3196ae2199f..412f4e793b0 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -167,161 +167,162 @@ declare namespace ts { SymbolKeyword = 131, TypeKeyword = 132, FromKeyword = 133, - OfKeyword = 134, - QualifiedName = 135, - ComputedPropertyName = 136, - TypeParameter = 137, - Parameter = 138, - Decorator = 139, - PropertySignature = 140, - PropertyDeclaration = 141, - MethodSignature = 142, - MethodDeclaration = 143, - Constructor = 144, - GetAccessor = 145, - SetAccessor = 146, - CallSignature = 147, - ConstructSignature = 148, - IndexSignature = 149, - TypePredicate = 150, - TypeReference = 151, - FunctionType = 152, - ConstructorType = 153, - TypeQuery = 154, - TypeLiteral = 155, - ArrayType = 156, - TupleType = 157, - UnionType = 158, - IntersectionType = 159, - ParenthesizedType = 160, - ThisType = 161, - StringLiteralType = 162, - ObjectBindingPattern = 163, - ArrayBindingPattern = 164, - BindingElement = 165, - ArrayLiteralExpression = 166, - ObjectLiteralExpression = 167, - PropertyAccessExpression = 168, - ElementAccessExpression = 169, - CallExpression = 170, - NewExpression = 171, - TaggedTemplateExpression = 172, - TypeAssertionExpression = 173, - ParenthesizedExpression = 174, - FunctionExpression = 175, - ArrowFunction = 176, - DeleteExpression = 177, - TypeOfExpression = 178, - VoidExpression = 179, - AwaitExpression = 180, - PrefixUnaryExpression = 181, - PostfixUnaryExpression = 182, - BinaryExpression = 183, - ConditionalExpression = 184, - TemplateExpression = 185, - YieldExpression = 186, - SpreadElementExpression = 187, - ClassExpression = 188, - OmittedExpression = 189, - ExpressionWithTypeArguments = 190, - AsExpression = 191, - TemplateSpan = 192, - SemicolonClassElement = 193, - Block = 194, - VariableStatement = 195, - EmptyStatement = 196, - ExpressionStatement = 197, - IfStatement = 198, - DoStatement = 199, - WhileStatement = 200, - ForStatement = 201, - ForInStatement = 202, - ForOfStatement = 203, - ContinueStatement = 204, - BreakStatement = 205, - ReturnStatement = 206, - WithStatement = 207, - SwitchStatement = 208, - LabeledStatement = 209, - ThrowStatement = 210, - TryStatement = 211, - DebuggerStatement = 212, - VariableDeclaration = 213, - VariableDeclarationList = 214, - FunctionDeclaration = 215, - ClassDeclaration = 216, - InterfaceDeclaration = 217, - TypeAliasDeclaration = 218, - EnumDeclaration = 219, - ModuleDeclaration = 220, - ModuleBlock = 221, - CaseBlock = 222, - ImportEqualsDeclaration = 223, - ImportDeclaration = 224, - ImportClause = 225, - NamespaceImport = 226, - NamedImports = 227, - ImportSpecifier = 228, - ExportAssignment = 229, - ExportDeclaration = 230, - NamedExports = 231, - ExportSpecifier = 232, - MissingDeclaration = 233, - ExternalModuleReference = 234, - JsxElement = 235, - JsxSelfClosingElement = 236, - JsxOpeningElement = 237, - JsxText = 238, - JsxClosingElement = 239, - JsxAttribute = 240, - JsxSpreadAttribute = 241, - JsxExpression = 242, - CaseClause = 243, - DefaultClause = 244, - HeritageClause = 245, - CatchClause = 246, - PropertyAssignment = 247, - ShorthandPropertyAssignment = 248, - EnumMember = 249, - SourceFile = 250, - JSDocTypeExpression = 251, - JSDocAllType = 252, - JSDocUnknownType = 253, - JSDocArrayType = 254, - JSDocUnionType = 255, - JSDocTupleType = 256, - JSDocNullableType = 257, - JSDocNonNullableType = 258, - JSDocRecordType = 259, - JSDocRecordMember = 260, - JSDocTypeReference = 261, - JSDocOptionalType = 262, - JSDocFunctionType = 263, - JSDocVariadicType = 264, - JSDocConstructorType = 265, - JSDocThisType = 266, - JSDocComment = 267, - JSDocTag = 268, - JSDocParameterTag = 269, - JSDocReturnTag = 270, - JSDocTypeTag = 271, - JSDocTemplateTag = 272, - SyntaxList = 273, - Count = 274, + GlobalKeyword = 134, + OfKeyword = 135, + QualifiedName = 136, + ComputedPropertyName = 137, + TypeParameter = 138, + Parameter = 139, + Decorator = 140, + PropertySignature = 141, + PropertyDeclaration = 142, + MethodSignature = 143, + MethodDeclaration = 144, + Constructor = 145, + GetAccessor = 146, + SetAccessor = 147, + CallSignature = 148, + ConstructSignature = 149, + IndexSignature = 150, + TypePredicate = 151, + TypeReference = 152, + FunctionType = 153, + ConstructorType = 154, + TypeQuery = 155, + TypeLiteral = 156, + ArrayType = 157, + TupleType = 158, + UnionType = 159, + IntersectionType = 160, + ParenthesizedType = 161, + ThisType = 162, + StringLiteralType = 163, + ObjectBindingPattern = 164, + ArrayBindingPattern = 165, + BindingElement = 166, + ArrayLiteralExpression = 167, + ObjectLiteralExpression = 168, + PropertyAccessExpression = 169, + ElementAccessExpression = 170, + CallExpression = 171, + NewExpression = 172, + TaggedTemplateExpression = 173, + TypeAssertionExpression = 174, + ParenthesizedExpression = 175, + FunctionExpression = 176, + ArrowFunction = 177, + DeleteExpression = 178, + TypeOfExpression = 179, + VoidExpression = 180, + AwaitExpression = 181, + PrefixUnaryExpression = 182, + PostfixUnaryExpression = 183, + BinaryExpression = 184, + ConditionalExpression = 185, + TemplateExpression = 186, + YieldExpression = 187, + SpreadElementExpression = 188, + ClassExpression = 189, + OmittedExpression = 190, + ExpressionWithTypeArguments = 191, + AsExpression = 192, + TemplateSpan = 193, + SemicolonClassElement = 194, + Block = 195, + VariableStatement = 196, + EmptyStatement = 197, + ExpressionStatement = 198, + IfStatement = 199, + DoStatement = 200, + WhileStatement = 201, + ForStatement = 202, + ForInStatement = 203, + ForOfStatement = 204, + ContinueStatement = 205, + BreakStatement = 206, + ReturnStatement = 207, + WithStatement = 208, + SwitchStatement = 209, + LabeledStatement = 210, + ThrowStatement = 211, + TryStatement = 212, + DebuggerStatement = 213, + VariableDeclaration = 214, + VariableDeclarationList = 215, + FunctionDeclaration = 216, + ClassDeclaration = 217, + InterfaceDeclaration = 218, + TypeAliasDeclaration = 219, + EnumDeclaration = 220, + ModuleDeclaration = 221, + ModuleBlock = 222, + CaseBlock = 223, + ImportEqualsDeclaration = 224, + ImportDeclaration = 225, + ImportClause = 226, + NamespaceImport = 227, + NamedImports = 228, + ImportSpecifier = 229, + ExportAssignment = 230, + ExportDeclaration = 231, + NamedExports = 232, + ExportSpecifier = 233, + MissingDeclaration = 234, + ExternalModuleReference = 235, + JsxElement = 236, + JsxSelfClosingElement = 237, + JsxOpeningElement = 238, + JsxText = 239, + JsxClosingElement = 240, + JsxAttribute = 241, + JsxSpreadAttribute = 242, + JsxExpression = 243, + CaseClause = 244, + DefaultClause = 245, + HeritageClause = 246, + CatchClause = 247, + PropertyAssignment = 248, + ShorthandPropertyAssignment = 249, + EnumMember = 250, + SourceFile = 251, + JSDocTypeExpression = 252, + JSDocAllType = 253, + JSDocUnknownType = 254, + JSDocArrayType = 255, + JSDocUnionType = 256, + JSDocTupleType = 257, + JSDocNullableType = 258, + JSDocNonNullableType = 259, + JSDocRecordType = 260, + JSDocRecordMember = 261, + JSDocTypeReference = 262, + JSDocOptionalType = 263, + JSDocFunctionType = 264, + JSDocVariadicType = 265, + JSDocConstructorType = 266, + JSDocThisType = 267, + JSDocComment = 268, + JSDocTag = 269, + JSDocParameterTag = 270, + JSDocReturnTag = 271, + JSDocTypeTag = 272, + JSDocTemplateTag = 273, + SyntaxList = 274, + Count = 275, FirstAssignment = 56, LastAssignment = 68, FirstReservedWord = 70, LastReservedWord = 105, FirstKeyword = 70, - LastKeyword = 134, + LastKeyword = 135, FirstFutureReservedWord = 106, LastFutureReservedWord = 114, - FirstTypeNode = 150, - LastTypeNode = 162, + FirstTypeNode = 151, + LastTypeNode = 163, FirstPunctuation = 15, LastPunctuation = 68, FirstToken = 0, - LastToken = 134, + LastToken = 135, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -330,7 +331,7 @@ declare namespace ts { LastTemplateToken = 14, FirstBinaryOperator = 25, LastBinaryOperator = 68, - FirstNode = 135, + FirstNode = 136, } enum NodeFlags { None = 0, @@ -354,10 +355,16 @@ declare namespace ts { ContainsThis = 262144, HasImplicitReturn = 524288, HasExplicitReturn = 1048576, + GlobalAugmentation = 2097152, + HasClassExtends = 4194304, + HasDecorators = 8388608, + HasParamDecorators = 16777216, + HasAsyncFunctions = 33554432, Modifier = 1022, AccessibilityModifier = 56, BlockScoped = 24576, ReachabilityCheckFlags = 1572864, + EmitHelperFlags = 62914560, } enum JsxFlags { None = 0, @@ -1141,6 +1148,7 @@ declare namespace ts { getSymbolAtLocation(node: Node): Symbol; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; getShorthandAssignmentValueSymbol(location: Node): Symbol; + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getTypeAtLocation(node: Node): Type; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; @@ -1154,6 +1162,7 @@ declare namespace ts { isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; + isUnknownSymbol(symbol: Symbol): boolean; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; @@ -1543,6 +1552,8 @@ declare namespace ts { } } declare namespace ts { + type FileWatcherCallback = (path: string, removed?: boolean) => void; + type DirectoryWatcherCallback = (path: string) => void; interface System { args: string[]; newLine: string; @@ -1550,8 +1561,8 @@ declare namespace ts { write(s: string): void; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; - watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher; + watchFile?(path: Path, callback: FileWatcherCallback): FileWatcher; + watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -1565,6 +1576,10 @@ declare namespace ts { interface FileWatcher { close(): void; } + interface DirectoryWatcher extends FileWatcher { + directoryPath: Path; + referenceCount: number; + } var sys: System; } declare namespace ts { @@ -2237,6 +2252,9 @@ declare namespace ts { static jsxOpenTagName: string; static jsxCloseTagName: string; static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } enum ClassificationType { comment = 1, @@ -2260,6 +2278,9 @@ declare namespace ts { jsxOpenTagName = 19, jsxCloseTagName = 20, jsxSelfClosingTagName = 21, + jsxAttribute = 22, + jsxText = 23, + jsxAttributeStringLiteralValue = 24, } interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; @@ -2283,7 +2304,6 @@ declare namespace ts { function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/lib/typescript.js b/lib/typescript.js index 6608f585b61..bbe9a4b07e3 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -163,182 +163,183 @@ var ts; SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 134] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 135] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 136] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 137] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 138] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 139] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 140] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 142] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 143] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 144] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 145] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 146] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 147] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 148] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 149] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 150] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 161] = "ThisType"; - SyntaxKind[SyntaxKind["StringLiteralType"] = 162] = "StringLiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 151] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 152] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 153] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 154] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 155] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 156] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 157] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 158] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 159] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 160] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 161] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 162] = "ThisType"; + SyntaxKind[SyntaxKind["StringLiteralType"] = 163] = "StringLiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 163] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 164] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 165] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 164] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 165] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 166] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 166] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 167] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 168] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 169] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 170] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 171] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 172] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 173] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 174] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 175] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 176] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 177] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 178] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 179] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 180] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 181] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 182] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 183] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 184] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 185] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 186] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 187] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 188] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 189] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 190] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 191] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 167] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 168] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 169] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 170] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 171] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 172] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 173] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 174] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 175] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 176] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 177] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 178] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 179] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 180] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 181] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 182] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 183] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 184] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 186] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 187] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 188] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 189] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 190] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 191] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 192] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 192] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 193] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 193] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 194] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 194] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 195] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 196] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 197] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 198] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 199] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 200] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 201] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 202] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 203] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 204] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 205] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 206] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 207] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 208] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 209] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 210] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 211] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 212] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 213] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 214] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 215] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 216] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 217] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 218] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 219] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 220] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 221] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 222] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 223] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 224] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 225] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 226] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 227] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 228] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 229] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 230] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 231] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 232] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 233] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 195] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 196] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 197] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 198] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 199] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 200] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 201] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 202] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 203] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 204] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 205] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 206] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 207] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 208] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 209] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 210] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 211] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 212] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 213] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 214] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 215] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 216] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 217] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 218] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 219] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 220] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 221] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 222] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 223] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 224] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 225] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 226] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 227] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 228] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 229] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 230] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 231] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 232] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 233] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 234] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 234] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 235] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 235] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 236] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 237] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 238] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 239] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 240] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 241] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 242] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 236] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 237] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 238] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 239] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 240] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 241] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 242] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 243] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 243] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 244] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 245] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 246] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 244] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 245] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 246] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 247] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 247] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 248] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 248] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 249] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 249] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 250] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 250] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 251] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 251] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 252] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 252] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 253] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 253] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 254] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 255] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 256] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 257] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 258] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 259] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 260] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 261] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 262] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 263] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 264] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 265] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 266] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 267] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 268] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 269] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 270] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 271] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 272] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 254] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 255] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 256] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 257] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 258] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 259] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 260] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 261] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 262] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 263] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 264] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 265] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 266] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 267] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 268] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 269] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 270] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 271] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 272] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 273] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 273] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 274] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 274] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 275] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 135] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 150] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 162] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 163] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 135] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -347,7 +348,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 136] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -372,10 +373,16 @@ var ts; NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 2097152] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 4194304] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 62914560] = "EmitHelperFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ @@ -584,11 +591,6 @@ var ts; NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; - NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; - NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; - NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -1532,7 +1534,8 @@ var ts; directoryComponents.length--; } // Find the component that differs - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + var joinStartIndex; + for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } @@ -1681,6 +1684,12 @@ var ts; return copiedList; } ts.copyListRemovingItem = copyListRemovingItem; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; })(ts || (ts = {})); /// var ts; @@ -1829,7 +1838,7 @@ var ts; var _os = require("os"); // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond - function createWatchedFileSet(interval, chunkSize) { + function createPollingWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } var watchedFiles = []; @@ -1843,13 +1852,13 @@ var ts; if (!watchedFile) { return; } - _fs.stat(watchedFile.fileName, function (err, stats) { + _fs.stat(watchedFile.filePath, function (err, stats) { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.filePath); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + watchedFile.mtime = getModifiedTime(watchedFile.filePath); + watchedFile.callback(watchedFile.filePath, watchedFile.mtime.getTime() === 0); } }); } @@ -1875,11 +1884,11 @@ var ts; nextFileToCheck = nextToCheck; }, interval); } - function addFile(fileName, callback) { + function addFile(filePath, callback) { var file = { - fileName: fileName, + filePath: filePath, callback: callback, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(filePath) }; watchedFiles.push(file); if (watchedFiles.length === 1) { @@ -1898,6 +1907,77 @@ var ts; removeFile: removeFile }; } + function createWatchedFileSet() { + var dirWatchers = ts.createFileMap(); + // One file can have multiple watchers + var fileWatcherCallbacks = ts.createFileMap(); + return { addFile: addFile, removeFile: removeFile }; + function reduceDirWatcherRefCountForFile(filePath) { + var dirPath = ts.getDirectoryPath(filePath); + if (dirWatchers.contains(dirPath)) { + var watcher = dirWatchers.get(dirPath); + watcher.referenceCount -= 1; + if (watcher.referenceCount <= 0) { + watcher.close(); + dirWatchers.remove(dirPath); + } + } + } + function addDirWatcher(dirPath) { + if (dirWatchers.contains(dirPath)) { + var watcher_1 = dirWatchers.get(dirPath); + watcher_1.referenceCount += 1; + return; + } + var watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher.referenceCount = 1; + dirWatchers.set(dirPath, watcher); + return; + } + function addFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + fileWatcherCallbacks.get(filePath).push(callback); + } + else { + fileWatcherCallbacks.set(filePath, [callback]); + } + } + function addFile(filePath, callback) { + addFileWatcherCallback(filePath, callback); + addDirWatcher(ts.getDirectoryPath(filePath)); + return { filePath: filePath, callback: callback }; + } + function removeFile(watchedFile) { + removeFileWatcherCallback(watchedFile.filePath, watchedFile.callback); + reduceDirWatcherRefCountForFile(watchedFile.filePath); + } + function removeFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + var newCallbacks = ts.copyListRemovingItem(callback, fileWatcherCallbacks.get(filePath)); + if (newCallbacks.length === 0) { + fileWatcherCallbacks.remove(filePath); + } + else { + fileWatcherCallbacks.set(filePath, newCallbacks); + } + } + } + /** + * @param watcherPath is the path from which the watcher is triggered. + */ + function fileEventHandler(eventName, relativeFileName, baseDirPath) { + // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" + var filePath = typeof relativeFileName !== "string" + ? undefined + : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); + if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { + var fileCallback = _a[_i]; + fileCallback(filePath); + } + } + } + } // REVIEW: for now this implementation uses polling. // The advantage of polling is that it works reliably // on all os and with network mounted files. @@ -1911,7 +1991,11 @@ var ts; // changes for large reference sets? If so, do we want // to increase the chunk size or decrease the interval // time dynamically to match the large reference set? + var pollingWatchedFileSet = createPollingWatchedFileSet(); var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1960,7 +2044,7 @@ var ts; } } function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; + return useCaseSensitiveFileNames ? path : path.toLowerCase(); } function readDirectory(path, extension, exclude) { var result = []; @@ -2000,20 +2084,28 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (filePath, callback) { // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 // and https://github.com/Microsoft/TypeScript/issues/4643), therefore // if the current node.js version is newer than 4, use `fs.watch` instead. - var watchedFile = watchedFileSet.addFile(fileName, callback); + var watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet; + var watchedFile = watchSet.addFile(filePath, callback); return { - close: function () { return watchedFileSet.removeFile(watchedFile); } + close: function () { return watchSet.removeFile(watchedFile); } }; }, watchDirectory: function (path, callback, recursive) { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + var options; + if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + options = { persistent: true, recursive: !!recursive }; + } + else { + options = { persistent: true }; + } + return _fs.watch(path, options, function (eventName, relativeFileName) { // In watchDirectory we only care about adding and removing files (when event name is // "rename"); changes made within files are handled by corresponding fileWatchers (when // event name is "change") @@ -2283,7 +2375,6 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -2519,7 +2610,6 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, - A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods: { code: 2519, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_r_2519", message: "A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, @@ -2548,6 +2638,16 @@ var ts; Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, + Cannot_re_export_name_that_is_not_defined_in_the_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_re_export_name_that_is_not_defined_in_the_module_2661", message: "Cannot re-export name that is not defined in the module." }, + 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." }, + Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope_2665", message: "Module augmentation cannot introduce new names in the top level scope." }, + 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." }, + Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, + Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, 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}'." }, @@ -2712,6 +2812,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, 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'." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, 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." }, 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." }, @@ -2810,6 +2911,7 @@ var ts; "protected": 111 /* ProtectedKeyword */, "public": 112 /* PublicKeyword */, "require": 127 /* RequireKeyword */, + "global": 134 /* GlobalKeyword */, "return": 94 /* ReturnKeyword */, "set": 129 /* SetKeyword */, "static": 113 /* StaticKeyword */, @@ -2830,7 +2932,7 @@ var ts; "yield": 114 /* YieldKeyword */, "async": 118 /* AsyncKeyword */, "await": 119 /* AwaitKeyword */, - "of": 134 /* OfKeyword */, + "of": 135 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -4246,7 +4348,7 @@ var ts; break; } } - return token = 238 /* JsxText */; + return token = 239 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -4429,7 +4531,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 250 /* SourceFile */) { + while (node && node.kind !== 251 /* SourceFile */) { node = node.parent; } return node; @@ -4532,6 +4634,31 @@ var ts; isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isAmbientModule(node) { + return node && node.kind === 221 /* ModuleDeclaration */ && + (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 2097152 /* GlobalAugmentation */); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + // external module augmentation is a ambient module declaration that is either: + // - defined in the top level scope and source file is an external module + // - defined inside ambient module declaration located in the top level scope and source file not an external module + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 251 /* SourceFile */: + return isExternalModule(node.parent); + case 222 /* ModuleBlock */: + return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { @@ -4541,15 +4668,15 @@ var ts; return current; } switch (current.kind) { - case 250 /* SourceFile */: - case 222 /* CaseBlock */: - case 246 /* CatchClause */: - case 220 /* ModuleDeclaration */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 251 /* SourceFile */: + case 223 /* CaseBlock */: + case 247 /* CatchClause */: + case 221 /* ModuleDeclaration */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: return current; - case 194 /* Block */: + case 195 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4562,9 +4689,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 213 /* VariableDeclaration */ && + declaration.kind === 214 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 246 /* CatchClause */; + declaration.parent.kind === 247 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4603,7 +4730,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 250 /* SourceFile */: + case 251 /* 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 @@ -4612,17 +4739,18 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 220 /* ModuleDeclaration */: - case 219 /* EnumDeclaration */: - case 249 /* EnumMember */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 220 /* EnumDeclaration */: + case 250 /* EnumMember */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 219 /* TypeAliasDeclaration */: errorNode = node.name; break; } @@ -4650,11 +4778,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 219 /* EnumDeclaration */ && isConst(node); + return node.kind === 220 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 165 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 166 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4669,14 +4797,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 213 /* VariableDeclaration */) { + if (node.kind === 214 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 214 /* VariableDeclarationList */) { + if (node && node.kind === 215 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 195 /* VariableStatement */) { + if (node && node.kind === 196 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4691,7 +4819,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 197 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 198 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4707,7 +4835,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? + var commentRanges = (node.kind === 139 /* Parameter */ || node.kind === 138 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -4722,7 +4850,7 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (150 /* FirstTypeNode */ <= node.kind && node.kind <= 162 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 163 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -4733,26 +4861,26 @@ var ts; case 131 /* SymbolKeyword */: return true; case 103 /* VoidKeyword */: - return node.parent.kind !== 179 /* VoidExpression */; - case 190 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 180 /* VoidExpression */; + case 191 /* 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 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 169 /* 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 === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 168 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135 /* QualifiedName */: - case 168 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 136 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 154 /* TypeQuery */) { + if (parent_1.kind === 155 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4761,38 +4889,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (150 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 162 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 163 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return node === parent_1.constraint; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 138 /* Parameter */: - case 213 /* VariableDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 139 /* Parameter */: + case 214 /* VariableDeclaration */: return node === parent_1.type; - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 145 /* Constructor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return node === parent_1.type; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return node === parent_1.type; - case 173 /* TypeAssertionExpression */: + case 174 /* TypeAssertionExpression */: return node === parent_1.type; - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4806,23 +4934,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return visitor(node); - case 222 /* CaseBlock */: - case 194 /* Block */: - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 207 /* WithStatement */: - case 208 /* SwitchStatement */: - case 243 /* CaseClause */: - case 244 /* DefaultClause */: - case 209 /* LabeledStatement */: - case 211 /* TryStatement */: - case 246 /* CatchClause */: + case 223 /* CaseBlock */: + case 195 /* Block */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 208 /* WithStatement */: + case 209 /* SwitchStatement */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: + case 210 /* LabeledStatement */: + case 212 /* TryStatement */: + case 247 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4832,18 +4960,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: - case 220 /* ModuleDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 217 /* ClassDeclaration */: + case 189 /* 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. @@ -4851,7 +4979,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 137 /* 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); @@ -4870,14 +4998,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 165 /* BindingElement */: - case 249 /* EnumMember */: - case 138 /* Parameter */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 248 /* ShorthandPropertyAssignment */: - case 213 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 250 /* EnumMember */: + case 139 /* Parameter */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 249 /* ShorthandPropertyAssignment */: + case 214 /* VariableDeclaration */: return true; } } @@ -4885,11 +5013,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); + return node && (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 216 /* ClassDeclaration */ || node.kind === 188 /* ClassExpression */); + return node && (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -4898,32 +5026,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 144 /* Constructor */: - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 145 /* Constructor */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: return true; } return false; @@ -4931,24 +5059,24 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: return true; - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 194 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 195 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 167 /* ObjectLiteralExpression */; + return node && node.kind === 144 /* MethodDeclaration */ && node.parent.kind === 168 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { @@ -4980,7 +5108,7 @@ var ts; return undefined; } switch (node.kind) { - case 136 /* ComputedPropertyName */: + case 137 /* 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 @@ -4995,9 +5123,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 139 /* Decorator */: + case 140 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 139 /* 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; @@ -5008,26 +5136,26 @@ var ts; node = node.parent; } break; - case 176 /* ArrowFunction */: + case 177 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 220 /* ModuleDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 219 /* EnumDeclaration */: - case 250 /* SourceFile */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 221 /* ModuleDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 220 /* EnumDeclaration */: + case 251 /* SourceFile */: return node; } } @@ -5048,26 +5176,26 @@ var ts; return node; } switch (node.kind) { - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: node = node.parent; break; - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return node; - case 139 /* Decorator */: + case 140 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 139 /* 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; @@ -5085,12 +5213,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 151 /* TypeReference */: + case 152 /* TypeReference */: return node.typeName; - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return node.expression; case 69 /* Identifier */: - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return node; } } @@ -5098,7 +5226,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5107,58 +5235,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: // classes are valid targets return true; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 216 /* ClassDeclaration */; - case 138 /* 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 && node.parent.parent.kind === 216 /* ClassDeclaration */; - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: + return node.parent.kind === 217 /* ClassDeclaration */; + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 144 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 216 /* ClassDeclaration */; + return node.body !== undefined + && node.parent.kind === 217 /* ClassDeclaration */; + case 139 /* 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 === 145 /* Constructor */ + || node.parent.kind === 144 /* MethodDeclaration */ + || node.parent.kind === 147 /* SetAccessor */) + && node.parent.parent.kind === 217 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { - switch (node.kind) { - case 216 /* ClassDeclaration */: - if (node.decorators) { - return true; - } - return false; - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - if (node.decorators) { - return true; - } - return false; - case 145 /* GetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; + return node.decorators !== undefined + && nodeCanBeDecorated(node); } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 168 /* PropertyAccessExpression */; + return node.kind === 169 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 169 /* ElementAccessExpression */; + return node.kind === 170 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -5168,42 +5278,42 @@ var ts; case 99 /* TrueKeyword */: case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 166 /* ArrayLiteralExpression */: - case 167 /* ObjectLiteralExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 172 /* TaggedTemplateExpression */: - case 191 /* AsExpression */: - case 173 /* TypeAssertionExpression */: - case 174 /* ParenthesizedExpression */: - case 175 /* FunctionExpression */: - case 188 /* ClassExpression */: - case 176 /* ArrowFunction */: - case 179 /* VoidExpression */: - case 177 /* DeleteExpression */: - case 178 /* TypeOfExpression */: - case 181 /* PrefixUnaryExpression */: - case 182 /* PostfixUnaryExpression */: - case 183 /* BinaryExpression */: - case 184 /* ConditionalExpression */: - case 187 /* SpreadElementExpression */: - case 185 /* TemplateExpression */: + case 167 /* ArrayLiteralExpression */: + case 168 /* ObjectLiteralExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 173 /* TaggedTemplateExpression */: + case 192 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 175 /* ParenthesizedExpression */: + case 176 /* FunctionExpression */: + case 189 /* ClassExpression */: + case 177 /* ArrowFunction */: + case 180 /* VoidExpression */: + case 178 /* DeleteExpression */: + case 179 /* TypeOfExpression */: + case 182 /* PrefixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: + case 184 /* BinaryExpression */: + case 185 /* ConditionalExpression */: + case 188 /* SpreadElementExpression */: + case 186 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 189 /* OmittedExpression */: - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: - case 186 /* YieldExpression */: - case 180 /* AwaitExpression */: + case 190 /* OmittedExpression */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: + case 187 /* YieldExpression */: + case 181 /* AwaitExpression */: return true; - case 135 /* QualifiedName */: - while (node.parent.kind === 135 /* QualifiedName */) { + case 136 /* QualifiedName */: + while (node.parent.kind === 136 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 154 /* TypeQuery */; + return node.parent.kind === 155 /* TypeQuery */; case 69 /* Identifier */: - if (node.parent.kind === 154 /* TypeQuery */) { + if (node.parent.kind === 155 /* TypeQuery */) { return true; } // fall through @@ -5212,47 +5322,47 @@ var ts; case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 213 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 249 /* EnumMember */: - case 247 /* PropertyAssignment */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 139 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 250 /* EnumMember */: + case 248 /* PropertyAssignment */: + case 166 /* BindingElement */: return parent_2.initializer === node; - case 197 /* ExpressionStatement */: - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 206 /* ReturnStatement */: - case 207 /* WithStatement */: - case 208 /* SwitchStatement */: - case 243 /* CaseClause */: - case 210 /* ThrowStatement */: - case 208 /* SwitchStatement */: + case 198 /* ExpressionStatement */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 207 /* ReturnStatement */: + case 208 /* WithStatement */: + case 209 /* SwitchStatement */: + case 244 /* CaseClause */: + case 211 /* ThrowStatement */: + case 209 /* SwitchStatement */: return parent_2.expression === node; - case 201 /* ForStatement */: + case 202 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 214 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 215 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 214 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215 /* VariableDeclarationList */) || forInStatement.expression === node; - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: return node === parent_2.expression; - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return node === parent_2.expression; - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: return node === parent_2.expression; - case 139 /* Decorator */: - case 242 /* JsxExpression */: - case 241 /* JsxSpreadAttribute */: + case 140 /* Decorator */: + case 243 /* JsxExpression */: + case 242 /* JsxSpreadAttribute */: return true; - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5276,7 +5386,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 234 /* ExternalModuleReference */; + return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5285,7 +5395,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 234 /* ExternalModuleReference */; + return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 235 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5303,7 +5413,7 @@ var ts; */ function isRequireCall(expression) { // of the form 'require("name")' - return expression.kind === 170 /* CallExpression */ && + return expression.kind === 171 /* CallExpression */ && expression.expression.kind === 69 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1 && @@ -5313,11 +5423,11 @@ var ts; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 183 /* BinaryExpression */) { + if (expression.kind !== 184 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 168 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 169 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -5335,7 +5445,7 @@ var ts; else if (lhs.expression.kind === 97 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 168 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 169 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 /* Identifier */ && innerPropertyAccess.name.text === "prototype") { @@ -5346,30 +5456,33 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 224 /* ImportDeclaration */) { + if (node.kind === 225 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 223 /* ImportEqualsDeclaration */) { + if (node.kind === 224 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 234 /* ExternalModuleReference */) { + if (reference.kind === 235 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 230 /* ExportDeclaration */) { + if (node.kind === 231 /* ExportDeclaration */) { return node.moduleSpecifier; } + if (node.kind === 221 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return node.name; + } } ts.getExternalModuleName = getExternalModuleName; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 138 /* Parameter */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 248 /* ShorthandPropertyAssignment */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 139 /* Parameter */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 249 /* ShorthandPropertyAssignment */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5377,9 +5490,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 263 /* JSDocFunctionType */ && + return node.kind === 264 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 265 /* JSDocConstructorType */; + node.parameters[0].type.kind === 266 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5393,15 +5506,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 271 /* JSDocTypeTag */); + return getJSDocTag(node, 272 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 270 /* JSDocReturnTag */); + return getJSDocTag(node, 271 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 272 /* JSDocTemplateTag */); + return getJSDocTag(node, 273 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5412,7 +5525,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 269 /* JSDocParameterTag */) { + if (t.kind === 270 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5431,12 +5544,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 264 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 265 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 264 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 265 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5457,7 +5570,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 164 /* ArrayBindingPattern */ || node.kind === 163 /* ObjectBindingPattern */); + return !!node && (node.kind === 165 /* ArrayBindingPattern */ || node.kind === 164 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -5481,34 +5594,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 176 /* ArrowFunction */: - case 165 /* BindingElement */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 144 /* Constructor */: - case 219 /* EnumDeclaration */: - case 249 /* EnumMember */: - case 232 /* ExportSpecifier */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 225 /* ImportClause */: - case 223 /* ImportEqualsDeclaration */: - case 228 /* ImportSpecifier */: - case 217 /* InterfaceDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 220 /* ModuleDeclaration */: - case 226 /* NamespaceImport */: - case 138 /* Parameter */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 146 /* SetAccessor */: - case 248 /* ShorthandPropertyAssignment */: - case 218 /* TypeAliasDeclaration */: - case 137 /* TypeParameter */: - case 213 /* VariableDeclaration */: + case 177 /* ArrowFunction */: + case 166 /* BindingElement */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 145 /* Constructor */: + case 220 /* EnumDeclaration */: + case 250 /* EnumMember */: + case 233 /* ExportSpecifier */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 146 /* GetAccessor */: + case 226 /* ImportClause */: + case 224 /* ImportEqualsDeclaration */: + case 229 /* ImportSpecifier */: + case 218 /* InterfaceDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 221 /* ModuleDeclaration */: + case 227 /* NamespaceImport */: + case 139 /* Parameter */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 147 /* SetAccessor */: + case 249 /* ShorthandPropertyAssignment */: + case 219 /* TypeAliasDeclaration */: + case 138 /* TypeParameter */: + case 214 /* VariableDeclaration */: return true; } return false; @@ -5516,25 +5629,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: - case 212 /* DebuggerStatement */: - case 199 /* DoStatement */: - case 197 /* ExpressionStatement */: - case 196 /* EmptyStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 201 /* ForStatement */: - case 198 /* IfStatement */: - case 209 /* LabeledStatement */: - case 206 /* ReturnStatement */: - case 208 /* SwitchStatement */: - case 210 /* ThrowStatement */: - case 211 /* TryStatement */: - case 195 /* VariableStatement */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 229 /* ExportAssignment */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 213 /* DebuggerStatement */: + case 200 /* DoStatement */: + case 198 /* ExpressionStatement */: + case 197 /* EmptyStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 202 /* ForStatement */: + case 199 /* IfStatement */: + case 210 /* LabeledStatement */: + case 207 /* ReturnStatement */: + case 209 /* SwitchStatement */: + case 211 /* ThrowStatement */: + case 212 /* TryStatement */: + case 196 /* VariableStatement */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 230 /* ExportAssignment */: return true; default: return false; @@ -5543,13 +5656,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: + case 145 /* Constructor */: + case 142 /* PropertyDeclaration */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 143 /* MethodSignature */: + case 150 /* IndexSignature */: return true; default: return false; @@ -5562,7 +5675,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 228 /* ImportSpecifier */ || parent.kind === 232 /* ExportSpecifier */) { + if (parent.kind === 229 /* ImportSpecifier */ || parent.kind === 233 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5577,31 +5690,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 249 /* EnumMember */: - case 247 /* PropertyAssignment */: - case 168 /* PropertyAccessExpression */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 250 /* EnumMember */: + case 248 /* PropertyAssignment */: + case 169 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 135 /* QualifiedName */) { + while (parent.kind === 136 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 154 /* TypeQuery */; + return parent.kind === 155 /* TypeQuery */; } return false; - case 165 /* BindingElement */: - case 228 /* ImportSpecifier */: + case 166 /* BindingElement */: + case 229 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 232 /* ExportSpecifier */: + case 233 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -5617,12 +5730,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 223 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ImportClause */ && !!node.name || - node.kind === 226 /* NamespaceImport */ || - node.kind === 228 /* ImportSpecifier */ || - node.kind === 232 /* ExportSpecifier */ || - node.kind === 229 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; + return node.kind === 224 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ImportClause */ && !!node.name || + node.kind === 227 /* NamespaceImport */ || + node.kind === 229 /* ImportSpecifier */ || + node.kind === 233 /* ExportSpecifier */ || + node.kind === 230 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5704,7 +5817,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 135 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5731,7 +5844,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 136 /* ComputedPropertyName */ && + return name.kind === 137 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -5749,7 +5862,7 @@ var ts; if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 136 /* ComputedPropertyName */) { + if (name.kind === 137 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5789,18 +5902,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 138 /* Parameter */; + return root.kind === 139 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 165 /* BindingElement */) { + while (node.kind === 166 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 220 /* ModuleDeclaration */ || n.kind === 250 /* SourceFile */; + return isFunctionLike(n) || n.kind === 221 /* ModuleDeclaration */ || n.kind === 251 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; /** @@ -5850,7 +5963,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 135 /* QualifiedName */; + return node.kind === 136 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -6180,7 +6293,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 145 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6197,10 +6310,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 145 /* GetAccessor */) { + if (accessor.kind === 146 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 146 /* SetAccessor */) { + else if (accessor.kind === 147 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6209,7 +6322,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) + if ((member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6220,10 +6333,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 145 /* GetAccessor */ && !getAccessor) { + if (member.kind === 146 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 146 /* SetAccessor */ && !setAccessor) { + if (member.kind === 147 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6433,24 +6546,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 171 /* NewExpression */: - case 170 /* CallExpression */: - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: - case 172 /* TaggedTemplateExpression */: - case 166 /* ArrayLiteralExpression */: - case 174 /* ParenthesizedExpression */: - case 167 /* ObjectLiteralExpression */: - case 188 /* ClassExpression */: - case 175 /* FunctionExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 172 /* NewExpression */: + case 171 /* CallExpression */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: + case 173 /* TaggedTemplateExpression */: + case 167 /* ArrayLiteralExpression */: + case 175 /* ParenthesizedExpression */: + case 168 /* ObjectLiteralExpression */: + case 189 /* ClassExpression */: + case 176 /* FunctionExpression */: case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: case 84 /* FalseKeyword */: case 93 /* NullKeyword */: case 97 /* ThisKeyword */: @@ -6467,7 +6580,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 190 /* ExpressionWithTypeArguments */ && + return node.kind === 191 /* ExpressionWithTypeArguments */ && node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } @@ -6490,16 +6603,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 167 /* ObjectLiteralExpression */) { + if (kind === 168 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 166 /* ArrayLiteralExpression */) { + if (kind === 167 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6854,9 +6967,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 137 /* TypeParameter */) { + if (d && d.kind === 138 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 217 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218 /* InterfaceDeclaration */) { return current; } } @@ -6864,7 +6977,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent); + return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 145 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -6876,7 +6989,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 250 /* SourceFile */) { + if (kind === 251 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -6919,26 +7032,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 248 /* ShorthandPropertyAssignment */: + case 249 /* 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 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* PropertyAssignment */: - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 139 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 248 /* PropertyAssignment */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6947,24 +7060,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6975,290 +7088,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 157 /* TupleType */: + case 158 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 173 /* TypeAssertionExpression */: + case 174 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 178 /* TypeOfExpression */: + case 179 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 179 /* VoidExpression */: + case 180 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 180 /* AwaitExpression */: + case 181 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 191 /* AsExpression */: + case 192 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 187 /* SpreadElementExpression */: + case 188 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 214 /* VariableDeclarationList */: + case 215 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 198 /* IfStatement */: + case 199 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 199 /* DoStatement */: + case 200 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 202 /* ForInStatement */: + case 203 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* ForOfStatement */: + case 204 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* ContinueStatement */: - case 205 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 206 /* BreakStatement */: return visitNode(cbNode, node.label); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 243 /* CaseClause */: + case 244 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 244 /* DefaultClause */: + case 245 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 211 /* TryStatement */: + case 212 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 139 /* Decorator */: + case 140 /* Decorator */: return visitNode(cbNode, node.expression); - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* 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 217 /* InterfaceDeclaration */: + case 218 /* 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 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 225 /* ImportClause */: + case 226 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 226 /* NamespaceImport */: + case 227 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 227 /* NamedImports */: - case 231 /* NamedExports */: + case 228 /* NamedImports */: + case 232 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 245 /* HeritageClause */: + case 246 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 234 /* ExternalModuleReference */: + case 235 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 233 /* MissingDeclaration */: + case 234 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 235 /* JsxElement */: + case 236 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 236 /* JsxSelfClosingElement */: - case 237 /* JsxOpeningElement */: + case 237 /* JsxSelfClosingElement */: + case 238 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 240 /* JsxAttribute */: + case 241 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 241 /* JsxSpreadAttribute */: + case 242 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 239 /* JsxClosingElement */: + case 240 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 251 /* JSDocTypeExpression */: + case 252 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 255 /* JSDocUnionType */: + case 256 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 256 /* JSDocTupleType */: + case 257 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 254 /* JSDocArrayType */: + case 255 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 258 /* JSDocNonNullableType */: + case 259 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 257 /* JSDocNullableType */: + case 258 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 259 /* JSDocRecordType */: + case 260 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 261 /* JSDocTypeReference */: + case 262 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 262 /* JSDocOptionalType */: + case 263 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 263 /* JSDocFunctionType */: + case 264 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 264 /* JSDocVariadicType */: + case 265 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 265 /* JSDocConstructorType */: + case 266 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 266 /* JSDocThisType */: + case 267 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 260 /* JSDocRecordMember */: + case 261 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 267 /* JSDocComment */: + case 268 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 269 /* JSDocParameterTag */: + case 270 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 270 /* JSDocReturnTag */: + case 271 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 271 /* JSDocTypeTag */: + case 272 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 272 /* JSDocTemplateTag */: + case 273 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7466,9 +7579,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 195 /* VariableStatement */: - case 215 /* FunctionDeclaration */: - case 138 /* Parameter */: + case 196 /* VariableStatement */: + case 216 /* FunctionDeclaration */: + case 139 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7511,7 +7624,7 @@ var ts; function createSourceFile(fileName, languageVersion) { // 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(250 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(251 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -7685,16 +7798,18 @@ var ts; } return result; } - // Invokes the provided callback then unconditionally restores the parser to the state it - // was in immediately prior to invoking the callback. The result of invoking the callback - // is returned from this function. + /** Invokes the provided callback then unconditionally restores the parser to the state it + * was in immediately prior to invoking the callback. The result of invoking the callback + * is returned from this function. + */ function lookAhead(callback) { return speculationHelper(callback, /*isLookAhead*/ true); } - // Invokes the provided callback. If the callback returns something falsy, then it restores - // the parser to the state it was in immediately prior to invoking the callback. If the - // callback returns something truthy, then the parser state is not rolled back. The result - // of invoking the callback is returned from this function. + /** Invokes the provided callback. If the callback returns something falsy, then it restores + * the parser to the state it was in immediately prior to invoking the callback. If the + * callback returns something truthy, then the parser state is not rolled back. The result + * of invoking the callback is returned from this function. + */ function tryParse(callback) { return speculationHelper(callback, /*isLookAhead*/ false); } @@ -7861,7 +7976,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(136 /* ComputedPropertyName */); + var node = createNode(137 /* ComputedPropertyName */); parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -8262,14 +8377,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 144 /* Constructor */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: - case 193 /* SemicolonClassElement */: + case 145 /* Constructor */: + case 150 /* IndexSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 194 /* SemicolonClassElement */: return true; - case 143 /* MethodDeclaration */: + case 144 /* 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. @@ -8284,8 +8399,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: return true; } } @@ -8294,58 +8409,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: - case 195 /* VariableStatement */: - case 194 /* Block */: - case 198 /* IfStatement */: - case 197 /* ExpressionStatement */: - case 210 /* ThrowStatement */: - case 206 /* ReturnStatement */: - case 208 /* SwitchStatement */: - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 201 /* ForStatement */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 196 /* EmptyStatement */: - case 211 /* TryStatement */: - case 209 /* LabeledStatement */: - case 199 /* DoStatement */: - case 212 /* DebuggerStatement */: - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 230 /* ExportDeclaration */: - case 229 /* ExportAssignment */: - case 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 218 /* TypeAliasDeclaration */: + case 216 /* FunctionDeclaration */: + case 196 /* VariableStatement */: + case 195 /* Block */: + case 199 /* IfStatement */: + case 198 /* ExpressionStatement */: + case 211 /* ThrowStatement */: + case 207 /* ReturnStatement */: + case 209 /* SwitchStatement */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 202 /* ForStatement */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 197 /* EmptyStatement */: + case 212 /* TryStatement */: + case 210 /* LabeledStatement */: + case 200 /* DoStatement */: + case 213 /* DebuggerStatement */: + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 231 /* ExportDeclaration */: + case 230 /* ExportAssignment */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 219 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 249 /* EnumMember */; + return node.kind === 250 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 148 /* ConstructSignature */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 140 /* PropertySignature */: - case 147 /* CallSignature */: + case 149 /* ConstructSignature */: + case 143 /* MethodSignature */: + case 150 /* IndexSignature */: + case 141 /* PropertySignature */: + case 148 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 213 /* VariableDeclaration */) { + if (node.kind !== 214 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8366,7 +8481,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 138 /* Parameter */) { + if (node.kind !== 139 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8483,7 +8598,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(135 /* QualifiedName */, entity.pos); + var node = createNode(136 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8522,7 +8637,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(185 /* TemplateExpression */); + var template = createNode(186 /* TemplateExpression */); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8535,7 +8650,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(192 /* TemplateSpan */); + var span = createNode(193 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8549,7 +8664,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(162 /* StringLiteralType */, /*internName*/ true); + return parseLiteralLikeNode(163 /* StringLiteralType */, /*internName*/ true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -8584,12 +8699,9 @@ var ts; return node; } // TYPES - function parseTypeReferenceOrTypePredicate() { + function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(typeName); - } - var node = createNode(151 /* TypeReference */, typeName.pos); + var node = createNode(152 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -8598,24 +8710,24 @@ var ts; } function parseTypePredicate(lhs) { nextToken(); - var node = createNode(150 /* TypePredicate */, lhs.pos); + var node = createNode(151 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(161 /* ThisType */); + var node = createNode(162 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(154 /* TypeQuery */); + var node = createNode(155 /* TypeQuery */); parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(137 /* TypeParameter */); + var node = createNode(138 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8659,7 +8771,7 @@ var ts; } } function parseParameter() { - var node = createNode(138 /* Parameter */); + var node = createNode(139 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8702,10 +8814,10 @@ var ts; signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } else if (parseOptional(returnToken)) { - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { @@ -8753,7 +8865,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 148 /* ConstructSignature */) { + if (kind === 149 /* ConstructSignature */) { parseExpected(92 /* NewKeyword */); } fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -8817,7 +8929,7 @@ var ts; return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149 /* IndexSignature */, fullStart); + var node = createNode(150 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -8830,7 +8942,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(142 /* MethodSignature */, fullStart); + var method = createNode(143 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -8840,7 +8952,7 @@ var ts; return finishNode(method); } else { - var property = createNode(140 /* PropertySignature */, fullStart); + var property = createNode(141 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8888,7 +9000,7 @@ var ts; switch (token) { case 17 /* OpenParenToken */: case 25 /* LessThanToken */: - return parseSignatureMember(147 /* CallSignature */); + return parseSignatureMember(148 /* CallSignature */); case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -8896,7 +9008,7 @@ var ts; : parsePropertyOrMethodSignature(); case 92 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148 /* ConstructSignature */); + return parseSignatureMember(149 /* ConstructSignature */); } // fall through. case 9 /* StringLiteral */: @@ -8933,7 +9045,7 @@ var ts; return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(155 /* TypeLiteral */); + var node = createNode(156 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -8949,12 +9061,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(157 /* TupleType */); + var node = createNode(158 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(160 /* ParenthesizedType */); + var node = createNode(161 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -8962,7 +9074,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 153 /* ConstructorType */) { + if (kind === 154 /* ConstructorType */) { parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -8981,7 +9093,7 @@ var ts; case 131 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); + return node || parseTypeReference(); case 9 /* StringLiteral */: return parseStringLiteralTypeNode(); case 103 /* VoidKeyword */: @@ -9004,7 +9116,7 @@ var ts; case 17 /* OpenParenToken */: return parseParenthesizedType(); default: - return parseTypeReferenceOrTypePredicate(); + return parseTypeReference(); } } function isStartOfType() { @@ -9039,7 +9151,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(156 /* ArrayType */, type.pos); + var node = createNode(157 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9061,10 +9173,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(160 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(159 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9101,6 +9213,26 @@ var ts; } return false; } + function parseTypeOrTypePredicate() { + var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); + var type = parseType(); + if (typePredicateVariable) { + var node = createNode(151 /* TypePredicate */, typePredicateVariable.pos); + node.parameterName = typePredicateVariable; + node.type = type; + return finishNode(node); + } + else { + return type; + } + } + function parseTypePredicatePrefix() { + var id = parseIdentifier(); + if (token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + return id; + } + } 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. @@ -9108,10 +9240,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152 /* FunctionType */); + return parseFunctionOrConstructorType(153 /* FunctionType */); } if (token === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(153 /* ConstructorType */); + return parseFunctionOrConstructorType(154 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -9304,7 +9436,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(186 /* YieldExpression */); + var node = createNode(187 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9324,8 +9456,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(176 /* ArrowFunction */, identifier.pos); - var parameter = createNode(138 /* Parameter */, identifier.pos); + var node = createNode(177 /* ArrowFunction */, identifier.pos); + var parameter = createNode(139 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9477,7 +9609,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(176 /* ArrowFunction */); + var node = createNode(177 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. @@ -9543,7 +9675,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(184 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(185 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -9556,7 +9688,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 135 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9664,39 +9796,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(183 /* BinaryExpression */, left.pos); + var node = createNode(184 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(191 /* AsExpression */, left.pos); + var node = createNode(192 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(181 /* PrefixUnaryExpression */); + var node = createNode(182 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(177 /* DeleteExpression */); + var node = createNode(178 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(178 /* TypeOfExpression */); + var node = createNode(179 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(179 /* VoidExpression */); + var node = createNode(180 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9712,7 +9844,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(180 /* AwaitExpression */); + var node = createNode(181 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9738,7 +9870,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 173 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 174 /* 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 { @@ -9828,7 +9960,7 @@ var ts; */ function parseIncrementExpression() { if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { - var node = createNode(181 /* PrefixUnaryExpression */); + var node = createNode(182 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -9841,7 +9973,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(182 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(183 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9945,7 +10077,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(168 /* PropertyAccessExpression */, expression.pos); + var node = createNode(169 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -9964,8 +10096,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 237 /* JsxOpeningElement */) { - var node = createNode(235 /* JsxElement */, opening.pos); + if (opening.kind === 238 /* JsxOpeningElement */) { + var node = createNode(236 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -9975,7 +10107,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 236 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 237 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -9990,7 +10122,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(183 /* BinaryExpression */, result.pos); + var badNode = createNode(184 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -10002,13 +10134,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(238 /* JsxText */, scanner.getStartPos()); + var node = createNode(239 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 238 /* JsxText */: + case 239 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10050,7 +10182,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(237 /* JsxOpeningElement */, fullStart); + node = createNode(238 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -10062,7 +10194,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(236 /* JsxSelfClosingElement */, fullStart); + node = createNode(237 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10073,7 +10205,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(135 /* QualifiedName */, elementName.pos); + var node = createNode(136 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10081,7 +10213,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(242 /* JsxExpression */); + var node = createNode(243 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -10100,7 +10232,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(240 /* JsxAttribute */); + var node = createNode(241 /* JsxAttribute */); node.name = parseIdentifierName(); if (parseOptional(56 /* EqualsToken */)) { switch (token) { @@ -10115,7 +10247,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(241 /* JsxSpreadAttribute */); + var node = createNode(242 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10123,7 +10255,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(239 /* JsxClosingElement */); + var node = createNode(240 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10136,7 +10268,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(173 /* TypeAssertionExpression */); + var node = createNode(174 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); @@ -10147,7 +10279,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(168 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(169 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10156,7 +10288,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(169 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(170 /* 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. @@ -10172,7 +10304,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(172 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(173 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10195,7 +10327,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(170 /* CallExpression */, expression.pos); + var callExpr = createNode(171 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10203,7 +10335,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(170 /* CallExpression */, expression.pos); + var callExpr = createNode(171 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10313,28 +10445,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(174 /* ParenthesizedExpression */); + var node = createNode(175 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(187 /* SpreadElementExpression */); + var node = createNode(188 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(189 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(190 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(166 /* ArrayLiteralExpression */); + var node = createNode(167 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 1024 /* MultiLine */; @@ -10344,10 +10476,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(146 /* GetAccessor */, fullStart, decorators, modifiers); } else if (parseContextualModifier(129 /* SetKeyword */)) { - return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(147 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10374,7 +10506,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(248 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(249 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56 /* EqualsToken */); @@ -10385,7 +10517,7 @@ var ts; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(247 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(248 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -10395,7 +10527,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(167 /* ObjectLiteralExpression */); + var node = createNode(168 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 1024 /* MultiLine */; @@ -10414,7 +10546,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(175 /* FunctionExpression */); + var node = createNode(176 /* FunctionExpression */); setModifiers(node, parseModifiers()); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); @@ -10436,7 +10568,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(171 /* NewExpression */); + var node = createNode(172 /* NewExpression */); parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -10447,7 +10579,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(194 /* Block */); + var node = createNode(195 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10477,12 +10609,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(196 /* EmptyStatement */); + var node = createNode(197 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(198 /* IfStatement */); + var node = createNode(199 /* IfStatement */); parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10492,7 +10624,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(199 /* DoStatement */); + var node = createNode(200 /* DoStatement */); parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); parseExpected(104 /* WhileKeyword */); @@ -10507,7 +10639,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(200 /* WhileStatement */); + var node = createNode(201 /* WhileStatement */); parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10530,21 +10662,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(202 /* ForInStatement */, pos); + var forInStatement = createNode(203 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(134 /* OfKeyword */)) { - var forOfStatement = createNode(203 /* ForOfStatement */, pos); + else if (parseOptional(135 /* OfKeyword */)) { + var forOfStatement = createNode(204 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(201 /* ForStatement */, pos); + var forStatement = createNode(202 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10562,7 +10694,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 205 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10570,7 +10702,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(206 /* ReturnStatement */); + var node = createNode(207 /* ReturnStatement */); parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -10579,7 +10711,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(207 /* WithStatement */); + var node = createNode(208 /* WithStatement */); parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10588,7 +10720,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(243 /* CaseClause */); + var node = createNode(244 /* CaseClause */); parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(54 /* ColonToken */); @@ -10596,7 +10728,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(244 /* DefaultClause */); + var node = createNode(245 /* DefaultClause */); parseExpected(77 /* DefaultKeyword */); parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -10606,12 +10738,12 @@ var ts; return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(208 /* SwitchStatement */); + var node = createNode(209 /* SwitchStatement */); parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(222 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(223 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10626,7 +10758,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(210 /* ThrowStatement */); + var node = createNode(211 /* ThrowStatement */); parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -10634,7 +10766,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(211 /* TryStatement */); + var node = createNode(212 /* TryStatement */); parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -10647,7 +10779,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(246 /* CatchClause */); + var result = createNode(247 /* CatchClause */); parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -10657,7 +10789,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(212 /* DebuggerStatement */); + var node = createNode(213 /* DebuggerStatement */); parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -10669,13 +10801,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(209 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(210 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(197 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(198 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -10742,6 +10874,8 @@ var ts; return false; } continue; + case 134 /* GlobalKeyword */: + return nextToken() === 15 /* OpenBraceToken */; case 89 /* ImportKeyword */: nextToken(); return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || @@ -10801,6 +10935,7 @@ var ts; case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: case 132 /* TypeKeyword */: + case 134 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 112 /* PublicKeyword */: @@ -10849,9 +10984,9 @@ var ts; case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(204 /* ContinueStatement */); + return parseBreakOrContinueStatement(205 /* ContinueStatement */); case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(205 /* BreakStatement */); + return parseBreakOrContinueStatement(206 /* BreakStatement */); case 94 /* ReturnKeyword */: return parseReturnStatement(); case 105 /* WithKeyword */: @@ -10884,6 +11019,7 @@ var ts; case 112 /* PublicKeyword */: case 115 /* AbstractKeyword */: case 113 /* StaticKeyword */: + case 134 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10910,6 +11046,7 @@ var ts; return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); + case 134 /* GlobalKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -10924,7 +11061,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(233 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(234 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10946,16 +11083,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(189 /* OmittedExpression */); + return createNode(190 /* OmittedExpression */); } - var node = createNode(165 /* BindingElement */); + var node = createNode(166 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(165 /* BindingElement */); + var node = createNode(166 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54 /* ColonToken */) { @@ -10970,14 +11107,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(163 /* ObjectBindingPattern */); + var node = createNode(164 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(164 /* ArrayBindingPattern */); + var node = createNode(165 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -10996,7 +11133,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(213 /* VariableDeclaration */); + var node = createNode(214 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11005,7 +11142,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(214 /* VariableDeclarationList */); + var node = createNode(215 /* VariableDeclarationList */); switch (token) { case 102 /* VarKeyword */: break; @@ -11028,7 +11165,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 === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 135 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11043,7 +11180,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(195 /* VariableStatement */, fullStart); + var node = createNode(196 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -11051,7 +11188,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* FunctionDeclaration */, fullStart); + var node = createNode(216 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); @@ -11064,7 +11201,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144 /* Constructor */, pos); + var node = createNode(145 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121 /* ConstructorKeyword */); @@ -11073,7 +11210,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143 /* MethodDeclaration */, fullStart); + var method = createNode(144 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11086,7 +11223,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141 /* PropertyDeclaration */, fullStart); + var property = createNode(142 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11212,7 +11349,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(139 /* Decorator */, decoratorStart); + var decorator = createNode(140 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11277,7 +11414,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(193 /* SemicolonClassElement */); + var result = createNode(194 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11315,10 +11452,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 188 /* ClassExpression */); + /*modifiers*/ undefined, 189 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 216 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -11362,7 +11499,7 @@ var ts; } function parseHeritageClause() { if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { - var node = createNode(245 /* HeritageClause */); + var node = createNode(246 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11371,7 +11508,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(190 /* ExpressionWithTypeArguments */); + var node = createNode(191 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11385,7 +11522,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217 /* InterfaceDeclaration */, fullStart); + var node = createNode(218 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107 /* InterfaceKeyword */); @@ -11396,7 +11533,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* TypeAliasDeclaration */, fullStart); + var node = createNode(219 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(132 /* TypeKeyword */); @@ -11412,13 +11549,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(249 /* EnumMember */, scanner.getStartPos()); + var node = createNode(250 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219 /* EnumDeclaration */, fullStart); + var node = createNode(220 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81 /* EnumKeyword */); @@ -11433,7 +11570,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(221 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(222 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11444,7 +11581,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(220 /* ModuleDeclaration */, fullStart); + var node = createNode(221 /* 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 & 65536 /* Namespace */; @@ -11458,16 +11595,27 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* ModuleDeclaration */, fullStart); + var node = createNode(221 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(/*internName*/ true); + if (token === 134 /* GlobalKeyword */) { + // parse 'global' as name of global scope augmentation + node.name = parseIdentifier(); + node.flags |= 2097152 /* GlobalAugmentation */; + } + else { + node.name = parseLiteralNode(/*internName*/ true); + } node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126 /* NamespaceKeyword */)) { + if (token === 134 /* GlobalKeyword */) { + // global augmentation + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + else if (parseOptional(126 /* NamespaceKeyword */)) { flags |= 65536 /* Namespace */; } else { @@ -11498,7 +11646,7 @@ var ts; // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(223 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(224 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -11509,7 +11657,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(224 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(225 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11532,7 +11680,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(225 /* ImportClause */, fullStart); + var importClause = createNode(226 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11542,7 +11690,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(227 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(228 /* NamedImports */); } return finishNode(importClause); } @@ -11552,7 +11700,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(234 /* ExternalModuleReference */); + var node = createNode(235 /* ExternalModuleReference */); parseExpected(127 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -11575,7 +11723,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(226 /* NamespaceImport */); + var namespaceImport = createNode(227 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -11590,14 +11738,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 227 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 228 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(232 /* ExportSpecifier */); + return parseImportOrExportSpecifier(233 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(228 /* ImportSpecifier */); + return parseImportOrExportSpecifier(229 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11622,14 +11770,14 @@ var ts; else { node.name = identifierName; } - if (kind === 228 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 229 /* 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(230 /* ExportDeclaration */, fullStart); + var node = createNode(231 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { @@ -11637,7 +11785,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(231 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(232 /* 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. @@ -11650,7 +11798,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(229 /* ExportAssignment */, fullStart); + var node = createNode(230 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56 /* EqualsToken */)) { @@ -11725,10 +11873,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 2 /* Export */ - || node.kind === 223 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 234 /* ExternalModuleReference */ - || node.kind === 224 /* ImportDeclaration */ - || node.kind === 229 /* ExportAssignment */ - || node.kind === 230 /* ExportDeclaration */ + || node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */ + || node.kind === 225 /* ImportDeclaration */ + || node.kind === 230 /* ExportAssignment */ + || node.kind === 231 /* ExportDeclaration */ ? node : undefined; }); @@ -11803,7 +11951,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(251 /* JSDocTypeExpression */); + var result = createNode(252 /* JSDocTypeExpression */); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11814,12 +11962,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47 /* BarToken */) { - var unionType = createNode(255 /* JSDocUnionType */, type.pos); + var unionType = createNode(256 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56 /* EqualsToken */) { - var optionalType = createNode(262 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(263 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11830,20 +11978,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(254 /* JSDocArrayType */, type.pos); + var arrayType = createNode(255 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 53 /* QuestionToken */) { - var nullableType = createNode(257 /* JSDocNullableType */, type.pos); + var nullableType = createNode(258 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49 /* ExclamationToken */) { - var nonNullableType = createNode(258 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(259 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11888,27 +12036,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(266 /* JSDocThisType */); + var result = createNode(267 /* JSDocThisType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(265 /* JSDocConstructorType */); + var result = createNode(266 /* JSDocConstructorType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(264 /* JSDocVariadicType */); + var result = createNode(265 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(263 /* JSDocFunctionType */); + var result = createNode(264 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -11921,12 +12069,12 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(138 /* Parameter */); + var parameter = createNode(139 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(261 /* JSDocTypeReference */); + var result = createNode(262 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(21 /* DotToken */)) { if (token === 25 /* LessThanToken */) { @@ -11956,13 +12104,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(135 /* QualifiedName */, left.pos); + var result = createNode(136 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(259 /* JSDocRecordType */); + var result = createNode(260 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -11970,7 +12118,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(260 /* JSDocRecordMember */); + var result = createNode(261 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 54 /* ColonToken */) { nextToken(); @@ -11979,13 +12127,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(258 /* JSDocNonNullableType */); + var result = createNode(259 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(256 /* JSDocTupleType */); + var result = createNode(257 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -11999,7 +12147,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(255 /* JSDocUnionType */); + var result = createNode(256 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12017,7 +12165,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(252 /* JSDocAllType */); + var result = createNode(253 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12040,11 +12188,11 @@ var ts; token === 27 /* GreaterThanToken */ || token === 56 /* EqualsToken */ || token === 47 /* BarToken */) { - var result = createNode(253 /* JSDocUnknownType */, pos); + var result = createNode(254 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(257 /* JSDocNullableType */, pos); + var result = createNode(258 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -12132,7 +12280,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(267 /* JSDocComment */, start); + var result = createNode(268 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12169,7 +12317,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(268 /* JSDocTag */, atToken.pos); + var result = createNode(269 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12220,7 +12368,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(269 /* JSDocParameterTag */, atToken.pos); + var result = createNode(270 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12230,27 +12378,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(270 /* JSDocReturnTag */, atToken.pos); + var result = createNode(271 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(271 /* JSDocTypeTag */, atToken.pos); + var result = createNode(272 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12263,7 +12411,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(138 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12274,7 +12422,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(272 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(273 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12804,16 +12952,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 217 /* InterfaceDeclaration */ || node.kind === 218 /* TypeAliasDeclaration */) { + if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 219 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 224 /* ImportDeclaration */ || node.kind === 223 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { + else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 221 /* ModuleBlock */) { + else if (node.kind === 222 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -12832,7 +12980,7 @@ var ts; }); return state; } - else if (node.kind === 220 /* ModuleDeclaration */) { + else if (node.kind === 221 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -12882,6 +13030,11 @@ var ts; var labelStack; var labelIndexMap; var implicitLabels; + // state used for emit helpers + var hasClassExtends; + var hasAsyncFunctions; + var hasDecorators; + var hasParameterDecorators; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -12911,6 +13064,10 @@ var ts; labelStack = undefined; labelIndexMap = undefined; implicitLabels = undefined; + hasClassExtends = false; + hasAsyncFunctions = false; + hasDecorators = false; + hasParameterDecorators = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -12933,7 +13090,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 220 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -12943,10 +13100,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 220 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { - return "\"" + node.name.text + "\""; + if (ts.isAmbientModule(node)) { + return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* 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)) { @@ -12958,21 +13115,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 144 /* Constructor */: + case 145 /* Constructor */: return "__constructor"; - case 152 /* FunctionType */: - case 147 /* CallSignature */: + case 153 /* FunctionType */: + case 148 /* CallSignature */: return "__call"; - case 153 /* ConstructorType */: - case 148 /* ConstructSignature */: + case 154 /* ConstructorType */: + case 149 /* ConstructSignature */: return "__new"; - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: return "__index"; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return "__export"; - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -12987,8 +13144,8 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 215 /* FunctionDeclaration */: - case 216 /* ClassDeclaration */: + case 216 /* FunctionDeclaration */: + case 217 /* ClassDeclaration */: return node.flags & 512 /* Default */ ? "default" : undefined; } } @@ -13065,7 +13222,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 232 /* ExportSpecifier */ || (node.kind === 223 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 233 /* ExportSpecifier */ || (node.kind === 224 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -13084,7 +13241,11 @@ var ts; // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & 131072 /* ExportContext */) { + // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge + // 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 & 131072 /* ExportContext */)) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -13148,10 +13309,12 @@ var ts; var flags = node.flags; // reset all reachability check related flags on node (for incremental scenarios) flags &= ~1572864 /* ReachabilityCheckFlags */; - if (kind === 217 /* InterfaceDeclaration */) { + // reset all emit helper flags on node (for incremental scenarios) + flags &= ~62914560 /* EmitHelperFlags */; + if (kind === 218 /* InterfaceDeclaration */) { seenThisKeyword = false; } - var saveState = kind === 250 /* SourceFile */ || kind === 221 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + var saveState = kind === 251 /* SourceFile */ || kind === 222 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -13169,9 +13332,23 @@ var ts; flags |= 1048576 /* HasExplicitReturn */; } } - if (kind === 217 /* InterfaceDeclaration */) { + if (kind === 218 /* InterfaceDeclaration */) { flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; } + if (kind === 251 /* SourceFile */) { + if (hasClassExtends) { + flags |= 4194304 /* HasClassExtends */; + } + if (hasDecorators) { + flags |= 8388608 /* HasDecorators */; + } + if (hasParameterDecorators) { + flags |= 16777216 /* HasParamDecorators */; + } + if (hasAsyncFunctions) { + flags |= 33554432 /* HasAsyncFunctions */; + } + } node.flags = flags; if (saveState) { hasExplicitReturn = savedHasExplicitReturn; @@ -13194,40 +13371,40 @@ var ts; return; } switch (node.kind) { - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: bindWhileStatement(node); break; - case 199 /* DoStatement */: + case 200 /* DoStatement */: bindDoStatement(node); break; - case 201 /* ForStatement */: + case 202 /* ForStatement */: bindForStatement(node); break; - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 198 /* IfStatement */: + case 199 /* IfStatement */: bindIfStatement(node); break; - case 206 /* ReturnStatement */: - case 210 /* ThrowStatement */: + case 207 /* ReturnStatement */: + case 211 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 211 /* TryStatement */: + case 212 /* TryStatement */: bindTryStatement(node); break; - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: bindSwitchStatement(node); break; - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: bindCaseBlock(node); break; - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: bindLabeledStatement(node); break; default: @@ -13302,7 +13479,7 @@ var ts; function bindReturnOrThrow(n) { // bind expression (don't affect reachability) bind(n.expression); - if (n.kind === 206 /* ReturnStatement */) { + if (n.kind === 207 /* ReturnStatement */) { hasExplicitReturn = true; } currentReachabilityState = 4 /* Unreachable */; @@ -13311,7 +13488,7 @@ var ts; // call bind on label (don't affect reachability) bind(n.label); // for continue case touch label so it will be marked a used - var isValidJump = jumpToLabel(n.label, n.kind === 205 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + var isValidJump = jumpToLabel(n.label, n.kind === 206 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); if (isValidJump) { currentReachabilityState = 4 /* Unreachable */; } @@ -13337,7 +13514,7 @@ var ts; // bind expression (don't affect reachability) bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 244 /* DefaultClause */; }); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245 /* DefaultClause */; }); // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); @@ -13364,37 +13541,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 167 /* ObjectLiteralExpression */: + case 189 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 156 /* TypeLiteral */: + case 168 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 215 /* FunctionDeclaration */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 220 /* ModuleDeclaration */: - case 250 /* SourceFile */: - case 218 /* TypeAliasDeclaration */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 221 /* ModuleDeclaration */: + case 251 /* SourceFile */: + case 219 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 246 /* CatchClause */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 222 /* CaseBlock */: + case 247 /* CatchClause */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 223 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 194 /* Block */: + case 195 /* 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. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -13431,38 +13608,38 @@ 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 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 217 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155 /* TypeLiteral */: - case 167 /* ObjectLiteralExpression */: - case 217 /* InterfaceDeclaration */: + case 156 /* TypeLiteral */: + case 168 /* ObjectLiteralExpression */: + case 218 /* InterfaceDeclaration */: // 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 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 218 /* TypeAliasDeclaration */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 219 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -13483,11 +13660,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 250 /* SourceFile */ ? node : node.body; - if (body.kind === 250 /* SourceFile */ || body.kind === 221 /* ModuleBlock */) { + var body = node.kind === 251 /* SourceFile */ ? node : node.body; + if (body.kind === 251 /* SourceFile */ || body.kind === 222 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 230 /* ExportDeclaration */ || stat.kind === 229 /* ExportAssignment */) { + if (stat.kind === 231 /* ExportDeclaration */ || stat.kind === 230 /* ExportAssignment */) { return true; } } @@ -13506,7 +13683,10 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 9 /* StringLiteral */) { + if (ts.isAmbientModule(node)) { + if (node.flags & 2 /* Export */) { + errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); + } declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -13571,7 +13751,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 === 247 /* PropertyAssignment */ || prop.kind === 248 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ + var currentKind = prop.kind === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */ || prop.kind === 144 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -13593,10 +13773,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -13756,17 +13936,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 250 /* SourceFile */: - case 221 /* ModuleBlock */: + case 251 /* SourceFile */: + case 222 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -13796,7 +13976,7 @@ var ts; /* Strict mode checks */ case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -13820,100 +14000,97 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return checkStrictModeCatchClause(node); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return checkStrictModeWithStatement(node); - case 161 /* ThisType */: + case 162 /* ThisType */: seenThisKeyword = true; return; - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return checkTypePredicate(node); - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 138 /* Parameter */: + case 139 /* Parameter */: return bindParameter(node); - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 247 /* PropertyAssignment */: - case 248 /* ShorthandPropertyAssignment */: + case 248 /* PropertyAssignment */: + case 249 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* 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) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 215 /* FunctionDeclaration */: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 144 /* Constructor */: + case 216 /* FunctionDeclaration */: + return bindFunctionDeclaration(node); + case 145 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 145 /* GetAccessor */: + case 146 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 146 /* SetAccessor */: + case 147 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 170 /* CallExpression */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + return bindFunctionExpression(node); + case 171 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 217 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 223 /* ImportEqualsDeclaration */: - case 226 /* NamespaceImport */: - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 227 /* NamespaceImport */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 225 /* ImportClause */: + case 226 /* ImportClause */: return bindImportClause(node); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return bindExportDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return bindExportAssignment(node); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -13922,7 +14099,7 @@ var ts; if (parameterName && parameterName.kind === 69 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 161 /* ThisType */) { + if (parameterName && parameterName.kind === 162 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -13937,7 +14114,7 @@ var ts; bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 229 /* ExportAssignment */ ? node.expression : node.right; + var boundExpression = node.kind === 230 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); @@ -13985,7 +14162,7 @@ var ts; } function bindThisPropertyAssignment(node) { // Declare a 'member' in case it turns out the container was an ES5 class - if (container.kind === 175 /* FunctionExpression */ || container.kind === 215 /* FunctionDeclaration */) { + if (container.kind === 176 /* FunctionExpression */ || container.kind === 216 /* FunctionDeclaration */) { container.symbol.members = container.symbol.members || {}; declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -14014,7 +14191,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 216 /* ClassDeclaration */) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { + hasClassExtends = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } + if (node.kind === 217 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -14076,6 +14261,12 @@ var ts; } } function bindParameter(node) { + if (!ts.isDeclarationFile(file) && + !ts.isInAmbientContext(node) && + ts.nodeIsDecorated(node)) { + hasDecorators = true; + hasParameterDecorators = true; + } if (inStrictMode) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) @@ -14094,7 +14285,34 @@ var ts; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } } + function bindFunctionDeclaration(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); + } + function bindFunctionExpression(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -14159,13 +14377,13 @@ var ts; case 4 /* Unreachable */: var reportError = // report error on all statements except empty ones - (ts.isStatement(node) && node.kind !== 196 /* EmptyStatement */) || + (ts.isStatement(node) && node.kind !== 197 /* EmptyStatement */) || // report error on class declarations - node.kind === 216 /* ClassDeclaration */ || + node.kind === 217 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 220 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 221 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 219 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 220 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8 /* ReportedUnreachable */; // unreachable code is reported if @@ -14179,7 +14397,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 !== 195 /* VariableStatement */ || + (node.kind !== 196 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -14264,6 +14482,7 @@ var ts; getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, // The language service will always care about the narrowed type of a symbol, because that is @@ -14280,6 +14499,7 @@ var ts; getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, @@ -14355,11 +14575,6 @@ var ts; var unionTypes = {}; var intersectionTypes = {}; var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -14504,7 +14719,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 220 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 220 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 221 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 221 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -14559,6 +14774,30 @@ var ts; } } } + function mergeModuleAugmentation(moduleName) { + var moduleAugmentation = moduleName.parent; + if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { + // this is a combined symbol for multiple augmentations within the same file. + // its symbol already has accumulated information for all declarations + // so we need to add it just once - do the work only for first declaration + ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); + return; + } + if (ts.isGlobalScopeAugmentation(moduleAugmentation)) { + mergeSymbolTable(globals, moduleAugmentation.symbol.exports); + } + else { + // find a module that about to be augmented + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); + if (!mainModule) { + return; + } + // if module symbol has already been merged - it is safe to use it. + // otherwise clone it + mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + } function addToSymbolTable(target, source, message) { for (var id in source) { if (ts.hasProperty(source, id)) { @@ -14585,18 +14824,8 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } - function getSourceFile(node) { - return ts.getAncestor(node, 250 /* SourceFile */); - } function isGlobalSourceFile(node) { - return node.kind === 250 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); - } - /** Is this type one of the apparent types created from the primitive types. */ - function isPrimitiveApparentType(type) { - return type === globalStringType || - type === globalNumberType || - type === globalBooleanType || - type === globalESSymbolType; + return node.kind === 251 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -14645,7 +14874,7 @@ var ts; if (declaration.pos <= usage.pos) { // declaration is before usage // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 213 /* VariableDeclaration */ || + return declaration.kind !== 214 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -14653,14 +14882,14 @@ var ts; return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 195 /* VariableStatement */ || - declaration.parent.parent.kind === 201 /* ForStatement */) { + if (declaration.parent.parent.kind === 196 /* VariableStatement */ || + declaration.parent.parent.kind === 202 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 203 /* ForOfStatement */ || - declaration.parent.parent.kind === 202 /* ForInStatement */) { + else if (declaration.parent.parent.kind === 204 /* ForOfStatement */ || + declaration.parent.parent.kind === 203 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); @@ -14677,7 +14906,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 /* PropertyDeclaration */ && + current.parent.kind === 142 /* PropertyDeclaration */ && (current.parent.flags & 64 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -14710,8 +14939,8 @@ var ts; if (meaning & result.flags & 793056 /* Type */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 138 /* Parameter */ || - lastLocation.kind === 137 /* TypeParameter */ + lastLocation.kind === 139 /* Parameter */ || + lastLocation.kind === 138 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -14720,9 +14949,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 === 138 /* Parameter */ || + lastLocation.kind === 139 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 138 /* Parameter */); + result.valueDeclaration.kind === 139 /* Parameter */); } } if (useResult) { @@ -14734,13 +14963,12 @@ var ts; } } switch (location.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 250 /* SourceFile */ || - (location.kind === 220 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + if (location.kind === 251 /* 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"]) { @@ -14763,7 +14991,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 232 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 233 /* ExportSpecifier */)) { break; } } @@ -14771,13 +14999,13 @@ var ts; break loop; } break; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* 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 @@ -14794,9 +15022,9 @@ var ts; } } break; - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 64 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -14807,7 +15035,7 @@ var ts; } break loop; } - if (location.kind === 188 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 189 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -14823,9 +15051,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 217 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 218 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -14833,19 +15061,19 @@ var ts; } } break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 175 /* FunctionExpression */: + case 176 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -14858,7 +15086,7 @@ var ts; } } break; - case 139 /* Decorator */: + case 140 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -14867,7 +15095,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 === 138 /* Parameter */) { + if (location.parent && location.parent.kind === 139 /* Parameter */) { location = location.parent; } // @@ -14889,7 +15117,9 @@ var ts; } if (!result) { if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } } return undefined; } @@ -14922,12 +15152,44 @@ var ts; } return result; } + function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { + if (!errorLocation || (errorLocation.kind === 69 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + return false; + } + var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); + var location = container; + while (location) { + if (ts.isClassLike(location.parent)) { + var classSymbol = getSymbolOfNode(location.parent); + if (!classSymbol) { + break; + } + // Check to see if a static member exists. + var constructorType = getTypeOfSymbol(classSymbol); + if (getPropertyOfType(constructorType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg), symbolToString(classSymbol)); + return true; + } + // No static member is present. + // Check if we're in an instance method and look for a relevant instance member. + if (location === container && !(location.flags & 64 /* Static */)) { + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + if (getPropertyOfType(instanceType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return true; + } + } + } + location = location.parent; + } + return false; + } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); // 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 213 /* VariableDeclaration */), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -14948,10 +15210,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 223 /* ImportEqualsDeclaration */) { + if (node.kind === 224 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 224 /* ImportDeclaration */) { + while (node && node.kind !== 225 /* ImportDeclaration */) { node = node.parent; } return node; @@ -14961,7 +15223,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 234 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 235 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -15063,17 +15325,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 225 /* ImportClause */: + case 226 /* ImportClause */: return getTargetOfImportClause(node); - case 226 /* NamespaceImport */: + case 227 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 228 /* ImportSpecifier */: + case 229 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 232 /* ExportSpecifier */: + case 233 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -15118,11 +15380,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 229 /* ExportAssignment */) { + if (node.kind === 230 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 232 /* ExportSpecifier */) { + else if (node.kind === 233 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -15135,7 +15397,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 223 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 224 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -15148,13 +15410,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 136 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 223 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 224 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -15174,9 +15436,9 @@ var ts; return undefined; } } - else if (name.kind === 135 /* QualifiedName */ || name.kind === 168 /* PropertyAccessExpression */) { - var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 136 /* QualifiedName */ || name.kind === 169 /* PropertyAccessExpression */) { + var left = name.kind === 136 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 136 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -15196,6 +15458,9 @@ var ts; return symbol.flags & meaning ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { + return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); + } + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } @@ -15210,19 +15475,28 @@ var ts; if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { - return symbol; + // merged symbol is module declaration symbol combined with all augmentations + return getMergedSymbol(symbol); } } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReferenceLiteral.text); var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { - return sourceFile.symbol; + // merged symbol is module declaration symbol combined with all augmentations + return getMergedSymbol(sourceFile.symbol); } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; + if (moduleNotFoundError) { + // report errors only if it was requested + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + } + return undefined; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + if (moduleNotFoundError) { + // report errors only if it was requested + error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + } + return undefined; } // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. @@ -15350,7 +15624,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 === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 145 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -15421,17 +15695,17 @@ var ts; } } switch (location_1.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -15472,7 +15746,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 232 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -15509,7 +15783,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, 232 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -15582,8 +15856,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 220 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 250 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 251 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -15619,12 +15892,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 154 /* TypeQuery */) { + if (entityName.parent.kind === 155 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 168 /* PropertyAccessExpression */ || - entityName.parent.kind === 223 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 136 /* QualifiedName */ || entityName.kind === 169 /* PropertyAccessExpression */ || + entityName.parent.kind === 224 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -15679,15 +15952,20 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 160 /* ParenthesizedType */) { + while (node.kind === 161 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 218 /* TypeAliasDeclaration */) { + if (node.kind === 219 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } + function isTopLevelInExternalModuleAugmentation(node) { + return node && node.parent && + node.parent.kind === 222 /* ModuleBlock */ && + ts.isExternalModuleAugmentation(node.parent.parent); + } function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -15696,10 +15974,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return "(Anonymous class)"; - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -15954,7 +16232,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 250 /* SourceFile */ || declaration.parent.kind === 221 /* ModuleBlock */; + return declaration.parent.kind === 251 /* SourceFile */ || declaration.parent.kind === 222 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -16215,70 +16493,74 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 165 /* BindingElement */: + case 166 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 213 /* VariableDeclaration */: + case 214 /* 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 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 215 /* FunctionDeclaration */: - case 219 /* EnumDeclaration */: - case 223 /* ImportEqualsDeclaration */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 216 /* FunctionDeclaration */: + case 220 /* EnumDeclaration */: + case 224 /* ImportEqualsDeclaration */: + // external module augmentation is always visible + if (ts.isExternalModuleAugmentation(node)) { + return true; + } var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && - !(node.kind !== 223 /* ImportEqualsDeclaration */ && parent_4.kind !== 250 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 224 /* ImportEqualsDeclaration */ && parent_4.kind !== 251 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.flags & (16 /* Private */ | 32 /* 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 144 /* Constructor */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: - case 138 /* Parameter */: - case 221 /* ModuleBlock */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: - case 151 /* TypeReference */: - case 156 /* ArrayType */: - case 157 /* TupleType */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - case 160 /* ParenthesizedType */: + case 145 /* Constructor */: + case 149 /* ConstructSignature */: + case 148 /* CallSignature */: + case 150 /* IndexSignature */: + case 139 /* Parameter */: + case 222 /* ModuleBlock */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 156 /* TypeLiteral */: + case 152 /* TypeReference */: + case 157 /* ArrayType */: + case 158 /* TupleType */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: + case 161 /* 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 225 /* ImportClause */: - case 226 /* NamespaceImport */: - case 228 /* ImportSpecifier */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: + case 229 /* ImportSpecifier */: return false; // Type parameters are always visible - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: // Source file is always visible - case 250 /* SourceFile */: + case 251 /* SourceFile */: return true; // Export assignments do not create name bindings outside the module - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -16287,10 +16569,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 229 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 230 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 232 /* ExportSpecifier */) { + else if (node.parent.kind === 233 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -16313,7 +16595,9 @@ var ts; var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); + if (importSymbol) { + buildVisibleNodeList(importSymbol.declarations); + } } }); } @@ -16382,14 +16666,14 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 213 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 214 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 // Every class automatically contains a static property member named 'prototype', // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. // It is an error to explicitly declare a static property member with the name 'prototype'. - var classType = getDeclaredTypeOfSymbol(prototype.parent); + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } // Return the type of the given property in the given type, or undefined if no such property exists @@ -16413,7 +16697,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -16421,7 +16705,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 136 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 137 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { @@ -16441,7 +16725,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 163 /* ObjectBindingPattern */) { + if (pattern.kind === 164 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { @@ -16489,11 +16773,11 @@ var ts; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { - // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 202 /* ForInStatement */) { - return anyType; + // A variable declared in a for..in statement is always of type string + if (declaration.parent.parent.kind === 203 /* ForInStatement */) { + return stringType; } - if (declaration.parent.parent.kind === 203 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 204 /* 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, @@ -16507,11 +16791,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138 /* Parameter */) { + if (declaration.kind === 139 /* 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 === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); + if (func.kind === 147 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -16527,7 +16811,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 248 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 249 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -16583,7 +16867,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 189 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 190 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -16599,7 +16883,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) { - return pattern.kind === 163 /* ObjectBindingPattern */ + return pattern.kind === 164 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -16621,10 +16905,10 @@ 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 === 247 /* PropertyAssignment */) { + if (declaration.kind === 248 /* PropertyAssignment */) { return type; } - if (type.flags & 134217728 /* PredicateType */ && (declaration.kind === 141 /* PropertyDeclaration */ || declaration.kind === 140 /* PropertySignature */)) { + if (type.flags & 134217728 /* PredicateType */ && (declaration.kind === 142 /* PropertyDeclaration */ || declaration.kind === 141 /* PropertySignature */)) { return type; } return getWidenedType(type); @@ -16634,7 +16918,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 139 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -16649,21 +16933,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 246 /* CatchClause */) { + if (declaration.parent.kind === 247 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 229 /* ExportAssignment */) { + if (declaration.kind === 230 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle module.exports = expr - if (declaration.kind === 183 /* BinaryExpression */) { + if (declaration.kind === 184 /* BinaryExpression */) { return links.type = checkExpression(declaration.right); } - if (declaration.kind === 168 /* PropertyAccessExpression */) { + if (declaration.kind === 169 /* PropertyAccessExpression */) { // Declarations only exist for property access expressions for certain // special assignment kinds - if (declaration.parent.kind === 183 /* BinaryExpression */) { + if (declaration.parent.kind === 184 /* BinaryExpression */) { // Handle exports.p = expr or this.p = expr or className.prototype.method = expr return links.type = checkExpressionCached(declaration.parent.right); } @@ -16693,7 +16977,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 145 /* GetAccessor */) { + if (accessor.kind === 146 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -16709,8 +16993,8 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 146 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 147 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -16739,7 +17023,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 146 /* 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)); } } @@ -16839,9 +17123,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 216 /* ClassDeclaration */ || node.kind === 188 /* ClassExpression */ || - node.kind === 215 /* FunctionDeclaration */ || node.kind === 175 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */ || node.kind === 176 /* ArrowFunction */) { + if (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */ || + node.kind === 216 /* FunctionDeclaration */ || node.kind === 176 /* FunctionExpression */ || + node.kind === 144 /* MethodDeclaration */ || node.kind === 177 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -16851,7 +17135,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, 217 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 218 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -16860,8 +17144,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 217 /* InterfaceDeclaration */ || node.kind === 216 /* ClassDeclaration */ || - node.kind === 188 /* ClassExpression */ || node.kind === 218 /* TypeAliasDeclaration */) { + if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 217 /* ClassDeclaration */ || + node.kind === 189 /* ClassExpression */ || node.kind === 219 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -17001,7 +17285,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 218 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -17033,7 +17317,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217 /* InterfaceDeclaration */) { + if (declaration.kind === 218 /* InterfaceDeclaration */) { if (declaration.flags & 262144 /* ContainsThis */) { return false; } @@ -17089,7 +17373,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 218 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 219 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -17122,7 +17406,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -17178,11 +17462,11 @@ var ts; case 120 /* BooleanKeyword */: case 131 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: return true; - case 156 /* ArrayType */: + case 157 /* ArrayType */: return isIndependentType(node.elementType); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -17195,7 +17479,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 !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 145 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -17216,12 +17500,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -17783,7 +18067,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 144 /* Constructor */ ? + var classType = declaration.kind === 145 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : @@ -17800,7 +18084,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 162 /* StringLiteralType */) { + if (param.type && param.type.kind === 163 /* StringLiteralType */) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -17826,8 +18110,8 @@ var ts; else { // 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 === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); + if (declaration.kind === 146 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 147 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -17845,19 +18129,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: // 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). @@ -17944,7 +18228,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 145 /* Constructor */ || signature.declaration.kind === 149 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -17981,7 +18265,7 @@ var ts; : undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 138 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -18014,7 +18298,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138 /* TypeParameter */).parent); } function getTypeListId(types) { if (types) { @@ -18113,7 +18397,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 152 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -18145,9 +18429,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: return declaration; } } @@ -18388,9 +18672,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 === 217 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 218 /* InterfaceDeclaration */)) { if (!(container.flags & 64 /* Static */) && - (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { + (container.kind !== 145 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -18434,36 +18718,36 @@ var ts; return esSymbolType; case 103 /* VoidKeyword */: return voidType; - case 161 /* ThisType */: + case 162 /* ThisType */: return getTypeFromThisTypeNode(node); - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: return getTypeFromStringLiteralTypeNode(node); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return getTypeFromTypeReference(node); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return getTypeFromPredicateTypeNode(node); - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 157 /* TupleType */: + case 158 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 158 /* UnionType */: + case 159 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 159 /* IntersectionType */: + case 160 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 156 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 69 /* Identifier */: - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -18654,27 +18938,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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 247 /* PropertyAssignment */: + case 248 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -18703,6 +18987,9 @@ var ts; function compareTypesIdentical(source, target) { return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } + function compareTypesAssignable(source, target) { + return checkTypeRelatedTo(source, target, assignableRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } @@ -18715,47 +19002,60 @@ var ts; function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } + function isSignatureAssignableTo(source, target, ignoreReturnTypes) { + return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function isSignatureAssignableTo(source, target, ignoreReturnTypes) { + function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return true; + return -1 /* True */; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return 0 /* False */; } // Spec 1.0 Section 3.8.3 & 3.8.4: // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); + var result = -1 /* True */; var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); + var sourceParams = source.parameters; + var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var related = isTypeAssignableTo(t, s) || isTypeAssignableTo(s, t); + var s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target); + var related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors); if (!related) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); + } + return 0 /* False */; } + result &= related; } if (!ignoreReturnTypes) { var targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) { - return true; + return result; } var sourceReturnType = getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions if (targetReturnType.flags & 134217728 /* PredicateType */ && targetReturnType.predicate.kind === 1 /* Identifier */) { if (!(sourceReturnType.flags & 134217728 /* PredicateType */)) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; } } - return isTypeAssignableTo(sourceReturnType, targetReturnType); + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); } - return true; + return result; } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); @@ -18812,22 +19112,12 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; - var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } else if (errorInfo) { - // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), - // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, - // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context - // where errors were being reported. - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); } @@ -18835,6 +19125,7 @@ var ts; } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { + ts.Debug.assert(!!errorNode); errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } function reportRelationError(message, source, target) { @@ -18973,14 +19264,14 @@ var ts; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - var apparentType = getApparentType(source); + 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 (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + if (apparentSource.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 16777726 /* Primitive */); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } @@ -19043,6 +19334,7 @@ var ts; // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. + ts.Debug.assert(!!errorNode); errorNode = prop.valueDeclaration; reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } @@ -19140,7 +19432,7 @@ var ts; var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { - if (elaborateErrors && related === 2 /* Failed */) { + if (reportErrors && related === 2 /* Failed */) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. relation[id] = 3 /* FailedAndReported */; @@ -19354,7 +19646,7 @@ var ts; } // don't elaborate the primitive apparent types (like Number) // because the actual primitives will have already been reported. - if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } return 0 /* False */; @@ -19363,72 +19655,10 @@ var ts; return result; } /** - * See signatureAssignableTo, signatureAssignableTo + * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, reportErrors) { - // TODO (drosen): De-duplicate code between related functions. - if (source === target) { - return -1 /* True */; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0 /* False */; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1 /* True */; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, /*reportErrors*/ false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0 /* False */; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) { - return result; - } - var sourceReturnType = getReturnTypeOfSignature(source); - // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions - if (targetReturnType.flags & 134217728 /* PredicateType */ && targetReturnType.predicate.kind === 1 /* Identifier */) { - if (!(sourceReturnType.flags & 134217728 /* PredicateType */)) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0 /* False */; - } - } - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -19844,22 +20074,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 138 /* Parameter */: + case 139 /* 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 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -20196,10 +20426,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 154 /* TypeQuery */: + case 155 /* TypeQuery */: return true; case 69 /* Identifier */: - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: node = node.parent; continue; default: @@ -20241,55 +20471,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: - case 166 /* ArrayLiteralExpression */: - case 167 /* ObjectLiteralExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: - case 174 /* ParenthesizedExpression */: - case 181 /* PrefixUnaryExpression */: - case 177 /* DeleteExpression */: - case 180 /* AwaitExpression */: - case 178 /* TypeOfExpression */: - case 179 /* VoidExpression */: - case 182 /* PostfixUnaryExpression */: - case 186 /* YieldExpression */: - case 184 /* ConditionalExpression */: - case 187 /* SpreadElementExpression */: - case 194 /* Block */: - case 195 /* VariableStatement */: - case 197 /* ExpressionStatement */: - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 206 /* ReturnStatement */: - case 207 /* WithStatement */: - case 208 /* SwitchStatement */: - case 243 /* CaseClause */: - case 244 /* DefaultClause */: - case 209 /* LabeledStatement */: - case 210 /* ThrowStatement */: - case 211 /* TryStatement */: - case 246 /* CatchClause */: - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: - case 240 /* JsxAttribute */: - case 241 /* JsxSpreadAttribute */: - case 237 /* JsxOpeningElement */: - case 242 /* JsxExpression */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: + case 167 /* ArrayLiteralExpression */: + case 168 /* ObjectLiteralExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: + case 175 /* ParenthesizedExpression */: + case 182 /* PrefixUnaryExpression */: + case 178 /* DeleteExpression */: + case 181 /* AwaitExpression */: + case 179 /* TypeOfExpression */: + case 180 /* VoidExpression */: + case 183 /* PostfixUnaryExpression */: + case 187 /* YieldExpression */: + case 185 /* ConditionalExpression */: + case 188 /* SpreadElementExpression */: + case 195 /* Block */: + case 196 /* VariableStatement */: + case 198 /* ExpressionStatement */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 207 /* ReturnStatement */: + case 208 /* WithStatement */: + case 209 /* SwitchStatement */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: + case 210 /* LabeledStatement */: + case 211 /* ThrowStatement */: + case 212 /* TryStatement */: + case 247 /* CatchClause */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: + case 241 /* JsxAttribute */: + case 242 /* JsxSpreadAttribute */: + case 238 /* JsxOpeningElement */: + case 243 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -20301,7 +20531,7 @@ var ts; // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & 3 /* Variable */) { if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - var declaration = ts.getDeclarationOfKind(symbol, 213 /* VariableDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* VariableDeclaration */); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -20309,13 +20539,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 198 /* IfStatement */: - case 184 /* ConditionalExpression */: - case 183 /* BinaryExpression */: + case 199 /* IfStatement */: + case 185 /* ConditionalExpression */: + case 184 /* BinaryExpression */: nodeStack.push({ node: node, child: child }); break; - case 250 /* SourceFile */: - case 220 /* ModuleDeclaration */: + case 251 /* SourceFile */: + case 221 /* ModuleDeclaration */: // Stop at the first containing file or module declaration break loop; } @@ -20327,19 +20557,19 @@ var ts; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 198 /* IfStatement */: + case 199 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node_1.expression) { type = narrowType(type, node_1.expression, /*assumeTrue*/ child === node_1.thenStatement); } break; - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node_1.condition) { type = narrowType(type, node_1.condition, /*assumeTrue*/ child === node_1.whenTrue); } break; - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node_1.right) { if (node_1.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { @@ -20367,7 +20597,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 178 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 179 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; @@ -20383,10 +20613,6 @@ var ts; if (typeInfo && typeInfo.type === undefinedType) { return type; } - // If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive - if (!!(type.flags & 1 /* Any */) && typeInfo && assumeTrue) { - return typeInfo.type; - } var flags; if (typeInfo) { flags = typeInfo.flags; @@ -20397,6 +20623,10 @@ var ts; } // At this point we can bail if it's not a union if (!(type.flags & 16384 /* Union */)) { + // If we're on the true branch and the type is a subtype, we should return the primitive type + if (assumeTrue && typeInfo && isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } // If the active non-union type would be removed from a union by this type guard, return an empty union return filterUnion(type) ? type : emptyUnionType; } @@ -20525,7 +20755,7 @@ var ts; return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); } function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 169 /* ElementAccessExpression */ || expression.kind === 168 /* PropertyAccessExpression */) { + if (expression.kind === 170 /* ElementAccessExpression */ || expression.kind === 169 /* PropertyAccessExpression */) { var accessExpression = expression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 /* Identifier */ && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { @@ -20538,8 +20768,8 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } @@ -20547,11 +20777,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 170 /* CallExpression */: + case 171 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -20566,20 +20796,20 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; - case 169 /* ElementAccessExpression */: - case 168 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 169 /* PropertyAccessExpression */: return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 174 /* ParenthesizedExpression */) { + while (expression.kind === 175 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -20594,7 +20824,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 176 /* ArrowFunction */) { + if (container.kind === 177 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -20625,7 +20855,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 246 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 247 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -20641,12 +20871,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container container = symbol.valueDeclaration; - while (container.kind !== 214 /* VariableDeclarationList */) { + while (container.kind !== 215 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 195 /* VariableStatement */) { + if (container.kind === 196 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -20667,7 +20897,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { + if (container.kind === 142 /* PropertyDeclaration */ || container.kind === 145 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -20681,32 +20911,32 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 176 /* ArrowFunction */) { + if (container.kind === 177 /* 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 /* ES6 */); } switch (container.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* 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 219 /* EnumDeclaration */: + case 220 /* 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 144 /* Constructor */: + case 145 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: if (container.flags & 64 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -20719,7 +20949,7 @@ var ts; } // 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 (ts.isInJavaScriptFile(node) && container.kind === 175 /* FunctionExpression */) { + if (ts.isInJavaScriptFile(node) && container.kind === 176 /* FunctionExpression */) { if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.protoype.y = f @@ -20736,19 +20966,19 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138 /* Parameter */) { + if (n.kind === 139 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 170 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 176 /* ArrowFunction */) { + while (container && container.kind === 177 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } @@ -20762,16 +20992,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 136 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 137 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 136 /* ComputedPropertyName */) { + if (current && current.kind === 137 /* 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 === 167 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -20792,7 +21022,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 167 /* ObjectLiteralExpression */) { + if (container.parent.kind === 168 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -20812,7 +21042,7 @@ var ts; } return unknownType; } - if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 145 /* 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; @@ -20827,7 +21057,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 === 144 /* Constructor */; + return container.kind === 145 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -20835,21 +21065,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 === 167 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */) { if (container.flags & 64 /* Static */) { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */; + return container.kind === 144 /* MethodDeclaration */ || + container.kind === 143 /* MethodSignature */ || + container.kind === 146 /* GetAccessor */ || + container.kind === 147 /* SetAccessor */; } else { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */ || - container.kind === 141 /* PropertyDeclaration */ || - container.kind === 140 /* PropertySignature */ || - container.kind === 144 /* Constructor */; + return container.kind === 144 /* MethodDeclaration */ || + container.kind === 143 /* MethodSignature */ || + container.kind === 146 /* GetAccessor */ || + container.kind === 147 /* SetAccessor */ || + container.kind === 142 /* PropertyDeclaration */ || + container.kind === 141 /* PropertySignature */ || + container.kind === 145 /* Constructor */; } } } @@ -20891,7 +21121,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138 /* Parameter */) { + if (declaration.kind === 139 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -20924,7 +21154,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 139 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -20935,8 +21165,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 === 144 /* Constructor */ || - functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { + functionDecl.kind === 145 /* Constructor */ || + functionDecl.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -20958,7 +21188,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 172 /* TaggedTemplateExpression */) { + if (template.parent.kind === 173 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -21089,13 +21319,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 240 /* JsxAttribute */) { + if (attribute.kind === 241 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 241 /* JsxSpreadAttribute */) { + else if (attribute.kind === 242 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -21133,40 +21363,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 213 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 139 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 166 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 176 /* ArrowFunction */: - case 206 /* ReturnStatement */: + case 177 /* ArrowFunction */: + case 207 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 247 /* PropertyAssignment */: + case 248 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 192 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 185 /* TemplateExpression */); + case 193 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 186 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return getContextualType(parent); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return getContextualType(parent); - case 240 /* JsxAttribute */: - case 241 /* JsxSpreadAttribute */: + case 241 /* JsxAttribute */: + case 242 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -21183,7 +21413,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 175 /* FunctionExpression */ || node.kind === 176 /* ArrowFunction */; + return node.kind === 176 /* FunctionExpression */ || node.kind === 177 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -21197,7 +21427,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -21260,13 +21490,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 183 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 184 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 247 /* PropertyAssignment */) { + if (parent.kind === 248 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 166 /* ArrayLiteralExpression */) { + if (parent.kind === 167 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -21282,8 +21512,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 165 /* BindingElement */ && !!node.initializer) || - (node.kind === 183 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 166 /* BindingElement */ && !!node.initializer) || + (node.kind === 184 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -21292,7 +21522,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 187 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 188 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -21316,7 +21546,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 187 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 188 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -21331,7 +21561,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 === 164 /* ArrayBindingPattern */ || pattern.kind === 166 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 165 /* ArrayBindingPattern */ || pattern.kind === 167 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -21339,7 +21569,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 189 /* OmittedExpression */) { + if (patternElement.kind !== 190 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -21354,7 +21584,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 137 /* 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, @@ -21411,24 +21641,24 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 163 /* ObjectBindingPattern */ || contextualType.pattern.kind === 167 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 164 /* ObjectBindingPattern */ || contextualType.pattern.kind === 168 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 247 /* PropertyAssignment */ || - memberDecl.kind === 248 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 248 /* PropertyAssignment */ || + memberDecl.kind === 249 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 247 /* PropertyAssignment */) { + if (memberDecl.kind === 248 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 143 /* MethodDeclaration */) { + else if (memberDecl.kind === 144 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 248 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 249 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -21436,8 +21666,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 === 247 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 248 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 248 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 249 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -21471,7 +21701,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 146 /* GetAccessor */ || memberDecl.kind === 147 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -21538,13 +21768,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: checkJsxExpression(child); break; - case 235 /* JsxElement */: + case 236 /* JsxElement */: checkJsxElement(child); break; - case 236 /* JsxSelfClosingElement */: + case 237 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -21562,7 +21792,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135 /* QualifiedName */) { + if (tagName.kind === 136 /* QualifiedName */) { return false; } else { @@ -21672,6 +21902,7 @@ var ts; if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } + return unknownSymbol; } } function lookupClassTag(node) { @@ -21771,21 +22002,25 @@ var ts; if (links.jsxFlags & 4 /* ValueElement */) { // Get the element instance type (the result of newing or invoking this tag) var elemInstanceType = getJsxElementInstanceType(node); - // Is this is a stateless function component? See if its single signature is - // assignable to the JSX Element Type - var callSignature = getSingleCallSignature(getTypeOfSymbol(sym)); - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType) && (paramType.flags & 80896 /* ObjectType */)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); + var elemClassType = getJsxGlobalElementClassType(); + if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { + // Is this is a stateless function component? See if its single signature's return type is + // assignable to the JSX Element Type + var elemType = getTypeOfSymbol(sym); + var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); + var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return links.resolvedJsxType = paramType; } - return paramType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } @@ -21902,11 +22137,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 === 240 /* JsxAttribute */) { + if (node.attributes[i].kind === 241 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 241 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 242 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -21936,7 +22171,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 : 141 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 142 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; @@ -21953,7 +22188,7 @@ var ts; var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (left.kind === 95 /* SuperKeyword */) { - var errorNode = node.kind === 168 /* PropertyAccessExpression */ ? + var errorNode = node.kind === 169 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -21963,7 +22198,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 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 144 /* 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); @@ -22050,7 +22285,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 168 /* PropertyAccessExpression */ + var left = node.kind === 169 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -22062,11 +22297,58 @@ var ts; } return true; } + /** + * Return the symbol of the for-in variable declared or referenced by the given for-in statement. + */ + function getForInVariableSymbol(node) { + var initializer = node.initializer; + if (initializer.kind === 215 /* VariableDeclarationList */) { + var variable = initializer.declarations[0]; + if (variable && !ts.isBindingPattern(variable.name)) { + return getSymbolOfNode(variable); + } + } + else if (initializer.kind === 69 /* Identifier */) { + return getResolvedSymbol(initializer); + } + return undefined; + } + /** + * Return true if the given type is considered to have numeric property names. + */ + function hasNumericPropertyNames(type) { + return getIndexTypeOfType(type, 1 /* Number */) && !getIndexTypeOfType(type, 0 /* String */); + } + /** + * Return true if given node is an expression consisting of an identifier (possibly parenthesized) + * that references a for-in variable for an object with numeric property names. + */ + function isForInVariableForNumericPropertyNames(expr) { + var e = skipParenthesizedNodes(expr); + if (e.kind === 69 /* Identifier */) { + var symbol = getResolvedSymbol(e); + if (symbol.flags & 3 /* Variable */) { + var child = expr; + var node = expr.parent; + while (node) { + if (node.kind === 203 /* ForInStatement */ && + child === node.statement && + getForInVariableSymbol(node) === symbol && + hasNumericPropertyNames(checkExpression(node.expression))) { + return true; + } + child = node; + node = node.parent; + } + } + } + return false; + } function checkIndexedAccess(node) { // Grammar checking if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 171 /* NewExpression */ && node.parent.expression === node) { + var sourceFile = ts.getSourceFileOfNode(node); + if (node.parent.kind === 172 /* 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); @@ -22115,7 +22397,7 @@ var ts; // Check for compatible indexer types. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); if (numberIndexType) { return numberIndexType; @@ -22128,7 +22410,9 @@ var ts; } // Fall back to any. if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + 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; } @@ -22147,7 +22431,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 169 /* ElementAccessExpression */ || indexArgumentExpression.kind === 168 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 170 /* ElementAccessExpression */ || indexArgumentExpression.kind === 169 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -22202,10 +22486,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 139 /* Decorator */) { + else if (node.kind !== 140 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -22271,7 +22555,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 187 /* SpreadElementExpression */) { + if (arg && arg.kind === 188 /* SpreadElementExpression */) { return i; } } @@ -22283,13 +22567,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 === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* 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 adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 185 /* TemplateExpression */) { + if (tagExpression.template.kind === 186 /* 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; @@ -22306,7 +22590,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 139 /* Decorator */) { + else if (node.kind === 140 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -22315,7 +22599,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 === 171 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 172 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -22394,7 +22678,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 !== 189 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 190 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -22454,7 +22738,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 !== 189 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 190 /* 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, arg); @@ -22486,16 +22770,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 185 /* TemplateExpression */) { + if (template.kind === 186 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 139 /* Decorator */) { + else if (node.kind === 140 /* 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. @@ -22520,19 +22804,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139 /* Decorator */) { + if (node.kind === 140 /* Decorator */) { switch (node.parent.kind) { - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* 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. @@ -22542,7 +22826,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 138 /* Parameter */: + case 139 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -22566,25 +22850,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* 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 === 138 /* Parameter */) { + if (node.kind === 139 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 144 /* Constructor */) { + if (node.kind === 145 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 142 /* PropertyDeclaration */ || + node.kind === 144 /* MethodDeclaration */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* 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 @@ -22611,21 +22895,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 138 /* Parameter */) { + if (node.kind === 139 /* Parameter */) { node = node.parent; - if (node.kind === 144 /* Constructor */) { + if (node.kind === 145 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 142 /* PropertyDeclaration */ || + node.kind === 144 /* MethodDeclaration */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* 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 @@ -22636,7 +22920,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralTypeForText(element.name.text); - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; @@ -22662,21 +22946,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 paramter decorator - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 138 /* Parameter */) { + if (node.kind === 139 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 141 /* PropertyDeclaration */) { + if (node.kind === 142 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 144 /* MethodDeclaration */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -22708,10 +22992,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 === 139 /* Decorator */) { + if (node.kind === 140 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 172 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -22723,8 +23007,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 === 139 /* Decorator */ || - (argIndex === 0 && node.kind === 172 /* TaggedTemplateExpression */)) { + if (node.kind === 140 /* Decorator */ || + (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -22733,11 +23017,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139 /* Decorator */) { + if (node.kind === 140 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 172 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -22746,8 +23030,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 172 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 139 /* Decorator */; + var isTaggedTemplate = node.kind === 173 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 140 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -23093,16 +23377,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138 /* Parameter */: + case 139 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -23139,16 +23423,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 170 /* CallExpression */) { + if (node.kind === 171 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 171 /* NewExpression */) { + else if (node.kind === 172 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 172 /* TaggedTemplateExpression */) { + else if (node.kind === 173 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 139 /* Decorator */) { + else if (node.kind === 140 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -23176,12 +23460,12 @@ var ts; if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 171 /* NewExpression */) { + if (node.kind === 172 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 144 /* Constructor */ && - declaration.kind !== 148 /* ConstructSignature */ && - declaration.kind !== 153 /* ConstructorType */) { + declaration.kind !== 145 /* Constructor */ && + declaration.kind !== 149 /* ConstructSignature */ && + declaration.kind !== 154 /* ConstructorType */) { // 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 // in a JS file @@ -23242,7 +23526,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189 /* OmittedExpression */) { + if (element.kind !== 190 /* OmittedExpression */) { if (element.name.kind === 69 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -23307,7 +23591,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 194 /* Block */) { + if (func.body.kind !== 195 /* 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 @@ -23437,7 +23721,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 !== 194 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { return; } var hasExplicitReturn = func.flags & 1048576 /* HasExplicitReturn */; @@ -23463,20 +23747,16 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 175 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 176 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); @@ -23510,18 +23790,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 144 /* MethodDeclaration */ && node.kind !== 143 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { // return is not necessary in the body of generators @@ -23536,7 +23813,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 194 /* Block */) { + if (node.body.kind === 195 /* Block */) { checkSourceElement(node.body); } else { @@ -23588,17 +23865,17 @@ var ts; // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 168 /* PropertyAccessExpression */: { + case 169 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: // old compiler doesn't check indexed access return true; - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -23607,11 +23884,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: { + case 169 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; } - case 169 /* ElementAccessExpression */: { + case 170 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9 /* StringLiteral */) { @@ -23621,7 +23898,7 @@ var ts; } return false; } - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -23767,9 +24044,9 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 247 /* PropertyAssignment */ || p.kind === 248 /* ShorthandPropertyAssignment */) { + if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { var name_13 = p.name; - if (name_13.kind === 136 /* ComputedPropertyName */) { + if (name_13.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(name_13); } if (isComputedNonLiteralName(name_13)) { @@ -23782,7 +24059,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - if (p.kind === 248 /* ShorthandPropertyAssignment */) { + if (p.kind === 249 /* ShorthandPropertyAssignment */) { checkDestructuringAssignment(p, type); } else { @@ -23808,8 +24085,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189 /* OmittedExpression */) { - if (e.kind !== 187 /* SpreadElementExpression */) { + if (e.kind !== 190 /* OmittedExpression */) { + if (e.kind !== 188 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -23834,7 +24111,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 183 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 184 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -23848,7 +24125,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 248 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 249 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -23858,14 +24135,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 183 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 167 /* ObjectLiteralExpression */) { + if (target.kind === 168 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 166 /* ArrayLiteralExpression */) { + if (target.kind === 167 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -23882,7 +24159,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 167 /* ObjectLiteralExpression */ || left.kind === 166 /* ArrayLiteralExpression */)) { + if (operator === 56 /* EqualsToken */ && (left.kind === 168 /* ObjectLiteralExpression */ || left.kind === 167 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -24151,7 +24428,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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -24162,7 +24439,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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -24192,7 +24469,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 135 /* QualifiedName */) { + if (node.kind === 136 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -24204,9 +24481,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 169 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 136 /* 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); } @@ -24233,7 +24510,7 @@ var ts; return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: return checkStringLiteralExpression(node); @@ -24241,58 +24518,58 @@ var ts; return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return checkCallExpression(node); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return checkClassExpression(node); - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 178 /* TypeOfExpression */: + case 179 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: return checkAssertion(node); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return checkDeleteExpression(node); - case 179 /* VoidExpression */: + case 180 /* VoidExpression */: return checkVoidExpression(node); - case 180 /* AwaitExpression */: + case 181 /* AwaitExpression */: return checkAwaitExpression(node); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 187 /* SpreadElementExpression */: + case 188 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 189 /* OmittedExpression */: + case 190 /* OmittedExpression */: return undefinedType; - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return checkYieldExpression(node); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return checkJsxExpression(node); - case 235 /* JsxElement */: + case 236 /* JsxElement */: return checkJsxElement(node); - case 236 /* JsxSelfClosingElement */: + case 237 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 237 /* JsxOpeningElement */: + case 238 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -24320,7 +24597,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 56 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 145 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -24337,9 +24614,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 143 /* MethodDeclaration */ || - node.kind === 215 /* FunctionDeclaration */ || - node.kind === 175 /* FunctionExpression */; + return node.kind === 144 /* MethodDeclaration */ || + node.kind === 216 /* FunctionDeclaration */ || + node.kind === 176 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -24353,105 +24630,98 @@ var ts; } return -1; } - function isInLegalParameterTypePredicatePosition(node) { - switch (node.parent.kind) { - case 176 /* ArrowFunction */: - case 147 /* CallSignature */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 152 /* FunctionType */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return node === node.parent.type; + function checkTypePredicate(node) { + var parent = getTypePredicateParent(node); + if (!parent) { + return; + } + var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); + if (!returnType || !(returnType.flags & 134217728 /* PredicateType */)) { + return; + } + var parameterName = node.parameterName; + if (parameterName.kind === 162 /* ThisType */) { + getTypeFromThisTypeNode(parameterName); + } + else { + var typePredicate = returnType.predicate; + if (typePredicate.parameterIndex >= 0) { + if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type); + } + } + else if (parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { + var name_14 = _a[_i].name; + if ((name_14.kind === 164 /* ObjectBindingPattern */ || + name_14.kind === 165 /* ArrayBindingPattern */) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + hasReportedError = true; + break; + } + } + if (!hasReportedError) { + error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } } - return false; } - function isInLegalThisTypePredicatePosition(node) { - if (isInLegalParameterTypePredicatePosition(node)) { - return true; - } + function getTypePredicateParent(node) { switch (node.parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 145 /* GetAccessor */: - return node === node.parent.type; + case 177 /* ArrowFunction */: + case 148 /* CallSignature */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 153 /* FunctionType */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + var parent_6 = node.parent; + if (node === parent_6.type) { + return parent_6; + } + } + } + function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var name_15 = _a[_i].name; + if (name_15.kind === 69 /* Identifier */ && + name_15.text === predicateVariableName) { + error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); + return true; + } + else if (name_15.kind === 165 /* ArrayBindingPattern */ || + name_15.kind === 164 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + return true; + } + } } - return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 149 /* IndexSignature */) { + if (node.kind === 150 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 152 /* FunctionType */ || node.kind === 215 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || - node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || - node.kind === 148 /* ConstructSignature */) { + else if (node.kind === 153 /* FunctionType */ || node.kind === 216 /* FunctionDeclaration */ || node.kind === 154 /* ConstructorType */ || + node.kind === 148 /* CallSignature */ || node.kind === 145 /* Constructor */ || + node.kind === 149 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150 /* TypePredicate */) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - if (!returnType || !(returnType.flags & 134217728 /* PredicateType */)) { - return; - } - var typePredicate = returnType.predicate; - var typePredicateNode = node.type; - checkSourceElement(typePredicateNode); - if (ts.isIdentifierTypePredicate(typePredicate)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 163 /* ObjectBindingPattern */ || - param.name.kind === 164 /* ArrayBindingPattern */) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 /* Identifier */ && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 164 /* ArrayBindingPattern */ || - element.name.kind === 163 /* ObjectBindingPattern */) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - } - else { - checkSourceElement(node.type); - } - } + checkSourceElement(node.type); if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 147 /* CallSignature */: + case 148 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -24479,7 +24749,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 217 /* InterfaceDeclaration */) { + if (node.kind === 218 /* 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 @@ -24556,7 +24826,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 170 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + return n.kind === 171 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -24577,12 +24847,12 @@ var ts; if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 175 /* FunctionExpression */ && n.kind !== 215 /* FunctionDeclaration */) { + else if (n.kind !== 176 /* FunctionExpression */ && n.kind !== 216 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 141 /* PropertyDeclaration */ && + return n.kind === 142 /* PropertyDeclaration */ && !(n.flags & 64 /* Static */) && !!n.initializer; } @@ -24612,7 +24882,7 @@ var ts; var superCallStatement; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 197 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 198 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -24640,7 +24910,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 145 /* GetAccessor */) { + if (node.kind === 146 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { if (node.flags & 1048576 /* HasExplicitReturn */) { if (compilerOptions.noImplicitReturns) { @@ -24655,13 +24925,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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* 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 === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; + var otherKind = node.kind === 146 /* GetAccessor */ ? 147 /* SetAccessor */ : 146 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { @@ -24680,7 +24950,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 167 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 168 /* ObjectLiteralExpression */) { checkSourceElement(node.body); } else { @@ -24771,9 +25041,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 217 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 218 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 148 /* CallSignature */ || signatureDeclarationNode.kind === 149 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 148 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -24793,9 +25063,9 @@ var ts; var flags = ts.getCombinedNodeFlags(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 !== 217 /* InterfaceDeclaration */ && - n.parent.kind !== 216 /* ClassDeclaration */ && - n.parent.kind !== 188 /* ClassExpression */ && + if (n.parent.kind !== 218 /* InterfaceDeclaration */ && + n.parent.kind !== 217 /* ClassDeclaration */ && + n.parent.kind !== 189 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 4 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -24883,7 +25153,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 === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && + var reportError = (node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && (node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -24925,7 +25195,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 217 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 218 /* InterfaceDeclaration */ || node.parent.kind === 156 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -24936,7 +25206,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 === 215 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { + if (node.kind === 216 /* FunctionDeclaration */ || node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */ || node.kind === 145 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -25076,16 +25346,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 220 /* ModuleDeclaration */: - return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 221 /* ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -25335,22 +25605,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 138 /* Parameter */: + case 139 /* 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 141 /* PropertyDeclaration */: + case 142 /* 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 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -25363,9 +25633,9 @@ var ts; // 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 === 151 /* TypeReference */) { + if (node && node.kind === 152 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* 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 @@ -25412,28 +25682,24 @@ 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 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 139 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } - emitDecorate = true; - if (node.kind === 138 /* Parameter */) { - emitParam = true; - } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { @@ -25448,13 +25714,10 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } // 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 === 136 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 137 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -25470,7 +25733,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.forEach(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(getSourceFile(declaration)) ? + function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)) ? declaration : undefined; }); // Only type check the symbol once if (node === firstDeclaration) { @@ -25505,7 +25768,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 194 /* Block */) { + if (node.kind === 195 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -25525,12 +25788,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 140 /* PropertySignature */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 142 /* MethodSignature */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 142 /* PropertyDeclaration */ || + node.kind === 141 /* PropertySignature */ || + node.kind === 144 /* MethodDeclaration */ || + node.kind === 143 /* MethodSignature */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -25539,7 +25802,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 139 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -25592,12 +25855,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 220 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 221 /* 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 === 250 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 251 /* 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)); } @@ -25632,7 +25895,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 === 213 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 214 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -25642,24 +25905,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 214 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 195 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 196 /* 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 === 194 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 221 /* ModuleBlock */ || - container.kind === 220 /* ModuleDeclaration */ || - container.kind === 250 /* SourceFile */); + (container.kind === 195 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 222 /* ModuleBlock */ || + container.kind === 221 /* ModuleDeclaration */ || + container.kind === 251 /* 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_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + var name_16 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); } } } @@ -25667,7 +25930,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 !== 138 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 139 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -25678,7 +25941,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 139 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -25704,15 +25967,15 @@ 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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 165 /* BindingElement */) { + if (node.kind === 166 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 136 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } } @@ -25721,13 +25984,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 === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 139 /* 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)) { - if (node.initializer) { + // Don't validate for-in initializer as it is already an error + if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -25737,7 +26001,8 @@ var ts; var type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer - if (node.initializer) { + // Don't validate for-in initializer as it is already an error + if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -25753,10 +26018,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { + if (node.kind !== 142 /* PropertyDeclaration */ && node.kind !== 141 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 213 /* VariableDeclaration */ || node.kind === 165 /* BindingElement */) { + if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -25779,7 +26044,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 === 167 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 168 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -25800,7 +26065,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 196 /* EmptyStatement */) { + if (node.thenStatement.kind === 197 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -25820,12 +26085,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -25845,14 +26110,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 === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* 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 === 166 /* ArrayLiteralExpression */ || varExpr.kind === 167 /* ObjectLiteralExpression */) { + if (varExpr.kind === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* 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. @@ -25881,7 +26146,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 === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* 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); @@ -25895,7 +26160,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 === 166 /* ArrayLiteralExpression */ || varExpr.kind === 167 /* ObjectLiteralExpression */) { + if (varExpr.kind === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -26140,7 +26405,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); + return !!(node.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -26163,10 +26428,10 @@ var ts; // for generators. return; } - if (func.kind === 146 /* SetAccessor */) { + if (func.kind === 147 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 144 /* Constructor */) { + else if (func.kind === 145 /* Constructor */) { if (!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); } @@ -26208,7 +26473,7 @@ var ts; var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258 /* StringLike */); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 244 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 245 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -26220,7 +26485,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 243 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 244 /* 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 assignable to or from the type of the 'switch' expression. @@ -26245,7 +26510,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 209 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 210 /* 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; @@ -26350,7 +26615,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 137 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -26431,7 +26696,6 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; @@ -26532,7 +26796,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 || !(derivedClassDecl.flags & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 188 /* ClassExpression */) { + if (derivedClassDecl.kind === 189 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -26580,7 +26844,7 @@ var ts; } } function isAccessor(kind) { - return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; + return kind === 146 /* GetAccessor */ || kind === 147 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -26650,7 +26914,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 217 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -26760,7 +27024,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -26771,7 +27035,7 @@ var ts; case 50 /* TildeToken */: return ~value_1; } return undefined; - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -26796,11 +27060,11 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return evalConstant(e.expression); case 69 /* Identifier */: - case 169 /* ElementAccessExpression */: - case 168 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 169 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -26813,7 +27077,7 @@ var ts; } else { var expression; - if (e.kind === 169 /* ElementAccessExpression */) { + if (e.kind === 170 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -26831,7 +27095,7 @@ var ts; if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 168 /* PropertyAccessExpression */) { + else if (current.kind === 169 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -26902,7 +27166,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 219 /* EnumDeclaration */) { + if (declaration.kind !== 220 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -26925,8 +27189,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 === 216 /* ClassDeclaration */ || - (declaration.kind === 215 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 217 /* ClassDeclaration */ || + (declaration.kind === 216 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -26949,7 +27213,12 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; + var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); + var inAmbientContext = ts.isInAmbientContext(node); + if (isGlobalAugmentation && !inAmbientContext) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); + } + var isAmbientExternalModule = ts.isAmbientModule(node); var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -26958,7 +27227,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -26969,7 +27238,7 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) + && !inAmbientContext && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { @@ -26982,30 +27251,120 @@ 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, 216 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 217 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; } } - // Checks for ambient external modules. if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + if (ts.isExternalModuleAugmentation(node)) { + // body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module) + // otherwise we'll be swamped in cascading errors. + // We can detect if augmentation was applied using following rules: + // - augmentation for a global scope is always applied + // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); + if (checkBody) { + // body of ambient external module is always a module block + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + checkModuleAugmentationElement(statement, isGlobalAugmentation); + } + } } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + else if (isGlobalSourceFile(node.parent)) { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + else { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else { + // Node is not an augmentation and is not located on the script level. + // This means that this is declaration of ambient module that is located in other module or namespace which is prohibited. + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } } } } checkSourceElement(node.body); } + function checkModuleAugmentationElement(node, isGlobalAugmentation) { + switch (node.kind) { + case 196 /* 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 230 /* ExportAssignment */: + case 231 /* ExportDeclaration */: + grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); + break; + case 224 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind !== 9 /* StringLiteral */) { + error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + break; + } + // fallthrough + case 225 /* ImportDeclaration */: + grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); + break; + case 166 /* BindingElement */: + case 214 /* VariableDeclaration */: + var name_17 = node.name; + if (ts.isBindingPattern(name_17)) { + for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + var el = _c[_b]; + // mark individual names in binding pattern + checkModuleAugmentationElement(el, isGlobalAugmentation); + } + break; + } + // fallthrough + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 216 /* FunctionDeclaration */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 219 /* TypeAliasDeclaration */: + var symbol = getSymbolOfNode(node); + if (symbol) { + // module augmentations cannot introduce new names on the top level scope of the module + // this is done it two steps + // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error + // 2. main check - report error if value declaration of the parent symbol is module augmentation) + var reportError = !(symbol.flags & 33554432 /* Merged */); + if (!reportError) { + if (isGlobalAugmentation) { + // global symbol should not have parent since it is not explicitly exported + reportError = symbol.parent !== undefined; + } + else { + // symbol should not originate in augmentation + reportError = ts.isExternalModuleAugmentation(symbol.parent.valueDeclaration); + } + } + if (reportError) { + error(node, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + } + } + break; + } + } function getFirstIdentifier(node) { while (true) { - if (node.kind === 135 /* QualifiedName */) { + if (node.kind === 136 /* QualifiedName */) { node = node.left; } - else if (node.kind === 168 /* PropertyAccessExpression */) { + else if (node.kind === 169 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -27021,20 +27380,24 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 221 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 250 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 230 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 231 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - // TypeScript 1.0 spec (April 2013): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference - // other external modules only through top - level external module names. - // Relative external module names are not permitted. - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; + // we have already reported errors on top level imports\exports in external module augmentations in checkModuleDeclaration + // no need to do this again. + if (!isTopLevelInExternalModuleAugmentation(node)) { + // TypeScript 1.0 spec (April 2013): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference + // other external modules only through top - level external module names. + // Relative external module names are not permitted. + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } } return true; } @@ -27046,7 +27409,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 232 /* ExportSpecifier */ ? + var message = node.kind === 233 /* 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)); @@ -27073,7 +27436,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -27130,8 +27493,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 221 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 250 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -27145,14 +27508,23 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 250 /* SourceFile */ && node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 220 /* ModuleDeclaration */) { + if (node.parent.kind !== 251 /* SourceFile */ && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 221 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); + var exportedName = node.propertyName || node.name; + // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) + var symbol = resolveName(exportedName, exportedName.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); + } + else { + markExportAsReferenced(node); + } } } function checkExportAssignment(node) { @@ -27160,8 +27532,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 === 250 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 220 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { + var container = node.parent.kind === 251 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 221 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -27202,7 +27574,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports["export="]; if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + if (!isTopLevelInExternalModuleAugmentation(declaration)) { + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } } // Checks for export * conflicts var exports = getExportsOfModule(moduleSymbol); @@ -27225,21 +27599,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 215 /* FunctionDeclaration */ || !!declaration.body; - } - } - function checkTypePredicate(node) { - var parameterName = node.parameterName; - if (parameterName.kind === 69 /* Identifier */ && !isInLegalParameterTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - else if (parameterName.kind === 161 /* ThisType */) { - if (!isInLegalThisTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods); - } - else { - getTypeFromThisTypeNode(parameterName); - } + return declaration.kind !== 216 /* FunctionDeclaration */ || !!declaration.body; } } function checkSourceElement(node) { @@ -27251,118 +27611,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return checkTypeParameter(node); - case 138 /* Parameter */: + case 139 /* Parameter */: return checkParameter(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return checkPropertyDeclaration(node); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: return checkSignatureDeclaration(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return checkMethodDeclaration(node); - case 144 /* Constructor */: + case 145 /* Constructor */: return checkConstructorDeclaration(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return checkAccessorDeclaration(node); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return checkTypeReferenceNode(node); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return checkTypePredicate(node); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return checkTypeQuery(node); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return checkTypeLiteral(node); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return checkArrayType(node); - case 157 /* TupleType */: + case 158 /* TupleType */: return checkTupleType(node); - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return checkSourceElement(node.type); - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return checkBlock(node); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return checkVariableStatement(node); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return checkExpressionStatement(node); - case 198 /* IfStatement */: + case 199 /* IfStatement */: return checkIfStatement(node); - case 199 /* DoStatement */: + case 200 /* DoStatement */: return checkDoStatement(node); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: return checkWhileStatement(node); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return checkForStatement(node); - case 202 /* ForInStatement */: + case 203 /* ForInStatement */: return checkForInStatement(node); - case 203 /* ForOfStatement */: + case 204 /* ForOfStatement */: return checkForOfStatement(node); - case 204 /* ContinueStatement */: - case 205 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 206 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return checkReturnStatement(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return checkWithStatement(node); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return checkSwitchStatement(node); - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return checkLabeledStatement(node); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: return checkThrowStatement(node); - case 211 /* TryStatement */: + case 212 /* TryStatement */: return checkTryStatement(node); - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 165 /* BindingElement */: + case 166 /* BindingElement */: return checkBindingElement(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return checkClassDeclaration(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return checkImportDeclaration(node); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return checkExportDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return checkExportAssignment(node); - case 196 /* EmptyStatement */: + case 197 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 212 /* DebuggerStatement */: + case 213 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 233 /* MissingDeclaration */: + case 234 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -27384,17 +27744,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: checkAccessorDeferred(node); break; - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -27420,10 +27780,6 @@ var ts; } // Grammar checking checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - emitAwaiter = false; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); @@ -27436,21 +27792,6 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) { - links.flags |= 8 /* EmitExtends */; - } - if (emitDecorate) { - links.flags |= 16 /* EmitDecorate */; - } - if (emitParam) { - links.flags |= 32 /* EmitParam */; - } - if (emitAwaiter) { - links.flags |= 64 /* EmitAwaiter */; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { - links.flags |= 128 /* EmitGenerator */; - } links.flags |= 1 /* TypeChecked */; } } @@ -27488,7 +27829,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 207 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 208 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -27511,25 +27852,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 188 /* ClassExpression */: + case 189 /* 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 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* 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. @@ -27538,7 +27879,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 175 /* FunctionExpression */: + case 176 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -27587,37 +27928,37 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 137 /* TypeParameter */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 219 /* EnumDeclaration */: + case 138 /* TypeParameter */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 220 /* 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 === 135 /* QualifiedName */) { + while (node.parent && node.parent.kind === 136 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 151 /* TypeReference */; + return node.parent && node.parent.kind === 152 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 168 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 169 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 190 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 191 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 136 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 223 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 224 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 230 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -27629,11 +27970,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 229 /* ExportAssignment */) { + if (entityName.parent.kind === 230 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 168 /* PropertyAccessExpression */) { + if (entityName.kind !== 169 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -27645,7 +27986,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 === 190 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 191 /* ExpressionWithTypeArguments */) { meaning = 793056 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -27658,9 +27999,9 @@ var ts; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 237 /* JsxOpeningElement */) || - (entityName.parent.kind === 236 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 239 /* JsxClosingElement */)) { + else if ((entityName.parent.kind === 238 /* JsxOpeningElement */) || + (entityName.parent.kind === 237 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 240 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -27674,14 +28015,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 168 /* PropertyAccessExpression */) { + else if (entityName.kind === 169 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 135 /* QualifiedName */) { + else if (entityName.kind === 136 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -27690,16 +28031,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 240 /* JsxAttribute */) { + else if (entityName.parent.kind === 241 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 150 /* TypePredicate */) { + if (entityName.parent.kind === 151 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -27716,12 +28057,12 @@ var ts; } if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 229 /* ExportAssignment */ + return node.parent.kind === 230 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 165 /* BindingElement */ && - node.parent.parent.kind === 163 /* ObjectBindingPattern */ && + else if (node.parent.kind === 166 /* BindingElement */ && + node.parent.parent.kind === 164 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -27732,19 +28073,19 @@ var ts; } switch (node.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97 /* ThisKeyword */: case 95 /* SuperKeyword */: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 161 /* ThisType */: + case 162 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 145 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -27752,14 +28093,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 224 /* ImportDeclaration */ || node.parent.kind === 230 /* ExportDeclaration */) && + ((node.parent.kind === 225 /* ImportDeclaration */ || node.parent.kind === 231 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 169 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -27776,11 +28117,17 @@ 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 === 248 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 107455 /* Value */); + if (location && location.kind === 249 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; } + /** Returns the target of an export specifier without following aliases */ + function getExportSpecifierLocalTargetSymbol(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); + } function getTypeOfNode(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further @@ -27858,9 +28205,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456 /* SyntheticProperty */) { var symbols = []; - var name_15 = symbol.name; + var name_18 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); + var symbol = getPropertyOfType(t, name_18); if (symbol) { symbols.push(symbol); } @@ -27920,11 +28267,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 250 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 251 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 220 /* ModuleDeclaration */ || n.kind === 219 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 221 /* ModuleDeclaration */ || n.kind === 220 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -27939,11 +28286,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 194 /* Block */: - case 222 /* CaseBlock */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 195 /* Block */: + case 223 /* CaseBlock */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: return true; } return false; @@ -27973,22 +28320,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 223 /* ImportEqualsDeclaration */: - case 225 /* ImportClause */: - case 226 /* NamespaceImport */: - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 250 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 251 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -28050,7 +28397,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 249 /* EnumMember */) { + if (node.kind === 250 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -28172,23 +28519,38 @@ var ts; } function getExternalModuleFileFromDeclaration(declaration) { var specifier = ts.getExternalModuleName(declaration); - var moduleSymbol = getSymbolAtLocation(specifier); + var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 250 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 251 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors ts.forEach(host.getSourceFiles(), function (file) { ts.bindSourceFile(file, compilerOptions); }); + var augmentations; // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } + if (file.moduleAugmentations) { + (augmentations || (augmentations = [])).push(file.moduleAugmentations); + } }); + if (augmentations) { + // merge module augmentations. + // this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed + for (var _i = 0, augmentations_1 = augmentations; _i < augmentations_1.length; _i++) { + var list = augmentations_1[_i]; + for (var _a = 0, list_2 = list; _a < list_2.length; _a++) { + var augmentation = list_2[_a]; + mergeModuleAugmentation(augmentation); + } + } + } // Setup global builtins addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedType; @@ -28262,14 +28624,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 143 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 144 /* 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 === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { + else if (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* 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); @@ -28279,38 +28641,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 220 /* ModuleDeclaration */: - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 230 /* ExportDeclaration */: - case 229 /* ExportAssignment */: - case 138 /* Parameter */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 145 /* Constructor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 150 /* IndexSignature */: + case 221 /* ModuleDeclaration */: + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 231 /* ExportDeclaration */: + case 230 /* ExportAssignment */: + case 139 /* Parameter */: break; - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && - node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 250 /* SourceFile */) { + node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 195 /* VariableStatement */: - case 218 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 250 /* SourceFile */) { + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 196 /* VariableStatement */: + case 219 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && - node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 250 /* SourceFile */) { + node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -28326,7 +28688,7 @@ var ts; var modifier = _a[_i]; switch (modifier.kind) { case 74 /* ConstKeyword */: - if (node.kind !== 219 /* EnumDeclaration */ && node.parent.kind === 216 /* ClassDeclaration */) { + if (node.kind !== 220 /* EnumDeclaration */ && node.parent.kind === 217 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); } break; @@ -28354,7 +28716,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 === 221 /* ModuleBlock */ || node.parent.kind === 250 /* SourceFile */) { + else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 128 /* Abstract */) { @@ -28374,10 +28736,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 === 221 /* ModuleBlock */ || node.parent.kind === 250 /* SourceFile */) { + else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -28399,10 +28761,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 2 /* Export */; @@ -28414,13 +28776,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 221 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 4 /* Ambient */; @@ -28430,11 +28792,11 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 216 /* ClassDeclaration */) { - if (node.kind !== 143 /* MethodDeclaration */) { + if (node.kind !== 217 /* ClassDeclaration */) { + if (node.kind !== 144 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 216 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { + if (!(node.parent.kind === 217 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 64 /* Static */) { @@ -28453,7 +28815,7 @@ var ts; else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -28461,7 +28823,7 @@ var ts; break; } } - if (node.kind === 144 /* Constructor */) { + if (node.kind === 145 /* Constructor */) { if (flags & 64 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -28479,10 +28841,10 @@ var ts; } return; } - else if ((node.kind === 224 /* ImportDeclaration */ || node.kind === 223 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { + else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 139 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256 /* Async */) { @@ -28494,10 +28856,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 143 /* MethodDeclaration */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -28563,7 +28925,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 176 /* ArrowFunction */) { + if (node.kind === 177 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -28631,7 +28993,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 189 /* OmittedExpression */) { + if (arg.kind === 190 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -28705,19 +29067,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 136 /* ComputedPropertyName */) { + if (node.kind !== 137 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 183 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 184 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* 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 === 215 /* FunctionDeclaration */ || - node.kind === 175 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 216 /* FunctionDeclaration */ || + node.kind === 176 /* FunctionExpression */ || + node.kind === 144 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -28741,21 +29103,21 @@ var ts; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; var _loop_1 = function(prop) { - var name_16 = prop.name; - if (prop.kind === 189 /* OmittedExpression */ || - name_16.kind === 136 /* ComputedPropertyName */) { + var name_19 = prop.name; + if (prop.kind === 190 /* OmittedExpression */ || + name_19.kind === 137 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_16); + checkGrammarComputedPropertyName(name_19); return "continue"; } - if (prop.kind === 248 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 249 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } // Modifiers are never allowed on properties except for 'async' on a method declaration ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 143 /* MethodDeclaration */) { + if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 144 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); @@ -28768,44 +29130,44 @@ 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 === 247 /* PropertyAssignment */ || prop.kind === 248 /* ShorthandPropertyAssignment */) { + if (prop.kind === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_16); + if (name_19.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_19); } currentKind = Property; } - else if (prop.kind === 143 /* MethodDeclaration */) { + else if (prop.kind === 144 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 145 /* GetAccessor */) { + else if (prop.kind === 146 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 146 /* SetAccessor */) { + else if (prop.kind === 147 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = currentKind; } else { - var existingKind = seen[name_16.text]; + var existingKind = seen[name_19.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; + seen[name_19.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; @@ -28820,19 +29182,19 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 241 /* JsxSpreadAttribute */) { + if (attr.kind === 242 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; + var name_20 = jsxAttr.name; + if (!ts.hasProperty(seen, name_20.text)) { + seen[name_20.text] = true; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 242 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 243 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -28841,7 +29203,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 214 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 215 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -28856,20 +29218,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 202 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 203 /* 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 === 202 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 203 /* 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 === 202 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 203 /* 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); @@ -28892,10 +29254,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 146 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 146 /* SetAccessor */) { + else if (kind === 147 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -28930,12 +29292,12 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 167 /* ObjectLiteralExpression */) { + if (node.parent.kind === 168 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -28954,10 +29316,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 === 217 /* InterfaceDeclaration */) { + else if (node.parent.kind === 218 /* 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 === 155 /* TypeLiteral */) { + else if (node.parent.kind === 156 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -28968,11 +29330,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 209 /* LabeledStatement */: + case 210 /* 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 === 204 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 205 /* 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); @@ -28980,8 +29342,8 @@ var ts; return false; } break; - case 208 /* SwitchStatement */: - if (node.kind === 205 /* BreakStatement */ && !node.label) { + case 209 /* SwitchStatement */: + if (node.kind === 206 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -28996,13 +29358,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 205 /* BreakStatement */ + var message = node.kind === 206 /* 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 === 205 /* BreakStatement */ + var message = node.kind === 206 /* 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); @@ -29014,7 +29376,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 164 /* ArrayBindingPattern */ || node.name.kind === 163 /* ObjectBindingPattern */) { + if (node.name.kind === 165 /* ArrayBindingPattern */ || node.name.kind === 164 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -29024,7 +29386,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 202 /* ForInStatement */ && node.parent.parent.kind !== 203 /* ForOfStatement */) { + if (node.parent.parent.kind !== 203 /* ForInStatement */ && node.parent.parent.kind !== 204 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -29060,7 +29422,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 189 /* OmittedExpression */) { + if (element.kind !== 190 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -29077,15 +29439,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: return false; - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -29141,7 +29503,7 @@ var ts; return true; } } - else if (node.parent.kind === 217 /* InterfaceDeclaration */) { + else if (node.parent.kind === 218 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -29149,7 +29511,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 155 /* TypeLiteral */) { + else if (node.parent.kind === 156 /* 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; } @@ -29174,12 +29536,12 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 217 /* InterfaceDeclaration */ || - node.kind === 218 /* TypeAliasDeclaration */ || - node.kind === 224 /* ImportDeclaration */ || - node.kind === 223 /* ImportEqualsDeclaration */ || - node.kind === 230 /* ExportDeclaration */ || - node.kind === 229 /* ExportAssignment */ || + if (node.kind === 218 /* InterfaceDeclaration */ || + node.kind === 219 /* TypeAliasDeclaration */ || + node.kind === 225 /* ImportDeclaration */ || + node.kind === 224 /* ImportEqualsDeclaration */ || + node.kind === 231 /* ExportDeclaration */ || + node.kind === 230 /* ExportAssignment */ || (node.flags & 4 /* Ambient */) || (node.flags & (2 /* Export */ | 512 /* Default */))) { return false; @@ -29189,7 +29551,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 === 195 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 196 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -29215,7 +29577,7 @@ var ts; // to prevent noisyness. 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 === 194 /* Block */ || node.parent.kind === 221 /* ModuleBlock */ || node.parent.kind === 250 /* SourceFile */) { + if (node.parent.kind === 195 /* Block */ || node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -29255,8 +29617,9 @@ var ts; getSourceMapData: function () { return undefined; }, setSourceFile: function (sourceFile) { }, emitStart: function (range) { }, - emitEnd: function (range) { }, + emitEnd: function (range, stopOverridingSpan) { }, emitPos: function (pos) { }, + changeEmitSourcePos: function () { }, getText: function () { return undefined; }, getSourceMappingURL: function () { return undefined; }, initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, @@ -29270,6 +29633,8 @@ var ts; var compilerOptions = host.getCompilerOptions(); var currentSourceFile; var sourceMapDir; // The directory in which sourcemap will be + var stopOverridingSpan = false; + var modifyLastSourcePos = false; // Current source map file and its index in the sources list var sourceMapSourceIndex; // Last recorded and encoded spans @@ -29284,6 +29649,7 @@ var ts; emitPos: emitPos, emitStart: emitStart, emitEnd: emitEnd, + changeEmitSourcePos: changeEmitSourcePos, getText: getText, getSourceMappingURL: getSourceMappingURL, initialize: initialize, @@ -29358,6 +29724,39 @@ var ts; lastEncodedNameIndex = undefined; sourceMapData = undefined; } + function updateLastEncodedAndRecordedSpans() { + if (modifyLastSourcePos) { + // Reset the source pos + modifyLastSourcePos = false; + // Change Last recorded Map with last encoded emit line and character + lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; + lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Pop sourceMapDecodedMappings to remove last entry + sourceMapData.sourceMapDecodedMappings.pop(); + // Change the last encoded source map + lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? + sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : + undefined; + // TODO: Update lastEncodedNameIndex + // Since we dont support this any more, lets not worry about it right now. + // When we start supporting nameIndex, we will get back to this + // Change the encoded source map + var sourceMapMappings = sourceMapData.sourceMapMappings; + var lenthToSet = sourceMapMappings.length - 1; + for (; lenthToSet >= 0; lenthToSet--) { + var currentChar = sourceMapMappings.charAt(lenthToSet); + if (currentChar === ",") { + // Separator for the entry found + break; + } + if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { + // Last line separator found + break; + } + } + sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); + } + } // Encoding for sourcemap span function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { @@ -29388,6 +29787,7 @@ var ts; sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); // 5. Relative namePosition 0 based if (lastRecordedSourceMapSpan.nameIndex >= 0) { + ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } @@ -29421,20 +29821,30 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; + stopOverridingSpan = false; } - else { + else if (!stopOverridingSpan) { // Take the new pos instead since there is no change in emittedLine and column since last location lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } + updateLastEncodedAndRecordedSpans(); + } + function getStartPos(range) { + var rangeHasDecorators = !!range.decorators; + return range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1; } function emitStart(range) { - var rangeHasDecorators = !!range.decorators; - emitPos(range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1); + emitPos(getStartPos(range)); } - function emitEnd(range) { + function emitEnd(range, stopOverridingEnd) { emitPos(range.end); + stopOverridingSpan = stopOverridingEnd; + } + function changeEmitSourcePos() { + ts.Debug.assert(!modifyLastSourcePos); + modifyLastSourcePos = true; } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -29536,6 +29946,7 @@ var ts; var writeTextOfNode; var writer = createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; + var resultHasExternalModuleIndicator; var currentText; var currentLineMap; var currentIdentifiers; @@ -29577,6 +29988,7 @@ var ts; } }); } + resultHasExternalModuleIndicator = false; if (!isBundledEmit || !ts.isExternalModule(sourceFile)) { noDeclare = false; emitSourceFile(sourceFile); @@ -29596,7 +30008,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 224 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 225 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -29613,6 +30025,13 @@ var ts; allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo); moduleElementDeclarationEmitInfo = []; } + if (!isBundledEmit && ts.isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) { + // if file was external module with augmentations - this fact should be preserved in .d.ts as well. + // in case if we didn't write any external module specifiers in .d.ts we need to emit something + // that will force compiler to think that this file is an external module - 'export {}' is a reasonable choice here. + write("export {};"); + writeLine(); + } }); return { reportedDeclarationError: reportedDeclarationError, @@ -29659,10 +30078,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 213 /* VariableDeclaration */) { + if (declaration.kind === 214 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 227 /* NamedImports */ || declaration.kind === 228 /* ImportSpecifier */ || declaration.kind === 225 /* ImportClause */) { + else if (declaration.kind === 228 /* NamedImports */ || declaration.kind === 229 /* ImportSpecifier */ || declaration.kind === 226 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -29680,7 +30099,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 === 224 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 225 /* 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; @@ -29690,12 +30109,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 220 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 220 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -29803,35 +30222,35 @@ var ts; case 120 /* BooleanKeyword */: case 131 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 161 /* ThisType */: - case 162 /* StringLiteralType */: + case 162 /* ThisType */: + case 163 /* StringLiteralType */: return writeTextOfNode(currentText, type); - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return emitTypeReference(type); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return emitTypeQuery(type); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return emitArrayType(type); - case 157 /* TupleType */: + case 158 /* TupleType */: return emitTupleType(type); - case 158 /* UnionType */: + case 159 /* UnionType */: return emitUnionType(type); - case 159 /* IntersectionType */: + case 160 /* IntersectionType */: return emitIntersectionType(type); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return emitParenType(type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return emitTypeLiteral(type); case 69 /* Identifier */: return emitEntityName(type); - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return emitEntityName(type); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -29839,8 +30258,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 136 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 136 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -29849,13 +30268,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 223 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 224 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 168 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 169 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -29934,9 +30353,9 @@ var ts; var count = 0; while (true) { count++; - var name_18 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_18)) { - return name_18; + var name_21 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_21)) { + return name_21; } } } @@ -29980,10 +30399,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 223 /* ImportEqualsDeclaration */ || - (node.parent.kind === 250 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 224 /* ImportEqualsDeclaration */ || + (node.parent.kind === 251 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 250 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -29993,7 +30412,7 @@ var ts; }); } else { - if (node.kind === 224 /* ImportDeclaration */) { + if (node.kind === 225 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -30011,23 +30430,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return writeVariableStatement(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return writeClassDeclaration(node); - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -30035,7 +30454,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 === 250 /* SourceFile */) { + if (node.parent.kind === 251 /* SourceFile */) { // If the node is exported if (node.flags & 2 /* Export */) { write("export "); @@ -30043,7 +30462,7 @@ var ts; if (node.flags & 512 /* Default */) { write("default "); } - else if (node.kind !== 217 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 218 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -30092,7 +30511,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 226 /* NamespaceImport */) { + if (namedBindings.kind === 227 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -30120,7 +30539,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -30137,11 +30556,19 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { + // emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations). + // 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 indistingushable 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 !== 221 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 223 /* ImportEqualsDeclaration */) { + if (parent.kind === 224 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } + else if (parent.kind === 221 /* ModuleDeclaration */) { + moduleSpecifier = parent.name; + } else { var node = parent; moduleSpecifier = node.moduleSpecifier; @@ -30192,14 +30619,24 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 65536 /* Namespace */) { - write("namespace "); + if (ts.isGlobalScopeAugmentation(node)) { + write("global "); } else { - write("module "); + if (node.flags & 65536 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } + if (ts.isExternalModuleAugmentation(node)) { + emitExternalModuleSpecifier(node); + } + else { + writeTextOfNode(currentText, node.name); + } } - writeTextOfNode(currentText, node.name); - while (node.body.kind !== 221 /* ModuleBlock */) { + while (node.body.kind !== 222 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -30264,7 +30701,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); + return node.parent.kind === 144 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -30275,15 +30712,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 === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || - node.parent.kind === 142 /* MethodSignature */ || - node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.kind === 147 /* CallSignature */ || - node.parent.kind === 148 /* ConstructSignature */); + if (node.parent.kind === 153 /* FunctionType */ || + node.parent.kind === 154 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 156 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 144 /* MethodDeclaration */ || + node.parent.kind === 143 /* MethodSignature */ || + node.parent.kind === 153 /* FunctionType */ || + node.parent.kind === 154 /* ConstructorType */ || + node.parent.kind === 148 /* CallSignature */ || + node.parent.kind === 149 /* ConstructSignature */); emitType(node.constraint); } else { @@ -30294,31 +30731,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 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147 /* CallSignature */: + case 148 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.parent.flags & 64 /* 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 === 216 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 217 /* 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 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -30352,7 +30789,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 216 /* ClassDeclaration */) { + if (node.parent.parent.kind === 217 /* 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 : @@ -30436,7 +30873,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 !== 213 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 214 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -30446,10 +30883,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentText, node.name); // If optional property emit ? - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { + if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && node.parent.kind === 156 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 16 /* Private */)) { @@ -30458,14 +30895,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 213 /* VariableDeclaration */) { + if (node.kind === 214 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { + else if (node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -30474,7 +30911,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -30506,7 +30943,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189 /* OmittedExpression */) { + if (element.kind !== 190 /* OmittedExpression */) { elements.push(element); } } @@ -30576,7 +31013,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 === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 146 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -30589,7 +31026,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 145 /* GetAccessor */ + return accessor.kind === 146 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -30598,7 +31035,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 147 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -30648,17 +31085,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 143 /* MethodDeclaration */) { + else if (node.kind === 144 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 144 /* Constructor */) { + else if (node.kind === 145 /* Constructor */) { write("constructor"); } else { @@ -30678,11 +31115,11 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; // Construct signature or constructor type write new Signature - if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { + if (node.kind === 149 /* ConstructSignature */ || node.kind === 154 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 149 /* IndexSignature */) { + if (node.kind === 150 /* IndexSignature */) { write("["); } else { @@ -30690,22 +31127,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149 /* IndexSignature */) { + if (node.kind === 150 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 153 /* FunctionType */ || node.kind === 154 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 156 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 16 /* Private */)) { + else if (node.kind !== 145 /* Constructor */ && !(node.flags & 16 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -30716,26 +31153,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.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 147 /* CallSignature */: + case 148 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.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 149 /* IndexSignature */: + case 150 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.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 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -30743,7 +31180,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -30757,7 +31194,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -30792,9 +31229,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.parent.kind === 155 /* TypeLiteral */) { + if (node.parent.kind === 153 /* FunctionType */ || + node.parent.kind === 154 /* ConstructorType */ || + node.parent.parent.kind === 156 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 16 /* Private */)) { @@ -30810,24 +31247,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 144 /* Constructor */: + case 145 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.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 147 /* CallSignature */: + case 148 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.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 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.parent.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -30835,7 +31272,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 === 216 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 217 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -30848,7 +31285,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 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -30860,12 +31297,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 === 163 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 164 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 164 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 165 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -30876,7 +31313,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 189 /* OmittedExpression */) { + if (bindingElement.kind === 190 /* 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) @@ -30885,7 +31322,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 165 /* BindingElement */) { + else if (bindingElement.kind === 166 /* 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" @@ -30924,40 +31361,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: - case 220 /* ModuleDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 217 /* InterfaceDeclaration */: - case 216 /* ClassDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 219 /* EnumDeclaration */: + case 216 /* FunctionDeclaration */: + case 221 /* ModuleDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 218 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 220 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return emitExportDeclaration(node); - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 145 /* Constructor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return writeFunctionDeclaration(node); - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: + case 149 /* ConstructSignature */: + case 148 /* CallSignature */: + case 150 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return emitAccessorDeclaration(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return emitPropertyDeclaration(node); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return emitSourceFile(node); } } @@ -31317,7 +31754,7 @@ var ts; 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};"; // emit output for the __param helper function var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -31415,6 +31852,7 @@ var ts; var isOwnFileEmit; /** If removeComments is true, no leading-comments needed to be emitted **/ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, _a[5 /* ES6 */] = emitES6Module, _a[2 /* AMD */] = emitAMDModule, @@ -31499,10 +31937,10 @@ var ts; // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_19)) { + var name_22 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_22)) { tempFlags |= flags; - return name_19; + return name_22; } } while (true) { @@ -31510,9 +31948,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; + var name_23 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_23)) { + return name_23; } } } @@ -31556,17 +31994,17 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return makeUniqueName(node.text); - case 220 /* ModuleDeclaration */: - case 219 /* EnumDeclaration */: + case 221 /* ModuleDeclaration */: + case 220 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 224 /* ImportDeclaration */: - case 230 /* ExportDeclaration */: + case 225 /* ImportDeclaration */: + case 231 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 215 /* FunctionDeclaration */: - case 216 /* ClassDeclaration */: - case 229 /* ExportAssignment */: + case 216 /* FunctionDeclaration */: + case 217 /* ClassDeclaration */: + case 230 /* ExportAssignment */: return generateNameForExportDefault(); - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -31836,10 +32274,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 185 /* TemplateExpression */) { + if (node.template.kind === 186 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 183 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 184 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -31874,7 +32312,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 174 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 175 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -31916,11 +32354,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return parent.expression === template; - case 172 /* TaggedTemplateExpression */: - case 174 /* ParenthesizedExpression */: + case 173 /* TaggedTemplateExpression */: + case 175 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -31941,7 +32379,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 37 /* AsteriskToken */: case 39 /* SlashToken */: @@ -31953,8 +32391,8 @@ var ts; default: return -1 /* LessThan */; } - case 186 /* YieldExpression */: - case 184 /* ConditionalExpression */: + case 187 /* YieldExpression */: + case 185 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -32021,38 +32459,38 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 241 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 242 /* JsxSpreadAttribute */; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 241 /* JsxSpreadAttribute */) { + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].kind === 242 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_1 === 0) { + if (i === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_1 > 0) { + if (i > 0) { write(", "); } - emit(attrs[i_1].expression); + emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 240 /* JsxAttribute */); + ts.Debug.assert(attrs[i].kind === 241 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_1 > 0) { + if (i > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_1]); + emitJsxAttribute(attrs[i]); } } if (haveOpenedObjectLiteral) @@ -32062,7 +32500,7 @@ var ts; else { // One object literal with all the attributes in them write("{"); - for (var i = 0; i < attrs.length; i++) { + for (var i = 0, n = attrs.length; i < n; i++) { if (i > 0) { write(", "); } @@ -32075,11 +32513,11 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 242 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 243 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 238 /* JsxText */) { + if (children[i].kind === 239 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -32097,11 +32535,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 235 /* JsxElement */) { + if (node.kind === 236 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 236 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -32123,11 +32561,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 241 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 242 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 240 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 241 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -32135,11 +32573,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 236 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 237 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 236 /* JsxSelfClosingElement */) { + if (node.kind === 237 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -32158,11 +32596,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 235 /* JsxElement */) { + if (node.kind === 236 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 236 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -32170,11 +32608,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 165 /* BindingElement */); + ts.Debug.assert(node.kind !== 166 /* BindingElement */); if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 136 /* ComputedPropertyName */) { + else if (node.kind === 137 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -32218,62 +32656,62 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 166 /* ArrayLiteralExpression */: - case 191 /* AsExpression */: - case 183 /* BinaryExpression */: - case 170 /* CallExpression */: - case 243 /* CaseClause */: - case 136 /* ComputedPropertyName */: - case 184 /* ConditionalExpression */: - case 139 /* Decorator */: - case 177 /* DeleteExpression */: - case 199 /* DoStatement */: - case 169 /* ElementAccessExpression */: - case 229 /* ExportAssignment */: - case 197 /* ExpressionStatement */: - case 190 /* ExpressionWithTypeArguments */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 198 /* IfStatement */: - case 239 /* JsxClosingElement */: - case 236 /* JsxSelfClosingElement */: - case 237 /* JsxOpeningElement */: - case 241 /* JsxSpreadAttribute */: - case 242 /* JsxExpression */: - case 171 /* NewExpression */: - case 174 /* ParenthesizedExpression */: - case 182 /* PostfixUnaryExpression */: - case 181 /* PrefixUnaryExpression */: - case 206 /* ReturnStatement */: - case 248 /* ShorthandPropertyAssignment */: - case 187 /* SpreadElementExpression */: - case 208 /* SwitchStatement */: - case 172 /* TaggedTemplateExpression */: - case 192 /* TemplateSpan */: - case 210 /* ThrowStatement */: - case 173 /* TypeAssertionExpression */: - case 178 /* TypeOfExpression */: - case 179 /* VoidExpression */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 186 /* YieldExpression */: + case 167 /* ArrayLiteralExpression */: + case 192 /* AsExpression */: + case 184 /* BinaryExpression */: + case 171 /* CallExpression */: + case 244 /* CaseClause */: + case 137 /* ComputedPropertyName */: + case 185 /* ConditionalExpression */: + case 140 /* Decorator */: + case 178 /* DeleteExpression */: + case 200 /* DoStatement */: + case 170 /* ElementAccessExpression */: + case 230 /* ExportAssignment */: + case 198 /* ExpressionStatement */: + case 191 /* ExpressionWithTypeArguments */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 199 /* IfStatement */: + case 240 /* JsxClosingElement */: + case 237 /* JsxSelfClosingElement */: + case 238 /* JsxOpeningElement */: + case 242 /* JsxSpreadAttribute */: + case 243 /* JsxExpression */: + case 172 /* NewExpression */: + case 175 /* ParenthesizedExpression */: + case 183 /* PostfixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: + case 207 /* ReturnStatement */: + case 249 /* ShorthandPropertyAssignment */: + case 188 /* SpreadElementExpression */: + case 209 /* SwitchStatement */: + case 173 /* TaggedTemplateExpression */: + case 193 /* TemplateSpan */: + case 211 /* ThrowStatement */: + case 174 /* TypeAssertionExpression */: + case 179 /* TypeOfExpression */: + case 180 /* VoidExpression */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 187 /* YieldExpression */: return true; - case 165 /* BindingElement */: - case 249 /* EnumMember */: - case 138 /* Parameter */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 213 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 250 /* EnumMember */: + case 139 /* Parameter */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 214 /* VariableDeclaration */: return parent.initializer === node; - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return parent.expression === node; - case 176 /* ArrowFunction */: - case 175 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 176 /* FunctionExpression */: return parent.body === node; - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return parent.left === node; } return false; @@ -32285,7 +32723,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 250 /* SourceFile */) { + if (container.kind === 251 /* SourceFile */) { // Identifier references module export if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { write("exports."); @@ -32301,17 +32739,17 @@ var ts; if (modulekind !== 5 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 225 /* ImportClause */) { + if (declaration.kind === 226 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 228 /* ImportSpecifier */) { + else if (declaration.kind === 229 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_21 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_21); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); if (languageVersion === 0 /* ES3 */ && identifier === "default") { write("[\"default\"]"); } @@ -32340,13 +32778,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 165 /* BindingElement */: - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 213 /* VariableDeclaration */: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + var parent_7 = node.parent; + switch (parent_7.kind) { + case 166 /* BindingElement */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 214 /* VariableDeclaration */: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } return false; @@ -32355,8 +32793,8 @@ var ts; if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { // in converted loop body arguments cannot be used directly. - var name_22 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_22); + var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_25); return; } } @@ -32456,10 +32894,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 183 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 184 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 184 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 185 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; @@ -32467,11 +32905,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69 /* Identifier */: - case 166 /* ArrayLiteralExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 170 /* CallExpression */: - case 174 /* ParenthesizedExpression */: + case 167 /* ArrayLiteralExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 175 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -32491,17 +32929,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 187 /* SpreadElementExpression */) { + if (e.kind === 188 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 166 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 187 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 188 /* SpreadElementExpression */) { i++; } write("["); @@ -32524,7 +32962,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 187 /* SpreadElementExpression */; + return node.kind === 188 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -32594,7 +33032,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { + if (property.kind === 146 /* GetAccessor */ || property.kind === 147 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -32646,13 +33084,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 247 /* PropertyAssignment */) { + if (property.kind === 248 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 248 /* ShorthandPropertyAssignment */) { + else if (property.kind === 249 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 143 /* MethodDeclaration */) { + else if (property.kind === 144 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -32686,7 +33124,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136 /* ComputedPropertyName */) { + if (properties[i].name.kind === 137 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -32702,21 +33140,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(183 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(184 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(168 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(169 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(169 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(170 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -32724,7 +33162,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 173 /* TypeAssertionExpression */ || expr.kind === 191 /* AsExpression */) { + while (expr.kind === 174 /* TypeAssertionExpression */ || expr.kind === 192 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -32736,11 +33174,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 171 /* NewExpression */ && + expr.kind !== 172 /* NewExpression */ && expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(174 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(175 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -32775,7 +33213,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 250 /* SourceFile */; + return container && container.kind !== 251 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -32805,7 +33243,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 168 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 169 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -32816,7 +33254,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 168 /* PropertyAccessExpression */ || node.kind === 169 /* ElementAccessExpression */ + return node.kind === 169 /* PropertyAccessExpression */ || node.kind === 170 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; } @@ -32905,7 +33343,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -32923,10 +33361,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 187 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 188 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 174 /* ParenthesizedExpression */ || node.kind === 173 /* TypeAssertionExpression */ || node.kind === 191 /* AsExpression */) { + while (node.kind === 175 /* ParenthesizedExpression */ || node.kind === 174 /* TypeAssertionExpression */ || node.kind === 192 /* AsExpression */) { node = node.expression; } return node; @@ -32947,13 +33385,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 168 /* PropertyAccessExpression */) { + if (expr.kind === 169 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 169 /* ElementAccessExpression */) { + else if (expr.kind === 170 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -32998,7 +33436,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 168 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + superCall = node.expression.kind === 169 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -33067,12 +33505,12 @@ 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 (!ts.nodeIsSynthesized(node) && node.parent.kind !== 176 /* ArrowFunction */) { - if (node.expression.kind === 173 /* TypeAssertionExpression */ || node.expression.kind === 191 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 177 /* ArrowFunction */) { + if (node.expression.kind === 174 /* TypeAssertionExpression */ || node.expression.kind === 192 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 173 /* TypeAssertionExpression */ || operand.kind === 191 /* AsExpression */) { + while (operand.kind === 174 /* TypeAssertionExpression */ || operand.kind === 192 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -33083,15 +33521,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 181 /* PrefixUnaryExpression */ && - operand.kind !== 179 /* VoidExpression */ && - operand.kind !== 178 /* TypeOfExpression */ && - operand.kind !== 177 /* DeleteExpression */ && - operand.kind !== 182 /* PostfixUnaryExpression */ && - operand.kind !== 171 /* NewExpression */ && - !(operand.kind === 170 /* CallExpression */ && node.parent.kind === 171 /* NewExpression */) && - !(operand.kind === 175 /* FunctionExpression */ && node.parent.kind === 170 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 168 /* PropertyAccessExpression */)) { + if (operand.kind !== 182 /* PrefixUnaryExpression */ && + operand.kind !== 180 /* VoidExpression */ && + operand.kind !== 179 /* TypeOfExpression */ && + operand.kind !== 178 /* DeleteExpression */ && + operand.kind !== 183 /* PostfixUnaryExpression */ && + operand.kind !== 172 /* NewExpression */ && + !(operand.kind === 171 /* CallExpression */ && node.parent.kind === 172 /* NewExpression */) && + !(operand.kind === 176 /* FunctionExpression */ && node.parent.kind === 171 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 169 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -33120,7 +33558,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 213 /* VariableDeclaration */ || node.parent.kind === 165 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 /* VariableDeclaration */ || node.parent.kind === 166 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -33151,7 +33589,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 181 /* PrefixUnaryExpression */) { + if (node.operand.kind === 182 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); @@ -33207,10 +33645,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 250 /* SourceFile */) { + if (current.kind === 251 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 221 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 222 /* ModuleBlock */) { return false; } else { @@ -33230,14 +33668,14 @@ var ts; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(170 /* ElementAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true, leftHandSideExpression.expression); } else { synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; @@ -33247,7 +33685,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(168 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(169 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -33275,8 +33713,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && - (node.left.kind === 167 /* ObjectLiteralExpression */ || node.left.kind === 166 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 197 /* ExpressionStatement */); + (node.left.kind === 168 /* ObjectLiteralExpression */ || node.left.kind === 167 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 198 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && @@ -33341,7 +33779,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 194 /* Block */) { + if (node && node.kind === 195 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -33355,12 +33793,12 @@ var ts; } emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); - if (node.kind === 221 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 220 /* ModuleDeclaration */); + if (node.kind === 222 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 221 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 221 /* ModuleBlock */) { + if (node.kind === 222 /* ModuleBlock */) { emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); @@ -33368,7 +33806,7 @@ var ts; emitToken(16 /* CloseBraceToken */, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 194 /* Block */) { + if (node.kind === 195 /* Block */) { write(" "); emit(node); } @@ -33380,7 +33818,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 176 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 177 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -33393,7 +33831,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 198 /* IfStatement */) { + if (node.elseStatement.kind === 199 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -33413,7 +33851,7 @@ var ts; else { emitNormalLoopBody(node, /*emitAsEmbeddedStatement*/ true); } - if (node.statement.kind === 194 /* Block */) { + if (node.statement.kind === 195 /* Block */) { write(" "); } else { @@ -33442,7 +33880,7 @@ var ts; * Returns false if nothing was written - this can happen for source file level variable declarations * in system modules where such variable declarations are hoisted. */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { + function tryEmitStartOfVariableDeclarationList(decl) { if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; @@ -33456,32 +33894,23 @@ var ts; } return false; } - var tokenKind = 102 /* VarKeyword */; + emitStart(decl); if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 108 /* LetKeyword */; + write("let "); } else if (ts.isConst(decl)) { - tokenKind = 74 /* ConstKeyword */; + write("const "); + } + else { + write("var "); } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); } else { - switch (tokenKind) { - case 102 /* VarKeyword */: - write("var "); - break; - case 108 /* LetKeyword */: - write("let "); - break; - case 74 /* ConstKeyword */: - write("const "); - break; - } + write("var "); } + // Note here we specifically dont emit end so that if we are going to emit binding pattern + // we can alter the source map correctly return true; } function emitVariableDeclarationListSkippingUninitializedEntries(list) { @@ -33512,7 +33941,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 209 /* LabeledStatement */) { + if (node.parent.kind === 210 /* LabeledStatement */) { // if parent of the loop was labeled statement - attach the label to loop skipping converted loop body emitLabelAndColon(node.parent); } @@ -33523,10 +33952,11 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + var initializer = node.initializer; + if (initializer && initializer.kind === 215 /* VariableDeclarationList */) { loopInitializer = node.initializer; } break; @@ -33540,7 +33970,7 @@ var ts; collectNames(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 194 /* Block */; + var bodyIsBlock = node.statement.kind === 195 /* Block */; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); @@ -33661,7 +34091,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 194 /* Block */) { + else if (node.statement.kind === 195 /* Block */) { emitLines(node.statement.statements); } else { @@ -33771,9 +34201,9 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { emitCommaList(variableDeclarationList.declarations); } @@ -33797,7 +34227,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 204 /* ForOfStatement */) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -33808,17 +34238,17 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + tryEmitStartOfVariableDeclarationList(variableDeclarationList); emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 202 /* ForInStatement */) { + if (node.kind === 203 /* ForInStatement */) { write(" in "); } else { @@ -33887,18 +34317,18 @@ var ts; emitEnd(node.expression); write("; "); // _i < _a.length; - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write(" < "); emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); - emitEnd(node.initializer); + emitEnd(node.expression); write("; "); // _i++) - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write("++"); - emitEnd(node.initializer); + emitEnd(node.expression); emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); @@ -33908,7 +34338,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -33938,7 +34368,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 166 /* ArrayLiteralExpression */ || node.initializer.kind === 167 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 167 /* ArrayLiteralExpression */ || node.initializer.kind === 168 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); @@ -33966,12 +34396,12 @@ var ts; // it is possible if either // - break\continue is statement 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 === 205 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 206 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { if (!node.label) { - if (node.kind === 205 /* BreakStatement */) { + if (node.kind === 206 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; write("return \"break\";"); } @@ -33982,7 +34412,7 @@ var ts; } else { var labelMarker; - if (node.kind === 205 /* BreakStatement */) { + if (node.kind === 206 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -33995,7 +34425,7 @@ var ts; return; } } - emitToken(node.kind === 205 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -34061,7 +34491,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 243 /* CaseClause */) { + if (node.kind === 244 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -34130,7 +34560,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 220 /* ModuleDeclaration */); + } while (node && node.kind !== 221 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -34155,13 +34585,13 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(179 /* VoidExpression */); + var result = ts.createSynthesizedNode(180 /* VoidExpression */); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 250 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 229 /* ExportAssignment */); + if (node.parent.kind === 251 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 230 /* ExportAssignment */); // only allow export default at a source file level if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!isEs6Module) { @@ -34257,7 +34687,7 @@ var ts; * @param value an expression as a right-hand-side operand of the assignment * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma */ - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment, nodeForSourceMap) { if (shouldEmitCommaBeforeAssignment) { write(", "); } @@ -34267,15 +34697,21 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 213 /* VariableDeclaration */ || name.parent.kind === 165 /* BindingElement */); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 /* VariableDeclaration */ || name.parent.kind === 166 /* BindingElement */); + // If this is first var declaration, we need to start at var/let/const keyword instead + // otherwise use nodeForSourceMap as the start position + emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); + withTemporaryNoSourceMap(function () { + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + }); + emitEnd(nodeForSourceMap, /*stopOverridingSpan*/ true); if (exportChanged) { write(")"); } @@ -34286,14 +34722,19 @@ var ts; * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma */ - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment, sourceMapNode) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment, sourceMapNode || expression.parent); return identifier; } + function isFirstVariableDeclaration(root) { + return root.kind === 214 /* VariableDeclaration */ && + root.parent.kind === 215 /* VariableDeclarationList */ && + root.parent.declarations[0] === root; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -34301,19 +34742,24 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 213 /* VariableDeclaration */) { + if (root.kind === 214 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 138 /* Parameter */) { + else if (root.kind === 139 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 183 /* BinaryExpression */) { + if (root.kind === 184 /* BinaryExpression */) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); + // If first variable declaration of variable statement correct the start location + if (isFirstVariableDeclaration(root)) { + // Use emit location of "var " as next emit start entry + sourceMap.changeEmitSourcePos(); + } emitBindingElement(root, value); } /** @@ -34325,27 +34771,28 @@ var ts; * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; * false if it is necessary to always emit an identifier. */ - function ensureIdentifier(expr, reuseIdentifierExpressions) { + function ensureIdentifier(expr, reuseIdentifierExpressions, sourceMapNode) { if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { return expr; } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0, sourceMapNode); emitCount++; return identifier; } - function createDefaultValueCheck(value, defaultValue) { + function createDefaultValueCheck(value, defaultValue, sourceMapNode) { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // If the temporary variable needs to be emitted use the source Map node for assignment of that statement + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(183 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(184 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(184 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(185 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -34360,9 +34807,10 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 136 /* ComputedPropertyName */; + var nameIsComputed = propName.kind === 137 /* ComputedPropertyName */; if (nameIsComputed) { - index = ensureIdentifier(propName.expression, /*reuseIdentifierExpressions*/ false); + // TODO to handle when we look into sourcemaps for computed properties, for now use propName + index = ensureIdentifier(propName.expression, /*reuseIdentifierExpressions*/ false, propName); } else { // We create a synthetic copy of the identifier in order to avoid the rewriting that might @@ -34375,7 +34823,7 @@ var ts; : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(170 /* CallExpression */); + var call = ts.createSynthesizedNode(171 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -34383,60 +34831,65 @@ var ts; call.arguments[0] = createNumericLiteral(sliceIndex); return call; } - function emitObjectLiteralAssignment(target, value) { + function emitObjectLiteralAssignment(target, value, sourceMapNode) { var properties = target.properties; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // 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, sourceMapNode); } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 247 /* PropertyAssignment */ || p.kind === 248 /* ShorthandPropertyAssignment */) { + if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { var propName = p.name; - var target_1 = p.kind === 248 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 249 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + // Assignment for target = value.propName should highligh whole property, hence use p as source map node + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } } - function emitArrayLiteralAssignment(target, value) { + function emitArrayLiteralAssignment(target, value, sourceMapNode) { var elements = target.elements; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // 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, sourceMapNode); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189 /* OmittedExpression */) { - if (e.kind !== 187 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + if (e.kind !== 190 /* OmittedExpression */) { + // Assignment for target = value.propName should highligh whole property, hence use e as source map node + if (e.kind !== 188 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + emitDestructuringAssignment(e.expression, createSliceCall(value, i), e); } } } } - function emitDestructuringAssignment(target, value) { - if (target.kind === 248 /* ShorthandPropertyAssignment */) { + function emitDestructuringAssignment(target, value, sourceMapNode) { + // When emitting target = value use source map node to highlight, including any temporary assignments needed for this + if (target.kind === 249 /* ShorthandPropertyAssignment */) { if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 183 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); + else if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 167 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); + if (target.kind === 168 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 166 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); + else if (target.kind === 167 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value, sourceMapNode); } else { - emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0, sourceMapNode); emitCount++; } } @@ -34447,25 +34900,32 @@ var ts; emit(value); } else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); + // Source map node for root.left = root.right is root + // but if root is synthetic, which could be in below case, use the target which is { a } + // for ({a} of {a: string}) { + // } + emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 174 /* ParenthesizedExpression */) { + if (root.parent.kind !== 175 /* ParenthesizedExpression */) { write("("); } - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - emitDestructuringAssignment(target, value); + // Temporary assignment needed to emit root should highlight whole binary expression + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, root); + // Source map node for root.left = root.right is root + emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 174 /* ParenthesizedExpression */) { + if (root.parent.kind !== 175 /* ParenthesizedExpression */) { write(")"); } } } function emitBindingElement(target, value) { + // Any temporary assignments needed to emit target = value should point to target if (target.initializer) { // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + value = value ? createDefaultValueCheck(value, target.initializer, target) : target.initializer; } else if (!value) { // Use 'void 0' in absence of value and initializer @@ -34480,16 +34940,16 @@ var ts; // to ensure value is evaluated exactly once. Additionally, if we have zero elements // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, // so in that case, we'll intentionally create that temporary. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0, target); } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 163 /* ObjectBindingPattern */) { + if (pattern.kind === 164 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 189 /* OmittedExpression */) { + else if (element.kind !== 190 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -34501,7 +34961,7 @@ var ts; } } else { - emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0, target); emitCount++; } } @@ -34529,8 +34989,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isLetDefinedInLoop && - node.parent.parent.kind !== 202 /* ForInStatement */ && - node.parent.parent.kind !== 203 /* ForOfStatement */) { + node.parent.parent.kind !== 203 /* ForInStatement */ && + node.parent.parent.kind !== 204 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -34548,7 +35008,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 189 /* OmittedExpression */) { + if (node.kind === 190 /* OmittedExpression */) { return; } var name = node.name; @@ -34560,7 +35020,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 213 /* VariableDeclaration */ && node.parent.kind !== 165 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 214 /* VariableDeclaration */ && node.parent.kind !== 166 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -34568,7 +35028,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 2 /* Export */) && modulekind === 5 /* ES6 */ && - node.parent.kind === 250 /* SourceFile */; + node.parent.kind === 251 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -34619,12 +35079,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_26 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_26); + emit(name_26); } else { emit(node.name); @@ -34729,12 +35189,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 146 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 176 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 177 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -34745,11 +35205,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 175 /* FunctionExpression */) { + if (node.kind === 176 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || modulekind !== 5 /* ES6 */; } @@ -34761,12 +35221,12 @@ var ts; // TODO (yuisu) : we should not have special cases to condition emitting comments // but have one place to fix check for these conditions. var kind = node.kind, parent = node.parent; - if (kind !== 143 /* MethodDeclaration */ && - kind !== 142 /* MethodSignature */ && + if (kind !== 144 /* MethodDeclaration */ && + kind !== 143 /* MethodSignature */ && parent && - parent.kind !== 247 /* PropertyAssignment */ && - parent.kind !== 170 /* CallExpression */ && - parent.kind !== 166 /* ArrayLiteralExpression */) { + parent.kind !== 248 /* PropertyAssignment */ && + parent.kind !== 171 /* CallExpression */ && + parent.kind !== 167 /* ArrayLiteralExpression */) { // 1. Methods will emit comments at their assignment declaration sites. // // 2. If the function is a property of object literal, emitting leading-comments @@ -34805,11 +35265,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 /* ES6 */ && kind === 215 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { + if (modulekind !== 5 /* ES6 */ && kind === 216 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 143 /* MethodDeclaration */ && kind !== 142 /* MethodSignature */) { + if (kind !== 144 /* MethodDeclaration */ && kind !== 143 /* MethodSignature */) { emitTrailingComments(node); } } @@ -34842,7 +35302,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 176 /* ArrowFunction */; + var isArrowFunction = node.kind === 177 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* 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 @@ -34961,7 +35421,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 194 /* Block */) { + if (node.body.kind === 195 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -35020,10 +35480,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 173 /* TypeAssertionExpression */) { + while (current.kind === 174 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 167 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 168 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -35097,9 +35557,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 197 /* ExpressionStatement */) { + if (statement && statement.kind === 198 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 170 /* CallExpression */) { + if (expr && expr.kind === 171 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 95 /* SuperKeyword */) { return statement; @@ -35133,7 +35593,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 136 /* ComputedPropertyName */) { + else if (memberName.kind === 137 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -35145,7 +35605,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { + if (member.kind === 142 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -35185,11 +35645,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 193 /* SemicolonClassElement */) { + if (member.kind === 194 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { + else if (member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -35206,7 +35666,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { + else if (member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -35256,22 +35716,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { + if ((member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 143 /* MethodDeclaration */ || - member.kind === 145 /* GetAccessor */ || - member.kind === 146 /* SetAccessor */) { + else if (member.kind === 144 /* MethodDeclaration */ || + member.kind === 146 /* GetAccessor */ || + member.kind === 147 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 64 /* Static */) { write("static "); } - if (member.kind === 145 /* GetAccessor */) { + if (member.kind === 146 /* GetAccessor */) { write("get "); } - else if (member.kind === 146 /* SetAccessor */) { + else if (member.kind === 147 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -35282,7 +35742,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 193 /* SemicolonClassElement */) { + else if (member.kind === 194 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -35311,11 +35771,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && !member.body) { + if (member.kind === 145 /* Constructor */ && !member.body) { emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { + if (member.kind === 142 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -35429,7 +35889,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -35506,7 +35966,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*isStatic*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 188 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -35588,7 +36048,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 250 /* SourceFile */) { + else if (node.parent.kind !== 251 /* SourceFile */) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -35600,7 +36060,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -35661,11 +36121,11 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { emitExportMemberAssignment(node); } } @@ -35749,7 +36209,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 143 /* MethodDeclaration */) { + if (member.kind === 144 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -35806,7 +36266,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0 /* ES3 */) { - if (member.kind !== 141 /* PropertyDeclaration */) { + if (member.kind !== 142 /* PropertyDeclaration */) { // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. // We have this extra argument here so that we can inject an explicit property descriptor at a later date. write(", null"); @@ -35848,10 +36308,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 142 /* PropertyDeclaration */: return true; } return false; @@ -35861,7 +36321,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 143 /* MethodDeclaration */: + case 144 /* MethodDeclaration */: return true; } return false; @@ -35871,9 +36331,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 216 /* ClassDeclaration */: - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: + case 217 /* ClassDeclaration */: + case 144 /* MethodDeclaration */: + case 147 /* SetAccessor */: return true; } return false; @@ -35891,19 +36351,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: write("Function"); return; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 138 /* Parameter */: + case 139 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 145 /* GetAccessor */: + case 146 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 146 /* SetAccessor */: + case 147 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -35919,23 +36379,23 @@ var ts; case 103 /* VoidKeyword */: write("void 0"); return; - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: write("Function"); return; - case 156 /* ArrayType */: - case 157 /* TupleType */: + case 157 /* ArrayType */: + case 158 /* TupleType */: write("Array"); return; - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: case 120 /* BooleanKeyword */: write("Boolean"); return; case 130 /* StringKeyword */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: write("String"); return; case 128 /* NumberKeyword */: @@ -35944,15 +36404,15 @@ var ts; case 131 /* SymbolKeyword */: write("Symbol"); return; - case 151 /* TypeReference */: + case 152 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 154 /* TypeQuery */: - case 155 /* TypeLiteral */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 155 /* TypeQuery */: + case 156 /* TypeLiteral */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: case 117 /* AnyKeyword */: - case 161 /* ThisType */: + case 162 /* ThisType */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -36025,7 +36485,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -36041,10 +36501,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 156 /* ArrayType */) { + if (parameterType.kind === 157 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 152 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -36121,7 +36581,7 @@ var ts; if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 219 /* EnumDeclaration */))) { + if (!(node.flags & 2 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220 /* EnumDeclaration */))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -36203,7 +36663,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 220 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -36227,7 +36687,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220 /* ModuleDeclaration */)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221 /* ModuleDeclaration */)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -36245,7 +36705,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 221 /* ModuleBlock */) { + if (node.body.kind === 222 /* ModuleBlock */) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -36321,16 +36781,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 223 /* ImportEqualsDeclaration */) { + if (node.kind === 224 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 224 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 225 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -36358,7 +36818,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -36384,7 +36844,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 223 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; + var isExportedImport = node.kind === 224 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); @@ -36403,7 +36863,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 224 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 225 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -36582,8 +37042,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 215 /* FunctionDeclaration */ && - expression.kind !== 216 /* ClassDeclaration */) { + if (expression.kind !== 216 /* FunctionDeclaration */ && + expression.kind !== 217 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -36620,7 +37080,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" @@ -36630,13 +37090,13 @@ var ts; externalImports.push(node); } break; - case 223 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 234 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 224 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 235 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -36654,12 +37114,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_27 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_27] || (exportSpecifiers[name_27] = [])).push(specifier); } } break; - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -36685,18 +37145,18 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 224 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 225 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 230 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 231 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode, emitRelativePathAsModuleName) { if (emitRelativePathAsModuleName) { - var name_25 = getExternalModuleNameFromDeclaration(host, resolver, importNode); - if (name_25) { - return "\"" + name_25 + "\""; + var name_28 = getExternalModuleNameFromDeclaration(host, resolver, importNode); + if (name_28) { + return "\"" + name_28 + "\""; } } var moduleName = ts.getExternalModuleName(importNode); @@ -36714,8 +37174,8 @@ var ts; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 230 /* ExportDeclaration */ || - (importNode.kind === 224 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 231 /* ExportDeclaration */ || + (importNode.kind === 225 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -36748,7 +37208,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 230 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 231 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -36780,7 +37240,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 230 /* ExportDeclaration */) { + if (externalImport.kind !== 231 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -36868,12 +37328,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; i++) { var local = hoistedVars[i]; - var name_26 = local.kind === 69 /* Identifier */ + var name_29 = local.kind === 69 /* Identifier */ ? local : local.name; - if (name_26) { + if (name_29) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_26.text); + var text = ts.unescapeIdentifier(name_29.text); if (ts.hasProperty(seen, text)) { continue; } @@ -36884,7 +37344,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 216 /* ClassDeclaration */ || local.kind === 220 /* ModuleDeclaration */ || local.kind === 219 /* EnumDeclaration */) { + if (local.kind === 217 /* ClassDeclaration */ || local.kind === 221 /* ModuleDeclaration */ || local.kind === 220 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -36918,21 +37378,21 @@ var ts; if (node.flags & 4 /* Ambient */) { return; } - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 219 /* EnumDeclaration */) { + if (node.kind === 220 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -36941,7 +37401,7 @@ var ts; } return; } - if (node.kind === 220 /* ModuleDeclaration */) { + if (node.kind === 221 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -36950,17 +37410,17 @@ var ts; } return; } - if (node.kind === 213 /* VariableDeclaration */ || node.kind === 165 /* BindingElement */) { + if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_27 = node.name; - if (name_27.kind === 69 /* Identifier */) { + var name_30 = node.name; + if (name_30.kind === 69 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_27); + hoistedVars.push(name_30); } else { - ts.forEachChild(name_27, visit); + ts.forEachChild(name_30, visit); } } return; @@ -36991,7 +37451,7 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 250 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 251 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return modulekind === 4 /* System */ && isCurrentFileExternalModule; @@ -37066,21 +37526,21 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -37093,12 +37553,12 @@ var ts; write(exportFunctionForFile + "({"); writeLine(); increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; i_2++) { - if (i_2 !== 0) { + for (var i_1 = 0, len = entry.exportClause.elements.length; i_1 < len; i_1++) { + if (i_1 !== 0) { write(","); writeLine(); } - var e = entry.exportClause.elements[i_2]; + var e = entry.exportClause.elements[i_1]; write("\""); emitNodeWithCommentsAndWithoutSourcemap(e.name); write("\": " + parameterName + "[\""); @@ -37139,10 +37599,10 @@ var ts; // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case 215 /* FunctionDeclaration */: - case 224 /* ImportDeclaration */: + case 216 /* FunctionDeclaration */: + case 225 /* ImportDeclaration */: continue; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -37151,7 +37611,7 @@ var ts; } } continue; - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; @@ -37510,22 +37970,22 @@ var ts; if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 4194304 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { + if (!decorateEmitted && node.flags & 8388608 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { + if (!paramEmitted && node.flags & 16777216 /* HasParamDecorators */) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + if (!awaiterEmitted && node.flags & 33554432 /* HasAsyncFunctions */) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -37596,28 +38056,41 @@ var ts; emitJavaScriptWorker(node); } } + function changeSourceMapEmit(writer) { + sourceMap = writer; + emitStart = writer.emitStart; + emitEnd = writer.emitEnd; + emitPos = writer.emitPos; + setSourceFile = writer.setSourceFile; + } + function withTemporaryNoSourceMap(callback) { + var prevSourceMap = sourceMap; + setSourceMapWriterEmit(ts.getNullSourceMapWriter()); + callback(); + setSourceMapWriterEmit(prevSourceMap); + } function isSpecializedCommentHandling(node) { switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 229 /* ExportAssignment */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 230 /* ExportAssignment */: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -37629,9 +38102,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 194 /* Block */ && + if (node.kind !== 195 /* Block */ && node.parent && - node.parent.kind === 176 /* ArrowFunction */ && + node.parent.kind === 177 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -37644,13 +38117,13 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return emitIdentifier(node); - case 138 /* Parameter */: + case 139 /* Parameter */: return emitParameter(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return emitMethod(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return emitAccessor(node); case 97 /* ThisKeyword */: return emitThis(node); @@ -37670,142 +38143,142 @@ var ts; case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: return emitTemplateExpression(node); - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return emitTemplateSpan(node); - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 238 /* JsxText */: + case 239 /* JsxText */: return emitJsxText(node); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return emitJsxExpression(node); - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return emitQualifiedName(node); - case 163 /* ObjectBindingPattern */: + case 164 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 164 /* ArrayBindingPattern */: + case 165 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 165 /* BindingElement */: + case 166 /* BindingElement */: return emitBindingElement(node); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 247 /* PropertyAssignment */: + case 248 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 248 /* ShorthandPropertyAssignment */: + case 249 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 170 /* CallExpression */: + case 171 /* CallExpression */: return emitCallExpression(node); - case 171 /* NewExpression */: + case 172 /* NewExpression */: return emitNewExpression(node); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 173 /* TypeAssertionExpression */: + case 174 /* TypeAssertionExpression */: return emit(node.expression); - case 191 /* AsExpression */: + case 192 /* AsExpression */: return emit(node.expression); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return emitParenExpression(node); - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return emitDeleteExpression(node); - case 178 /* TypeOfExpression */: + case 179 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 179 /* VoidExpression */: + case 180 /* VoidExpression */: return emitVoidExpression(node); - case 180 /* AwaitExpression */: + case 181 /* AwaitExpression */: return emitAwaitExpression(node); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return emitBinaryExpression(node); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return emitConditionalExpression(node); - case 187 /* SpreadElementExpression */: + case 188 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return emitYieldExpression(node); - case 189 /* OmittedExpression */: + case 190 /* OmittedExpression */: return; - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return emitBlock(node); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return emitVariableStatement(node); - case 196 /* EmptyStatement */: + case 197 /* EmptyStatement */: return write(";"); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return emitExpressionStatement(node); - case 198 /* IfStatement */: + case 199 /* IfStatement */: return emitIfStatement(node); - case 199 /* DoStatement */: + case 200 /* DoStatement */: return emitDoStatement(node); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: return emitWhileStatement(node); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return emitForStatement(node); - case 203 /* ForOfStatement */: - case 202 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 203 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 204 /* ContinueStatement */: - case 205 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 206 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return emitReturnStatement(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return emitWithStatement(node); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return emitSwitchStatement(node); - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return emitLabeledStatement(node); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: return emitThrowStatement(node); - case 211 /* TryStatement */: + case 212 /* TryStatement */: return emitTryStatement(node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return emitCatchClause(node); - case 212 /* DebuggerStatement */: + case 213 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return emitClassExpression(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return emitClassDeclaration(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return emitEnumMember(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return emitImportDeclaration(node); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return emitExportDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return emitSourceFileNode(node); } } @@ -37844,7 +38317,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 250 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 251 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -37859,7 +38332,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 250 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 251 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -38290,7 +38763,25 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + : (function (moduleNames, containingFile) { + var resolvedModuleNames = []; + // resolveModuleName does not store any results between calls. + // lookup is a local cache to avoid resolving the same module name several times + var lookup = {}; + for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { + var moduleName = moduleNames_1[_i]; + var resolvedName = void 0; + if (ts.hasProperty(lookup, moduleName)) { + resolvedName = lookup[moduleName]; + } + else { + resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule; + lookup[moduleName] = resolvedName; + } + resolvedModuleNames.push(resolvedName); + } + return resolvedModuleNames; + }); var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing @@ -38408,14 +38899,18 @@ var ts; // tripleslash references has changed return false; } - // check imports + // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed return false; } + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + return false; + } if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (var i = 0; i < moduleNames.length; i++) { @@ -38580,44 +39075,44 @@ var ts; return false; } switch (node.kind) { - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 245 /* HeritageClause */: + case 246 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: - case 215 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -38625,20 +39120,20 @@ var ts; return true; } break; - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -38646,7 +39141,7 @@ var ts; return true; } break; - case 138 /* Parameter */: + case 139 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -38662,17 +39157,17 @@ var ts; return true; } break; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 173 /* TypeAssertionExpression */: + case 174 /* 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 139 /* Decorator */: + case 140 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -38750,59 +39245,77 @@ var ts; function moduleNameIsEqualTo(a, b) { return a.text === b.text; } + function getTextOfLiteral(literal) { + return literal.text; + } function collectExternalModuleReferences(file) { if (file.imports) { return; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); + var isExternalModuleFile = ts.isExternalModule(file); var imports; + var moduleAugmentations; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; - collect(node, /*allowRelativeModuleNames*/ true, /*collectOnlyRequireCalls*/ false); + collectModuleReferences(node, /*inAmbientModule*/ false); + if (isJavaScriptFile) { + collectRequireCalls(node); + } } file.imports = imports || emptyArray; + file.moduleAugmentations = moduleAugmentations || emptyArray; return; - function collect(node, allowRelativeModuleNames, collectOnlyRequireCalls) { - if (!collectOnlyRequireCalls) { - switch (node.kind) { - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 230 /* ExportDeclaration */: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } + function collectModuleReferences(node, inAmbientModule) { + switch (node.kind) { + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 231 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; - case 220 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 + } + if (!moduleNameExpr.text) { + break; + } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 221 /* ModuleDeclaration */: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { + var moduleName = node.name; + // Ambient module declarations can be interpreted as augmentations for some existing external modules. + // This will happen in two cases: + // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope + // - if current file is not external module then module augmentation is an ambient module declaration with non-relative module name + // immediately nested in top level ambient module declaration . + if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { + (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + } + else if (!inAmbientModule) { // 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. // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /*allowRelativeModuleNames*/ false, collectOnlyRequireCalls); - }); + // NOTE: body of ambient module is always a module block + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + collectModuleReferences(statement, /*inAmbientModule*/ true); + } } - break; - } + } } - if (isJavaScriptFile) { - if (ts.isRequireCall(node)) { - (imports || (imports = [])).push(node.arguments[0]); - } - else { - ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames, /*collectOnlyRequireCalls*/ true); }); - } + } + function collectRequireCalls(node) { + if (ts.isRequireCall(node)) { + (imports || (imports = [])).push(node.arguments[0]); + } + else { + ts.forEachChild(node, collectRequireCalls); } } } @@ -38914,14 +39427,21 @@ var ts; } function processImportedModules(file, basePath) { collectExternalModuleReferences(file); - if (file.imports.length) { + if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); - for (var i = 0; i < file.imports.length; i++) { + for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { + // add file to program only if: + // - resolution was successfull + // - noResolve is falsy + // - module name come from the list fo imports + var shouldAddFile = resolution && + !options.noResolve && + i < file.imports.length; + if (shouldAddFile) { var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, @@ -39786,7 +40306,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 176 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 177 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -39798,30 +40318,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 194 /* Block */: + case 195 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 199 /* DoStatement */ || - parent_7.kind === 202 /* ForInStatement */ || - parent_7.kind === 203 /* ForOfStatement */ || - parent_7.kind === 201 /* ForStatement */ || - parent_7.kind === 198 /* IfStatement */ || - parent_7.kind === 200 /* WhileStatement */ || - parent_7.kind === 207 /* WithStatement */ || - parent_7.kind === 246 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 200 /* DoStatement */ || + parent_8.kind === 203 /* ForInStatement */ || + parent_8.kind === 204 /* ForOfStatement */ || + parent_8.kind === 202 /* ForStatement */ || + parent_8.kind === 199 /* IfStatement */ || + parent_8.kind === 201 /* WhileStatement */ || + parent_8.kind === 208 /* WithStatement */ || + parent_8.kind === 247 /* CatchClause */) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 211 /* TryStatement */) { + if (parent_8.kind === 212 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_7; + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -39844,23 +40364,23 @@ var ts; break; } // Fallthrough. - case 221 /* ModuleBlock */: { + case 222 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 167 /* ObjectLiteralExpression */: - case 222 /* CaseBlock */: { + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 168 /* ObjectLiteralExpression */: + case 223 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -39890,12 +40410,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_31 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_31); 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_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_31); if (!matches) { continue; } @@ -39908,14 +40428,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_31); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_31, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -39953,7 +40473,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 136 /* ComputedPropertyName */) { + else if (declaration.name.kind === 137 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -39974,7 +40494,7 @@ var ts; } return true; } - if (expression.kind === 168 /* PropertyAccessExpression */) { + if (expression.kind === 169 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -39987,7 +40507,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 === 136 /* ComputedPropertyName */) { + if (declaration.name.kind === 137 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -40061,17 +40581,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 220 /* ModuleDeclaration */); + } while (current.kind === 221 /* ModuleDeclaration */); // fall through - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -40082,21 +40602,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 230 /* ExportDeclaration */: + case 231 /* 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 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -40108,7 +40628,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -40117,21 +40637,21 @@ var ts; } } break; - case 165 /* BindingElement */: - case 213 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 214 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: - case 220 /* ModuleDeclaration */: - case 215 /* FunctionDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 216 /* FunctionDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: childNodes.push(node); break; } @@ -40179,17 +40699,17 @@ var ts; for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; switch (node.kind) { - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -40200,12 +40720,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 215 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 216 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 194 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 195 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 215 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 216 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -40265,7 +40785,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 138 /* Parameter */: + case 139 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -40273,36 +40793,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 145 /* GetAccessor */: + case 146 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 146 /* SetAccessor */: + case 147 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 147 /* CallSignature */: + case 148 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: var variableDeclarationNode; - var name_29; - if (node.kind === 165 /* BindingElement */) { - name_29 = node.name; + var name_32; + if (node.kind === 166 /* BindingElement */) { + name_32 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 213 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 214 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -40310,24 +40830,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_32 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.variableElement); } - case 144 /* Constructor */: + case 145 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 232 /* ExportSpecifier */: - case 228 /* ImportSpecifier */: - case 223 /* ImportEqualsDeclaration */: - case 225 /* ImportClause */: - case 226 /* NamespaceImport */: + case 233 /* ExportSpecifier */: + case 229 /* ImportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -40357,29 +40877,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: return createSourceFileItem(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return createClassItem(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return createEnumItem(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return createModuleItem(node); - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { + if (ts.isAmbientModule(moduleDeclaration)) { return getTextOfNode(moduleDeclaration.name); } // 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 === 220 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -40391,7 +40911,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 194 /* Block */) { + if (node.body && node.body.kind === 195 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -40412,7 +40932,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 144 /* Constructor */ && member; + return member.kind === 145 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -40436,7 +40956,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 137 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -40445,13 +40965,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 220 /* ModuleDeclaration */) { + while (node.body.kind === 221 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 250 /* SourceFile */ + return node.kind === 251 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -41202,7 +41722,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 170 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 171 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -41210,7 +41730,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 168 /* PropertyAccessExpression */ + : expression.kind === 169 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -41243,7 +41763,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 170 /* CallExpression */ || node.parent.kind === 171 /* NewExpression */) { + if (node.parent.kind === 171 /* CallExpression */ || node.parent.kind === 172 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -41296,25 +41816,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 172 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 173 /* 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); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 172 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 173 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 185 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 192 /* TemplateSpan */ && node.parent.parent.parent.kind === 172 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 193 /* TemplateSpan */ && node.parent.parent.parent.kind === 173 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 185 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -41432,7 +41952,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 === 185 /* TemplateExpression */) { + if (template.kind === 186 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -41441,7 +41961,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 250 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 251 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -41641,40 +42161,40 @@ var ts; return false; } switch (n.kind) { - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 167 /* ObjectLiteralExpression */: - case 163 /* ObjectBindingPattern */: - case 155 /* TypeLiteral */: - case 194 /* Block */: - case 221 /* ModuleBlock */: - case 222 /* CaseBlock */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 168 /* ObjectLiteralExpression */: + case 164 /* ObjectBindingPattern */: + case 156 /* TypeLiteral */: + case 195 /* Block */: + case 222 /* ModuleBlock */: + case 223 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 171 /* NewExpression */: + case 172 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 170 /* CallExpression */: - case 174 /* ParenthesizedExpression */: - case 160 /* ParenthesizedType */: + case 171 /* CallExpression */: + case 175 /* ParenthesizedExpression */: + case 161 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 176 /* ArrowFunction */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 149 /* ConstructSignature */: + case 148 /* CallSignature */: + case 177 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -41684,64 +42204,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 198 /* IfStatement */: + case 199 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 23 /* SemicolonToken */); - case 166 /* ArrayLiteralExpression */: - case 164 /* ArrayBindingPattern */: - case 169 /* ElementAccessExpression */: - case 136 /* ComputedPropertyName */: - case 157 /* TupleType */: + case 167 /* ArrayLiteralExpression */: + case 165 /* ArrayBindingPattern */: + case 170 /* ElementAccessExpression */: + case 137 /* ComputedPropertyName */: + case 158 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 200 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 201 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 199 /* DoStatement */: + case 200 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 178 /* TypeOfExpression */: - case 177 /* DeleteExpression */: - case 179 /* VoidExpression */: - case 186 /* YieldExpression */: - case 187 /* SpreadElementExpression */: + case 179 /* TypeOfExpression */: + case 178 /* DeleteExpression */: + case 180 /* VoidExpression */: + case 187 /* YieldExpression */: + case 188 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -41797,7 +42317,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 === 273 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 274 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -41903,7 +42423,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 238 /* JsxText */) { + if (isToken(n) || n.kind === 239 /* JsxText */) { return n; } var children = n.getChildren(); @@ -41911,7 +42431,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 238 /* JsxText */) { + if (isToken(n) || n.kind === 239 /* JsxText */) { return n; } var children = n.getChildren(); @@ -41925,10 +42445,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 238 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 239 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 238 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 239 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -41940,7 +42460,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 250 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 251 /* 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. @@ -41962,7 +42482,7 @@ var ts; ts.findPrecedingToken = findPrecedingToken; function isInString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); - return token && (token.kind === 9 /* StringLiteral */ || token.kind === 162 /* StringLiteralType */) && position > token.getStart(); + return token && (token.kind === 9 /* StringLiteral */ || token.kind === 163 /* StringLiteralType */) && position > token.getStart(); } ts.isInString = isInString; function isInComment(sourceFile, position) { @@ -42066,17 +42586,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 151 /* TypeReference */ || node.kind === 170 /* CallExpression */) { + if (node.kind === 152 /* TypeReference */ || node.kind === 171 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 216 /* ClassDeclaration */ || node.kind === 217 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 217 /* ClassDeclaration */ || node.kind === 218 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 135 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -42092,7 +42612,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 162 /* StringLiteralType */ + || kind === 163 /* StringLiteralType */ || kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; @@ -42135,13 +42655,40 @@ var ts; return true; } ts.compareDataObjects = compareDataObjects; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { + if (node.kind === 167 /* ArrayLiteralExpression */ || + node.kind === 168 /* ObjectLiteralExpression */) { + // [a,b,c] from: + // [a, b, c] = someExpression; + if (node.parent.kind === 184 /* BinaryExpression */ && + node.parent.left === node && + node.parent.operatorToken.kind === 56 /* EqualsToken */) { + return true; + } + // [a, b, c] from: + // for([a, b, c] of expression) + if (node.parent.kind === 204 /* ForOfStatement */ && + node.parent.initializer === node) { + return true; + } + // [a, b, c] of + // [x, [a, b, c] ] = someExpression + // or + // {x, a: {a, b, c} } = someExpression + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 248 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + return true; + } + } + return false; + } + ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 139 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -42329,7 +42876,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 228 /* ImportSpecifier */ || location.parent.kind === 232 /* ExportSpecifier */) && + (location.parent.kind === 229 /* ImportSpecifier */ || location.parent.kind === 233 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -42452,10 +42999,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 240 /* JsxAttribute */: - case 237 /* JsxOpeningElement */: - case 239 /* JsxClosingElement */: - case 236 /* JsxSelfClosingElement */: + case 241 /* JsxAttribute */: + case 238 /* JsxOpeningElement */: + case 240 /* JsxClosingElement */: + case 237 /* JsxSelfClosingElement */: return node.kind === 69 /* Identifier */; } } @@ -43059,9 +43606,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_33 in o) { + if (o[name_33] === rule) { + return name_33; } } throw new Error("Unknown rule"); @@ -43070,40 +43617,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 201 /* ForStatement */; + return context.contextNode.kind === 202 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 183 /* BinaryExpression */: - case 184 /* ConditionalExpression */: - case 191 /* AsExpression */: - case 150 /* TypePredicate */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 184 /* BinaryExpression */: + case 185 /* ConditionalExpression */: + case 192 /* AsExpression */: + case 151 /* TypePredicate */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 165 /* BindingElement */: + case 166 /* BindingElement */: // equals in type X = ... - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: // equal in p = 0; - case 138 /* Parameter */: - case 249 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 139 /* Parameter */: + case 250 /* EnumMember */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 202 /* ForInStatement */: + case 203 /* ForInStatement */: return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 203 /* ForOfStatement */: - return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; + case 204 /* ForOfStatement */: + return context.currentTokenSpan.kind === 135 /* OfKeyword */ || context.nextTokenSpan.kind === 135 /* OfKeyword */; } return false; }; @@ -43111,7 +43658,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 184 /* ConditionalExpression */; + return context.contextNode.kind === 185 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -43155,93 +43702,93 @@ var ts; return true; } switch (node.kind) { - case 194 /* Block */: - case 222 /* CaseBlock */: - case 167 /* ObjectLiteralExpression */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 223 /* CaseBlock */: + case 168 /* ObjectLiteralExpression */: + case 222 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 147 /* CallSignature */: - case 175 /* FunctionExpression */: - case 144 /* Constructor */: - case 176 /* ArrowFunction */: + case 148 /* CallSignature */: + case 176 /* FunctionExpression */: + case 145 /* Constructor */: + case 177 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 215 /* FunctionDeclaration */ || context.contextNode.kind === 175 /* FunctionExpression */; + return context.contextNode.kind === 216 /* FunctionDeclaration */ || context.contextNode.kind === 176 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 220 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 156 /* TypeLiteral */: + case 221 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 216 /* ClassDeclaration */: - case 220 /* ModuleDeclaration */: - case 219 /* EnumDeclaration */: - case 194 /* Block */: - case 246 /* CatchClause */: - case 221 /* ModuleBlock */: - case 208 /* SwitchStatement */: + case 217 /* ClassDeclaration */: + case 221 /* ModuleDeclaration */: + case 220 /* EnumDeclaration */: + case 195 /* Block */: + case 247 /* CatchClause */: + case 222 /* ModuleBlock */: + case 209 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 198 /* IfStatement */: - case 208 /* SwitchStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 200 /* WhileStatement */: - case 211 /* TryStatement */: - case 199 /* DoStatement */: - case 207 /* WithStatement */: + case 199 /* IfStatement */: + case 209 /* SwitchStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 201 /* WhileStatement */: + case 212 /* TryStatement */: + case 200 /* DoStatement */: + case 208 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 246 /* CatchClause */: + case 247 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 167 /* ObjectLiteralExpression */; + return context.contextNode.kind === 168 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 170 /* CallExpression */; + return context.contextNode.kind === 171 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 171 /* NewExpression */; + return context.contextNode.kind === 172 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -43253,7 +43800,7 @@ var ts; return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 176 /* ArrowFunction */; + return context.contextNode.kind === 177 /* ArrowFunction */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -43271,41 +43818,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 139 /* Decorator */; + return node.kind === 140 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 214 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 215 /* 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 === 220 /* ModuleDeclaration */; + return context.contextNode.kind === 221 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 156 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 151 /* TypeReference */: - case 173 /* TypeAssertionExpression */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 190 /* ExpressionWithTypeArguments */: + case 152 /* TypeReference */: + case 174 /* TypeAssertionExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 191 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -43316,13 +43863,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 173 /* TypeAssertionExpression */; + return context.contextNode.kind === 174 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 179 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 180 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 186 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 187 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -43346,7 +43893,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 134 /* LastToken */ + 1; + this.mapRowLength = 135 /* 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); @@ -43541,7 +44088,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 135 /* LastToken */; token++) { result.push(token); } return result; @@ -43583,9 +44130,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 135 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 135 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); @@ -43815,17 +44362,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 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 194 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 250 /* SourceFile */: - case 194 /* Block */: - case 221 /* ModuleBlock */: + return body && body.kind === 195 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 251 /* SourceFile */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -44027,19 +44574,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 216 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 217 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 215 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 219 /* EnumDeclaration */: return 219 /* EnumDeclaration */; - case 145 /* GetAccessor */: return 123 /* GetKeyword */; - case 146 /* SetAccessor */: return 129 /* SetKeyword */; - case 143 /* MethodDeclaration */: + case 217 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 218 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 216 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 220 /* EnumDeclaration */: return 220 /* EnumDeclaration */; + case 146 /* GetAccessor */: return 123 /* GetKeyword */; + case 147 /* SetAccessor */: return 129 /* SetKeyword */; + case 144 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 139 /* Parameter */: return node.name.kind; } } @@ -44179,7 +44726,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 140 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -44523,20 +45070,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 144 /* Constructor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 176 /* ArrowFunction */: + case 145 /* Constructor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 177 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -44544,8 +45091,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -44553,7 +45100,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 151 /* TypeReference */: + case 152 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -44669,7 +45216,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 183 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 184 /* 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 */) { @@ -44788,7 +45335,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.isStatement(current)) && - (parent.kind === 250 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 251 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -44821,7 +45368,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 198 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 199 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -44833,23 +45380,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 151 /* TypeReference */: + case 152 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return node.parent.properties; - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return node.parent.elements; - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: { + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -44860,8 +45407,8 @@ var ts; } break; } - case 171 /* NewExpression */: - case 170 /* CallExpression */: { + case 172 /* NewExpression */: + case 171 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -44891,8 +45438,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 170 /* CallExpression */ || - node.parent.kind === 171 /* NewExpression */) && + if (node.parent && (node.parent.kind === 171 /* CallExpression */ || + node.parent.kind === 172 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -44910,10 +45457,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: node = node.expression; break; default: @@ -44977,45 +45524,45 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 197 /* ExpressionStatement */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 166 /* ArrayLiteralExpression */: - case 194 /* Block */: - case 221 /* ModuleBlock */: - case 167 /* ObjectLiteralExpression */: - case 155 /* TypeLiteral */: - case 157 /* TupleType */: - case 222 /* CaseBlock */: - case 244 /* DefaultClause */: - case 243 /* CaseClause */: - case 174 /* ParenthesizedExpression */: - case 168 /* PropertyAccessExpression */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 195 /* VariableStatement */: - case 213 /* VariableDeclaration */: - case 229 /* ExportAssignment */: - case 206 /* ReturnStatement */: - case 184 /* ConditionalExpression */: - case 164 /* ArrayBindingPattern */: - case 163 /* ObjectBindingPattern */: - case 237 /* JsxOpeningElement */: - case 236 /* JsxSelfClosingElement */: - case 242 /* JsxExpression */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 138 /* Parameter */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 160 /* ParenthesizedType */: - case 172 /* TaggedTemplateExpression */: - case 180 /* AwaitExpression */: - case 227 /* NamedImports */: + case 198 /* ExpressionStatement */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 167 /* ArrayLiteralExpression */: + case 195 /* Block */: + case 222 /* ModuleBlock */: + case 168 /* ObjectLiteralExpression */: + case 156 /* TypeLiteral */: + case 158 /* TupleType */: + case 223 /* CaseBlock */: + case 245 /* DefaultClause */: + case 244 /* CaseClause */: + case 175 /* ParenthesizedExpression */: + case 169 /* PropertyAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 196 /* VariableStatement */: + case 214 /* VariableDeclaration */: + case 230 /* ExportAssignment */: + case 207 /* ReturnStatement */: + case 185 /* ConditionalExpression */: + case 165 /* ArrayBindingPattern */: + case 164 /* ObjectBindingPattern */: + case 238 /* JsxOpeningElement */: + case 237 /* JsxSelfClosingElement */: + case 243 /* JsxExpression */: + case 143 /* MethodSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 139 /* Parameter */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 161 /* ParenthesizedType */: + case 173 /* TaggedTemplateExpression */: + case 181 /* AwaitExpression */: + case 228 /* NamedImports */: return true; } return false; @@ -45024,22 +45571,22 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 201 /* ForStatement */: - case 198 /* IfStatement */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 176 /* ArrowFunction */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return childKind !== 194 /* Block */; - case 235 /* JsxElement */: - return childKind !== 239 /* JsxClosingElement */; + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 202 /* ForStatement */: + case 199 /* IfStatement */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 177 /* ArrowFunction */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + return childKind !== 195 /* Block */; + case 236 /* JsxElement */: + return childKind !== 240 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -45191,7 +45738,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(273 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); + var list = createNode(274 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -45210,7 +45757,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 135 /* FirstNode */) { + if (this.kind >= 136 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -45257,7 +45804,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 136 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -45265,7 +45812,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 136 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -45314,7 +45861,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 139 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -45323,15 +45870,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 220 /* ModuleDeclaration */ && declaration.body.kind === 220 /* ModuleDeclaration */) { + if (declaration.kind === 221 /* ModuleDeclaration */ && declaration.body.kind === 221 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 220 /* ModuleDeclaration */ && declaration.parent.kind === 220 /* ModuleDeclaration */) { + while (declaration.kind === 221 /* ModuleDeclaration */ && declaration.parent.kind === 221 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 213 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -45676,9 +46223,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 136 /* ComputedPropertyName */) { + if (declaration.name.kind === 137 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 168 /* PropertyAccessExpression */) { + if (expr.kind === 169 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -45698,9 +46245,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -45720,60 +46267,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 219 /* EnumDeclaration */: - case 220 /* ModuleDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 232 /* ExportSpecifier */: - case 228 /* ImportSpecifier */: - case 223 /* ImportEqualsDeclaration */: - case 225 /* ImportClause */: - case 226 /* NamespaceImport */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 155 /* TypeLiteral */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 220 /* EnumDeclaration */: + case 221 /* ModuleDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 233 /* ExportSpecifier */: + case 229 /* ImportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 156 /* TypeLiteral */: addDeclaration(node); // fall through - case 144 /* Constructor */: - case 195 /* VariableStatement */: - case 214 /* VariableDeclarationList */: - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: - case 221 /* ModuleBlock */: + case 145 /* Constructor */: + case 196 /* VariableStatement */: + case 215 /* VariableDeclarationList */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: + case 222 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 138 /* Parameter */: + case 139 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 56 /* AccessibilityModifier */)) { break; } // fall through - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 249 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 250 /* EnumMember */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: addDeclaration(node); break; - case 230 /* ExportDeclaration */: + case 231 /* 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 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -45785,7 +46332,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -45961,6 +46508,9 @@ var ts; ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; return ClassificationTypeNames; }()); ts.ClassificationTypeNames = ClassificationTypeNames; @@ -45986,6 +46536,9 @@ var ts; 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; function displayPartsToString(displayParts) { @@ -46001,16 +46554,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 175 /* FunctionExpression */) { + if (declaration.kind === 176 /* FunctionExpression */) { return true; } - if (declaration.kind !== 213 /* VariableDeclaration */ && declaration.kind !== 215 /* FunctionDeclaration */) { + if (declaration.kind !== 214 /* VariableDeclaration */ && declaration.kind !== 216 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_8.kind === 250 /* SourceFile */ || parent_8.kind === 221 /* ModuleBlock */) { + if (parent_9.kind === 251 /* SourceFile */ || parent_9.kind === 222 /* ModuleBlock */) { return false; } } @@ -46266,18 +46819,12 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames) { - return useCaseSensitivefileNames - ? (function (fileName) { return fileName; }) - : (function (fileName) { return fileName.toLowerCase(); }); - } - ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; - var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); + var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + +"|" + settings.allowJs; } @@ -46642,7 +47189,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 209 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 210 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -46651,12 +47198,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 69 /* Identifier */ && - (node.parent.kind === 205 /* BreakStatement */ || node.parent.kind === 204 /* ContinueStatement */) && + (node.parent.kind === 206 /* BreakStatement */ || node.parent.kind === 205 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 69 /* Identifier */ && - node.parent.kind === 209 /* LabeledStatement */ && + node.parent.kind === 210 /* LabeledStatement */ && node.parent.label === node; } /** @@ -46664,7 +47211,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 209 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 210 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -46675,25 +47222,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 170 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 171 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 220 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 221 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 69 /* Identifier */ && @@ -46702,22 +47249,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 247 /* PropertyAssignment */ || node.parent.kind === 248 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 248 /* PropertyAssignment */ || node.parent.kind === 249 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* PropertyAssignment */: - case 249 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 220 /* ModuleDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 248 /* PropertyAssignment */: + case 250 /* EnumMember */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 221 /* ModuleDeclaration */: return node.parent.name === node; - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -46776,7 +47323,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 135 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -46791,17 +47338,17 @@ var ts; return undefined; } switch (node.kind) { - case 250 /* SourceFile */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 220 /* ModuleDeclaration */: + case 251 /* SourceFile */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 221 /* ModuleDeclaration */: return node; } } @@ -46809,38 +47356,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 220 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 216 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 217 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 218 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 219 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 213 /* VariableDeclaration */: + case 221 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 217 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 218 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 219 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 220 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 214 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 215 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 216 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 146 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 147 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 249 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 223 /* ImportEqualsDeclaration */: - case 228 /* ImportSpecifier */: - case 225 /* ImportClause */: - case 232 /* ExportSpecifier */: - case 226 /* NamespaceImport */: + case 150 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 149 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 148 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 145 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 138 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 250 /* EnumMember */: return ScriptElementKind.variableElement; + case 139 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 224 /* ImportEqualsDeclaration */: + case 229 /* ImportSpecifier */: + case 226 /* ImportClause */: + case 233 /* ExportSpecifier */: + case 227 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -46878,7 +47425,7 @@ var ts; host.log(message); } } - var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -47152,9 +47699,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 271 /* JSDocTypeTag */: - case 269 /* JSDocParameterTag */: - case 270 /* JSDocReturnTag */: + case 272 /* JSDocTypeTag */: + case 270 /* JSDocParameterTag */: + case 271 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -47199,13 +47746,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_9 = contextToken.parent, kind = contextToken.kind; + var parent_10 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_9.kind === 168 /* PropertyAccessExpression */) { + if (parent_10.kind === 169 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 135 /* QualifiedName */) { + else if (parent_10.kind === 136 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -47220,8 +47767,9 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 239 /* JsxClosingElement */) { + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 240 /* JsxClosingElement */) { isStartingCloseTag = true; + location = contextToken; } } } @@ -47245,7 +47793,10 @@ var ts; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; - symbols = [typeChecker.getSymbolAtLocation(tagName)]; + var tagSymbol = typeChecker.getSymbolAtLocation(tagName); + if (!typeChecker.isUnknownSymbol(tagSymbol)) { + symbols = [tagSymbol]; + } isMemberCompletion = true; isNewIdentifierLocation = false; } @@ -47263,7 +47814,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 168 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -47319,7 +47870,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 236 /* JsxSelfClosingElement */) || (jsxContainer.kind === 237 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 237 /* JsxSelfClosingElement */) || (jsxContainer.kind === 238 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -47391,15 +47942,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 238 /* JsxText */) { + if (contextToken.kind === 239 /* JsxText */) { return true; } if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 237 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 238 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 239 /* JsxClosingElement */ || contextToken.parent.kind === 236 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 235 /* JsxElement */; + if (contextToken.parent.kind === 240 /* JsxClosingElement */ || contextToken.parent.kind === 237 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 236 /* JsxElement */; } } return false; @@ -47409,40 +47960,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 170 /* CallExpression */ // func( a, | - || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 171 /* NewExpression */ // new C(a, | - || containingNodeKind === 166 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 183 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 171 /* CallExpression */ // func( a, | + || containingNodeKind === 145 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 172 /* NewExpression */ // new C(a, | + || containingNodeKind === 167 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 184 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 153 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 170 /* CallExpression */ // func( | - || containingNodeKind === 144 /* Constructor */ // constructor( | - || containingNodeKind === 171 /* NewExpression */ // new C(a| - || containingNodeKind === 174 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 171 /* CallExpression */ // func( | + || containingNodeKind === 145 /* Constructor */ // constructor( | + || containingNodeKind === 172 /* NewExpression */ // new C(a| + || containingNodeKind === 175 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 161 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 166 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 167 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 150 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 137 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 125 /* ModuleKeyword */: // module | case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 220 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 221 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 216 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 217 /* ClassDeclaration */; // class A{ | case 56 /* EqualsToken */: - return containingNodeKind === 213 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 183 /* BinaryExpression */; // x = a| + return containingNodeKind === 214 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 184 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 185 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 186 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 192 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 193 /* TemplateSpan */; // `aa ${10} dd ${| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 142 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -47456,7 +48007,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 162 /* StringLiteralType */ + || contextToken.kind === 163 /* StringLiteralType */ || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_7 = contextToken.getStart(); @@ -47486,14 +48037,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 167 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 168 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 163 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 164 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -47539,9 +48090,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 227 /* NamedImports */ ? - 224 /* ImportDeclaration */ : - 230 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 228 /* NamedImports */ ? + 225 /* ImportDeclaration */ : + 231 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -47566,9 +48117,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 167 /* ObjectLiteralExpression */ || parent_10.kind === 163 /* ObjectBindingPattern */)) { - return parent_10; + var parent_11 = contextToken.parent; + if (parent_11 && (parent_11.kind === 168 /* ObjectLiteralExpression */ || parent_11.kind === 164 /* ObjectBindingPattern */)) { + return parent_11; } break; } @@ -47585,8 +48136,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 227 /* NamedImports */: - case 231 /* NamedExports */: + case 228 /* NamedImports */: + case 232 /* NamedExports */: return contextToken.parent; } } @@ -47595,37 +48146,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_11 = contextToken.parent; + var parent_12 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: - case 240 /* JsxAttribute */: - case 241 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 236 /* JsxSelfClosingElement */ || parent_11.kind === 237 /* JsxOpeningElement */)) { - return parent_11; + case 241 /* JsxAttribute */: + case 242 /* JsxSpreadAttribute */: + if (parent_12 && (parent_12.kind === 237 /* JsxSelfClosingElement */ || parent_12.kind === 238 /* JsxOpeningElement */)) { + return parent_12; } - else if (parent_11.kind === 240 /* JsxAttribute */) { - return parent_11.parent; + else if (parent_12.kind === 241 /* JsxAttribute */) { + return parent_12.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_11 && ((parent_11.kind === 240 /* JsxAttribute */) || (parent_11.kind === 241 /* JsxSpreadAttribute */))) { - return parent_11.parent; + if (parent_12 && ((parent_12.kind === 241 /* JsxAttribute */) || (parent_12.kind === 242 /* JsxSpreadAttribute */))) { + return parent_12.parent; } break; case 16 /* CloseBraceToken */: - if (parent_11 && - parent_11.kind === 242 /* JsxExpression */ && - parent_11.parent && - (parent_11.parent.kind === 240 /* JsxAttribute */)) { - return parent_11.parent.parent; + if (parent_12 && + parent_12.kind === 243 /* JsxExpression */ && + parent_12.parent && + (parent_12.parent.kind === 241 /* JsxAttribute */)) { + return parent_12.parent.parent; } - if (parent_11 && parent_11.kind === 241 /* JsxSpreadAttribute */) { - return parent_11.parent; + if (parent_12 && parent_12.kind === 242 /* JsxSpreadAttribute */) { + return parent_12.parent; } break; } @@ -47634,16 +48185,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return true; } return false; @@ -47655,54 +48206,54 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 213 /* VariableDeclaration */ || - containingNodeKind === 214 /* VariableDeclarationList */ || - containingNodeKind === 195 /* VariableStatement */ || - containingNodeKind === 219 /* EnumDeclaration */ || + return containingNodeKind === 214 /* VariableDeclaration */ || + containingNodeKind === 215 /* VariableDeclarationList */ || + containingNodeKind === 196 /* VariableStatement */ || + containingNodeKind === 220 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 216 /* ClassDeclaration */ || - containingNodeKind === 188 /* ClassExpression */ || - containingNodeKind === 217 /* InterfaceDeclaration */ || - containingNodeKind === 164 /* ArrayBindingPattern */ || - containingNodeKind === 218 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 217 /* ClassDeclaration */ || + containingNodeKind === 189 /* ClassExpression */ || + containingNodeKind === 218 /* InterfaceDeclaration */ || + containingNodeKind === 165 /* ArrayBindingPattern */ || + containingNodeKind === 219 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 164 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 165 /* ArrayBindingPattern */; // var [.| case 54 /* ColonToken */: - return containingNodeKind === 165 /* BindingElement */; // var {x :html| + return containingNodeKind === 166 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 164 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 165 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 246 /* CatchClause */ || + return containingNodeKind === 247 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 219 /* EnumDeclaration */ || - containingNodeKind === 217 /* InterfaceDeclaration */ || - containingNodeKind === 155 /* TypeLiteral */; // const x : { | + return containingNodeKind === 220 /* EnumDeclaration */ || + containingNodeKind === 218 /* InterfaceDeclaration */ || + containingNodeKind === 156 /* TypeLiteral */; // const x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 140 /* PropertySignature */ && + return containingNodeKind === 141 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 217 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 155 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 218 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 156 /* TypeLiteral */); // const x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 216 /* ClassDeclaration */ || - containingNodeKind === 188 /* ClassExpression */ || - containingNodeKind === 217 /* InterfaceDeclaration */ || - containingNodeKind === 218 /* TypeAliasDeclaration */ || + return containingNodeKind === 217 /* ClassDeclaration */ || + containingNodeKind === 189 /* ClassExpression */ || + containingNodeKind === 218 /* InterfaceDeclaration */ || + containingNodeKind === 219 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 113 /* StaticKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; + return containingNodeKind === 142 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 138 /* Parameter */ || + return containingNodeKind === 139 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 164 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 165 /* ArrayBindingPattern */); // var [...z| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 138 /* Parameter */; + return containingNodeKind === 139 /* Parameter */; case 116 /* AsKeyword */: - return containingNodeKind === 228 /* ImportSpecifier */ || - containingNodeKind === 232 /* ExportSpecifier */ || - containingNodeKind === 226 /* NamespaceImport */; + return containingNodeKind === 229 /* ImportSpecifier */ || + containingNodeKind === 233 /* ExportSpecifier */ || + containingNodeKind === 227 /* NamespaceImport */; case 73 /* ClassKeyword */: case 81 /* EnumKeyword */: case 107 /* InterfaceKeyword */: @@ -47762,8 +48313,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_34 = element.propertyName || element.name; + exisingImportsOrExports[name_34.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -47784,10 +48335,10 @@ 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 !== 247 /* PropertyAssignment */ && - m.kind !== 248 /* ShorthandPropertyAssignment */ && - m.kind !== 165 /* BindingElement */ && - m.kind !== 143 /* MethodDeclaration */) { + if (m.kind !== 248 /* PropertyAssignment */ && + m.kind !== 249 /* ShorthandPropertyAssignment */ && + m.kind !== 166 /* BindingElement */ && + m.kind !== 144 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -47795,7 +48346,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 165 /* BindingElement */ && m.propertyName) { + if (m.kind === 166 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 69 /* Identifier */) { existingName = m.propertyName.text; @@ -47825,7 +48376,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 240 /* JsxAttribute */) { + if (attr.kind === 241 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -47851,7 +48402,23 @@ var ts; } else { if (!symbols || symbols.length === 0) { - return undefined; + if (sourceFile.languageVariant === 1 /* JSX */ && + location.parent && location.parent.kind === 240 /* 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: + // var x =
completion list at "1" will contain "div" with type any + var tagName = location.parent.parent.openingElement.tagName; + entries.push({ + name: tagName.text, + kind: undefined, + kindModifiers: undefined, + sortText: "0" + }); + } + else { + return undefined; + } } getCompletionEntriesFromSymbols(symbols, entries); } @@ -47864,10 +48431,10 @@ var ts; var entries = []; var target = program.getCompilerOptions().target; var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!uniqueNames[name_32]) { - uniqueNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks*/ true); + for (var name_35 in nameTable) { + if (!uniqueNames[name_35]) { + uniqueNames[name_35] = name_35; + var displayName = getCompletionEntryDisplayName(name_35, target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -47973,7 +48540,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 188 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -48075,7 +48642,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 168 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 169 /* 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)) { @@ -48084,7 +48651,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 170 /* CallExpression */ || location.kind === 171 /* NewExpression */) { + if (location.kind === 171 /* CallExpression */ || location.kind === 172 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -48097,7 +48664,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 171 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 172 /* NewExpression */ || callExpression.expression.kind === 95 /* 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 @@ -48150,24 +48717,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 145 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 145 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 144 /* Constructor */) { + if (functionDeclaration.kind === 145 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -48176,7 +48743,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 188 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 189 /* 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 @@ -48220,7 +48787,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 220 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 221 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -48243,17 +48810,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 148 /* ConstructSignature */) { + if (declaration.kind === 149 /* ConstructSignature */) { displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 147 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 148 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -48273,7 +48840,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 249 /* EnumMember */) { + if (declaration.kind === 250 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -48289,7 +48856,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 223 /* ImportEqualsDeclaration */) { + if (declaration.kind === 224 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -48418,14 +48985,14 @@ var ts; } var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { + if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: case 97 /* ThisKeyword */: - case 161 /* ThisType */: + case 162 /* ThisType */: case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -48504,8 +49071,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 144 /* Constructor */) || - (!selectConstructors && (d.kind === 215 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 145 /* Constructor */) || + (!selectConstructors && (d.kind === 216 /* FunctionDeclaration */ || d.kind === 144 /* MethodDeclaration */ || d.kind === 143 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -48574,7 +49141,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 === 248 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 249 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -48650,7 +49217,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || - node.kind === 161 /* ThisType */ || + node.kind === 162 /* ThisType */ || node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -48704,75 +49271,75 @@ var ts; switch (node.kind) { case 88 /* IfKeyword */: case 80 /* ElseKeyword */: - if (hasKind(node.parent, 198 /* IfStatement */)) { + if (hasKind(node.parent, 199 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 206 /* ReturnStatement */)) { + if (hasKind(node.parent, 207 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 210 /* ThrowStatement */)) { + if (hasKind(node.parent, 211 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 211 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 212 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 100 /* TryKeyword */: case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 211 /* TryStatement */)) { + if (hasKind(parent(node), 212 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 208 /* SwitchStatement */)) { + if (hasKind(node.parent, 209 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 71 /* CaseKeyword */: case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 208 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 209 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 70 /* BreakKeyword */: case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 205 /* BreakStatement */) || hasKind(node.parent, 204 /* ContinueStatement */)) { + if (hasKind(node.parent, 206 /* BreakStatement */) || hasKind(node.parent, 205 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 86 /* ForKeyword */: - if (hasKind(node.parent, 201 /* ForStatement */) || - hasKind(node.parent, 202 /* ForInStatement */) || - hasKind(node.parent, 203 /* ForOfStatement */)) { + if (hasKind(node.parent, 202 /* ForStatement */) || + hasKind(node.parent, 203 /* ForInStatement */) || + hasKind(node.parent, 204 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 104 /* WhileKeyword */: case 79 /* DoKeyword */: - if (hasKind(node.parent, 200 /* WhileStatement */) || hasKind(node.parent, 199 /* DoStatement */)) { + if (hasKind(node.parent, 201 /* WhileStatement */) || hasKind(node.parent, 200 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 144 /* Constructor */)) { + if (hasKind(node.parent, 145 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 123 /* GetKeyword */: case 129 /* SetKeyword */: - if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { + if (hasKind(node.parent, 146 /* GetAccessor */) || hasKind(node.parent, 147 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 195 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 196 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -48788,10 +49355,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 /* ThrowStatement */) { + if (node.kind === 211 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 211 /* TryStatement */) { + else if (node.kind === 212 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -48818,19 +49385,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 250 /* SourceFile */) { - return parent_12; + var parent_13 = child.parent; + if (ts.isFunctionBlock(parent_13) || parent_13.kind === 251 /* SourceFile */) { + return parent_13; } // 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_12.kind === 211 /* TryStatement */) { - var tryStatement = parent_12; + if (parent_13.kind === 212 /* TryStatement */) { + var tryStatement = parent_13; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_12; + child = parent_13; } return undefined; } @@ -48839,7 +49406,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* BreakStatement */ || node.kind === 204 /* ContinueStatement */) { + if (node.kind === 206 /* BreakStatement */ || node.kind === 205 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -48854,16 +49421,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 208 /* SwitchStatement */: - if (statement.kind === 204 /* ContinueStatement */) { + case 209 /* SwitchStatement */: + if (statement.kind === 205 /* ContinueStatement */) { continue; } // Fall through. - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 200 /* WhileStatement */: - case 199 /* DoStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 201 /* WhileStatement */: + case 200 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -48882,24 +49449,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 === 216 /* ClassDeclaration */ || - container.kind === 188 /* ClassExpression */ || - (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { + if (!(container.kind === 217 /* ClassDeclaration */ || + container.kind === 189 /* ClassExpression */ || + (declaration.kind === 139 /* Parameter */ && hasKind(container, 145 /* Constructor */)))) { return undefined; } } else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 216 /* ClassDeclaration */ || container.kind === 188 /* ClassExpression */)) { + if (!(container.kind === 217 /* ClassDeclaration */ || container.kind === 189 /* ClassExpression */)) { return undefined; } } else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 221 /* ModuleBlock */ || container.kind === 250 /* SourceFile */)) { + if (!(container.kind === 222 /* ModuleBlock */ || container.kind === 251 /* SourceFile */)) { return undefined; } } else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 216 /* ClassDeclaration */ || declaration.kind === 216 /* ClassDeclaration */)) { + if (!(container.kind === 217 /* ClassDeclaration */ || declaration.kind === 217 /* ClassDeclaration */)) { return undefined; } } @@ -48911,8 +49478,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 221 /* ModuleBlock */: - case 250 /* SourceFile */: + case 222 /* ModuleBlock */: + case 251 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -48921,17 +49488,17 @@ var ts; nodes = container.statements; } break; - case 144 /* Constructor */: + case 145 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* 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 & 56 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 144 /* Constructor */ && member; + return member.kind === 145 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -48984,8 +49551,8 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); @@ -49008,7 +49575,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 199 /* DoStatement */) { + if (loopNode.kind === 200 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { @@ -49029,13 +49596,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -49089,7 +49656,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, 194 /* Block */))) { + if (!(func && hasKind(func.body, 195 /* Block */))) { return undefined; } var keywords = []; @@ -49105,7 +49672,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 198 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 199 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -49118,7 +49685,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 198 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 199 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -49235,7 +49802,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 /* ThisKeyword */ || node.kind === 161 /* ThisType */) { + if (node.kind === 97 /* ThisKeyword */ || node.kind === 162 /* ThisType */) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95 /* SuperKeyword */) { @@ -49296,10 +49863,8 @@ var ts; textSpan: ts.createTextSpan(declarations[0].getStart(), 0) }; } - function isImportOrExportSpecifierImportSymbol(symbol) { - return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 228 /* ImportSpecifier */ || declaration.kind === 232 /* ExportSpecifier */; - }); + function isImportSpecifierSymbol(symbol) { + return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 229 /* ImportSpecifier */); } function getInternedName(symbol, location, declarations) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. @@ -49325,14 +49890,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 === 175 /* FunctionExpression */ || valueDeclaration.kind === 188 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 176 /* FunctionExpression */ || valueDeclaration.kind === 189 /* 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 (d.flags & 16 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 216 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 217 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -49358,7 +49923,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 250 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 251 /* 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; @@ -49531,13 +50096,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -49569,27 +50134,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 176 /* 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. @@ -49598,7 +50163,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 250 /* SourceFile */) { + if (searchSpaceNode.kind === 251 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -49624,33 +50189,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 161 /* ThisType */)) { + if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 162 /* ThisType */)) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 217 /* 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 && (container.flags & 64 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 250 /* SourceFile */: - if (container.kind === 250 /* SourceFile */ && !ts.isExternalModule(container)) { + case 251 /* SourceFile */: + if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -49662,9 +50227,17 @@ var ts; // The search set contains at least the current symbol var result = [symbol]; // If the symbol is an alias, add what it alaises to the list - if (isImportOrExportSpecifierImportSymbol(symbol)) { + if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } + // For export specifiers, the exported name can be refering to a local symbol, e.g.: + // import {a} from "mod"; + // export {a as somethingElse} + // We want the *local* declaration of 'a' as declared in the import, + // *not* as declared within "mod" (or farther) + if (location.parent.kind === 233 /* ExportSpecifier */) { + result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent)); + } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set @@ -49692,7 +50265,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 contructor.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 === 138 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -49704,19 +50277,44 @@ var ts; } // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {}); } }); return result; } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to serach for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (ts.hasProperty(previousIterationSymbolsCache, symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 216 /* ClassDeclaration */) { + if (declaration.kind === 217 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 217 /* InterfaceDeclaration */) { + else if (declaration.kind === 218 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -49731,7 +50329,8 @@ var ts; result.push(propertySymbol); } // Visit the typeReference as well to see if it directly or indirectly use that property - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); + previousIterationSymbolsCache[symbol.name] = symbol; + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); } } } @@ -49742,12 +50341,22 @@ var ts; } // If the reference symbol is an alias, check if what it is aliasing is one of the search // symbols. - if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + if (isImportSpecifierSymbol(referenceSymbol)) { var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; } } + // For export specifiers, it can be a local symbol, e.g. + // import {a} from "mod"; + // export {a as somethingElse} + // We want the local target of the export (i.e. the import symbol) and not the final target (i.e. "mod".a) + if (referenceLocation.parent.kind === 233 /* ExportSpecifier */) { + var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } + } // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol @@ -49767,7 +50376,7 @@ var ts; // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, /*previousIterationSymbolsCache*/ {}); return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; @@ -49777,19 +50386,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_36 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_36); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_36); if (symbol) { result_4.push(symbol); } @@ -49798,7 +50407,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_36); if (symbol_1) { return [symbol_1]; } @@ -49856,10 +50465,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 182 /* PostfixUnaryExpression */ || parent.kind === 181 /* PrefixUnaryExpression */) { + if (parent.kind === 183 /* PostfixUnaryExpression */ || parent.kind === 182 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 183 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 184 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } @@ -49890,34 +50499,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 138 /* Parameter */: - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* PropertyAssignment */: - case 248 /* ShorthandPropertyAssignment */: - case 249 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 246 /* CatchClause */: + case 139 /* Parameter */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 248 /* PropertyAssignment */: + case 249 /* ShorthandPropertyAssignment */: + case 250 /* EnumMember */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 247 /* CatchClause */: return 1 /* Value */; - case 137 /* TypeParameter */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 155 /* TypeLiteral */: + case 138 /* TypeParameter */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 156 /* TypeLiteral */: return 2 /* Type */; - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 220 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */) { + case 221 /* ModuleDeclaration */: + if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -49926,15 +50535,15 @@ var ts; else { return 4 /* Namespace */; } - case 227 /* NamedImports */: - case 228 /* ImportSpecifier */: - case 223 /* ImportEqualsDeclaration */: - case 224 /* ImportDeclaration */: - case 229 /* ExportAssignment */: - case 230 /* ExportDeclaration */: + case 228 /* NamedImports */: + case 229 /* ImportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportDeclaration */: + case 230 /* ExportAssignment */: + case 231 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 250 /* SourceFile */: + case 251 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -49943,10 +50552,10 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 151 /* TypeReference */ || - (node.parent.kind === 190 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 152 /* TypeReference */ || + (node.parent.kind === 191 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node)) || - node.kind === 161 /* ThisType */; + node.kind === 162 /* ThisType */; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -49954,32 +50563,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 168 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 168 /* PropertyAccessExpression */) { + if (root.parent.kind === 169 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 169 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 190 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 245 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 191 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 246 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 216 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 217 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 217 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 218 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 135 /* QualifiedName */) { - while (root.parent && root.parent.kind === 135 /* QualifiedName */) { + if (root.parent.kind === 136 /* QualifiedName */) { + while (root.parent && root.parent.kind === 136 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 151 /* TypeReference */ && !isLastClause; + return root.parent.kind === 152 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 135 /* QualifiedName */) { + while (node.parent.kind === 136 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49989,15 +50598,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 135 /* QualifiedName */ && + if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 223 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 224 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 229 /* ExportAssignment */) { + if (node.parent.kind === 230 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -50037,16 +50646,16 @@ var ts; return; } switch (node.kind) { - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: case 9 /* StringLiteral */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: case 84 /* FalseKeyword */: case 99 /* TrueKeyword */: case 93 /* NullKeyword */: case 95 /* SuperKeyword */: case 97 /* ThisKeyword */: - case 161 /* ThisType */: + case 162 /* ThisType */: case 69 /* Identifier */: break; // Cant create the text span @@ -50063,7 +50672,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 === 220 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 221 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -50104,10 +50713,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 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -50161,7 +50770,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 220 /* ModuleDeclaration */ && + return declaration.kind === 221 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -50212,6 +50821,9 @@ var ts; case 19 /* jsxOpenTagName */: return ClassificationTypeNames.jsxOpenTagName; case 20 /* jsxCloseTagName */: return ClassificationTypeNames.jsxCloseTagName; case 21 /* jsxSelfClosingTagName */: return ClassificationTypeNames.jsxSelfClosingTagName; + case 22 /* jsxAttribute */: return ClassificationTypeNames.jsxAttribute; + case 23 /* jsxText */: return ClassificationTypeNames.jsxText; + case 24 /* jsxAttributeStringLiteralValue */: return ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -50319,16 +50931,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 269 /* JSDocParameterTag */: + case 270 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 272 /* JSDocTemplateTag */: + case 273 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 271 /* JSDocTypeTag */: + case 272 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 270 /* JSDocReturnTag */: + case 271 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -50365,7 +50977,8 @@ var ts; function classifyDisabledMergeCode(text, start, end) { // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. - for (var i = start; i < end; i++) { + var i; + for (i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { break; } @@ -50385,11 +50998,11 @@ var ts; pushClassification(start, end - start, type); } } - function classifyToken(token) { + function classifyTokenOrJsxText(token) { if (ts.nodeIsMissing(token)) { return; } - var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenStart = token.kind === 239 /* JsxText */ ? token.pos : classifyLeadingTriviaAndGetTokenStart(token); var tokenWidth = token.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -50419,16 +51032,17 @@ var ts; if (token) { if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 213 /* VariableDeclaration */ || - token.parent.kind === 141 /* PropertyDeclaration */ || - token.parent.kind === 138 /* Parameter */) { + if (token.parent.kind === 214 /* VariableDeclaration */ || + token.parent.kind === 142 /* PropertyDeclaration */ || + token.parent.kind === 139 /* Parameter */ || + token.parent.kind === 241 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 183 /* BinaryExpression */ || - token.parent.kind === 181 /* PrefixUnaryExpression */ || - token.parent.kind === 182 /* PostfixUnaryExpression */ || - token.parent.kind === 184 /* ConditionalExpression */) { + if (token.parent.kind === 184 /* BinaryExpression */ || + token.parent.kind === 182 /* PrefixUnaryExpression */ || + token.parent.kind === 183 /* PostfixUnaryExpression */ || + token.parent.kind === 185 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -50437,8 +51051,8 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 162 /* StringLiteralType */) { - return 6 /* stringLiteral */; + else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 163 /* StringLiteralType */) { + return token.parent.kind === 241 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -50448,54 +51062,61 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } + else if (tokenKind === 239 /* JsxText */) { + return 23 /* jsxText */; + } else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 138 /* Parameter */: + case 139 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } return; - case 237 /* JsxOpeningElement */: + case 238 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } return; - case 239 /* JsxClosingElement */: + case 240 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } return; - case 236 /* JsxSelfClosingElement */: + case 237 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } return; + case 241 /* JsxAttribute */: + if (token.parent.name === token) { + return 22 /* jsxAttribute */; + } } } return 2 /* identifier */; @@ -50511,8 +51132,8 @@ var ts; var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; - if (ts.isToken(child)) { - classifyToken(child); + if (ts.isToken(child) || child.kind === 239 /* JsxText */) { + classifyTokenOrJsxText(child); } else { // Recurse into our child nodes. @@ -50638,19 +51259,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 144 /* Constructor */: - case 216 /* ClassDeclaration */: - case 195 /* VariableStatement */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 145 /* Constructor */: + case 217 /* ClassDeclaration */: + case 196 /* VariableStatement */: break findOwner; - case 250 /* SourceFile */: + case 251 /* SourceFile */: return undefined; - case 220 /* ModuleDeclaration */: + case 221 /* 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 === 220 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 221 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -50692,7 +51313,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 195 /* VariableStatement */) { + if (commentOwner.kind === 196 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -50710,17 +51331,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 174 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 175 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return rightHandSide.parameters; - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 144 /* Constructor */) { + if (member.kind === 145 /* Constructor */) { return member.parameters; } } @@ -50974,7 +51595,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 === 234 /* ExternalModuleReference */ || + node.parent.kind === 235 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -50987,7 +51608,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 169 /* ElementAccessExpression */ && + node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -51246,7 +51867,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 9 /* StringLiteral */ || token === 162 /* StringLiteralType */) { + if (token === 9 /* StringLiteral */ || token === 163 /* StringLiteralType */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -51369,7 +51990,7 @@ var ts; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 135 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -51385,7 +52006,7 @@ var ts; case 8 /* NumericLiteral */: return 4 /* numericLiteral */; case 9 /* StringLiteral */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: return 6 /* stringLiteral */; case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; @@ -51476,6 +52097,9 @@ var ts; startNode.getStart(sourceFile); return ts.createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } + function textSpanEndingAtNextToken(startNode, previousTokenToFindNextEndToken) { + return textSpan(startNode, ts.findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent)); + } function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { return spanInNode(node); @@ -51493,132 +52117,114 @@ var ts; } function spanInNode(node) { if (node) { - if (ts.isExpression(node)) { - if (node.parent.kind === 199 /* DoStatement */) { - // Set span as if on while keyword - return spanInPreviousNode(node); - } - if (node.parent.kind === 139 /* Decorator */) { - // Set breakpoint on the decorator emit - return spanInNode(node.parent); - } - if (node.parent.kind === 201 /* ForStatement */) { - // For now lets set the span on this expression, fix it later - return textSpan(node); - } - if (node.parent.kind === 183 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { - // if this is comma expression, the breakpoint is possible in this expression - return textSpan(node); - } - if (node.parent.kind === 176 /* ArrowFunction */ && node.parent.body === node) { - // If this is body of arrow function, it is allowed to have the breakpoint - return textSpan(node); - } - } switch (node.kind) { - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 213 /* VariableDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 214 /* VariableDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return spanInVariableDeclaration(node); - case 138 /* Parameter */: + case 139 /* Parameter */: return spanInParameterDeclaration(node); - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 145 /* Constructor */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 221 /* ModuleBlock */: + case 222 /* ModuleBlock */: return spanInBlock(node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return spanInBlock(node.block); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: // Span on while(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 199 /* DoStatement */: + return textSpanEndingAtNextToken(node, node.expression); + case 200 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 212 /* DebuggerStatement */: + case 213 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 198 /* IfStatement */: + case 199 /* IfStatement */: // set on if(..) span - return textSpan(node, ts.findNextToken(node.expression, node)); - case 209 /* LabeledStatement */: + return textSpanEndingAtNextToken(node, node.expression); + case 210 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return spanInForStatement(node); - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - // span on for (a in ...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 208 /* SwitchStatement */: + case 203 /* ForInStatement */: + // span of for (a in ...) + return textSpanEndingAtNextToken(node, node.expression); + case 204 /* ForOfStatement */: + // span in initializer + return spanInInitializerOfForLike(node); + case 209 /* SwitchStatement */: // span on switch(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + return textSpanEndingAtNextToken(node, node.expression); + case 244 /* CaseClause */: + case 245 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 211 /* TryStatement */: + case 212 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 249 /* EnumMember */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 250 /* EnumMember */: + case 166 /* BindingElement */: // span on complete node return textSpan(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 139 /* Decorator */: + case 140 /* Decorator */: return spanInNodeArray(node.parent.decorators); + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: + return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -51630,6 +52236,8 @@ var ts; return spanInOpenBraceToken(node); case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); + case 20 /* CloseBracketToken */: + return spanInCloseBracketToken(node); case 17 /* OpenParenToken */: return spanInOpenParenToken(node); case 18 /* CloseParenToken */: @@ -51646,58 +52254,142 @@ var ts; case 72 /* CatchKeyword */: case 85 /* FinallyKeyword */: return spanInNextNode(node); + case 135 /* OfKeyword */: + return spanInOfKeyword(node); default: + // Destructuring pattern in destructuring assignment + // [a, b, c] of + // [a, b, c] = expression + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); + } + // Set breakpoint on identifier element of destructuring pattern + // a or ...c or d: x from + // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern + if ((node.kind === 69 /* Identifier */ || + node.kind == 188 /* SpreadElementExpression */ || + node.kind === 248 /* PropertyAssignment */ || + node.kind === 249 /* ShorthandPropertyAssignment */) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + return textSpan(node); + } + if (node.kind === 184 /* BinaryExpression */) { + var binaryExpression = node; + // Set breakpoint in destructuring pattern if its destructuring assignment + // [a, b, c] or {a, b, c} of + // [a, b, c] = expression or + // {a, b, c} = expression + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); + } + if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { + // Set breakpoint on assignment expression element of destructuring pattern + // a = expression of + // [a = expression, b, c] = someExpression or + // { a = expression, b, c } = someExpression + return textSpan(node); + } + if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) { + return spanInNode(binaryExpression.left); + } + } + if (ts.isExpression(node)) { + switch (node.parent.kind) { + case 200 /* DoStatement */: + // Set span as if on while keyword + return spanInPreviousNode(node); + case 140 /* Decorator */: + // Set breakpoint on the decorator emit + return spanInNode(node.parent); + case 202 /* ForStatement */: + case 204 /* ForOfStatement */: + return textSpan(node); + case 184 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 24 /* CommaToken */) { + // if this is comma expression, the breakpoint is possible in this expression + return textSpan(node); + } + break; + case 177 /* ArrowFunction */: + if (node.parent.body === node) { + // If this is body of arrow function, it is allowed to have the breakpoint + return textSpan(node); + } + break; + } + } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 247 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 248 /* 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 === 173 /* TypeAssertionExpression */ && node.parent.type === node) { - return spanInNode(node.parent.expression); + if (node.parent.kind === 174 /* TypeAssertionExpression */ && node.parent.type === node) { + return spanInNextNode(node.parent.type); } // return type of function go to previous token if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } + // initializer of variable/parameter declaration go to previous node + if ((node.parent.kind === 214 /* VariableDeclaration */ || + node.parent.kind === 139 /* Parameter */)) { + var paramOrVarDecl = node.parent; + if (paramOrVarDecl.initializer === node || + paramOrVarDecl.type === node || + ts.isAssignmentOperator(node.kind)) { + return spanInPreviousNode(node); + } + } + if (node.parent.kind === 184 /* BinaryExpression */) { + var binaryExpression = node.parent; + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && + (binaryExpression.right === node || + binaryExpression.operatorToken === node)) { + // If initializer of destructuring assignment move to previous token + return spanInPreviousNode(node); + } + } // Default go to parent to set the breakpoint return spanInNode(node.parent); } } + function textSpanFromVariableDeclaration(variableDeclaration) { + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] === variableDeclaration) { + // First declaration - include let keyword + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + else { + // Span only on this declaration + return textSpan(variableDeclaration); + } + } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 202 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 203 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 203 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 195 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 201 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); - var declarations = isParentVariableStatement - ? variableDeclaration.parent.parent.declarationList.declarations - : isDeclarationOfForStatement - ? variableDeclaration.parent.parent.initializer.declarations - : undefined; - // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) { - if (declarations && declarations[0] === variableDeclaration) { - if (isParentVariableStatement) { - // First declaration - include let keyword - return textSpan(variableDeclaration.parent, variableDeclaration); - } - else { - ts.Debug.assert(isDeclarationOfForStatement); - // Include let keyword from for statement declarations in the span - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - } - else { - // Span only on this declaration - return textSpan(variableDeclaration); - } + // If this is a destructuring pattern set breakpoint in binding pattern + if (ts.isBindingPattern(variableDeclaration.name)) { + return spanInBindingPattern(variableDeclaration.name); } - else if (declarations && declarations[0] !== variableDeclaration) { + // Breakpoint is possible in variableDeclaration only if there is initialization + // or its declaration from 'for of' + if (variableDeclaration.initializer || + (variableDeclaration.flags & 2 /* Export */) || + variableDeclaration.parent.parent.kind === 204 /* ForOfStatement */) { + return textSpanFromVariableDeclaration(variableDeclaration); + } + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] !== variableDeclaration) { // If we cant set breakpoint on this declaration, set it on previous one - var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); - return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); + // Because the variable declaration may be binding pattern and + // we would like to set breakpoint in last binding element if thats the case, + // use preceding token instead + return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); } } function canHaveSpanInParameterDeclaration(parameter) { @@ -51706,7 +52398,11 @@ var ts; !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); } function spanInParameterDeclaration(parameter) { - if (canHaveSpanInParameterDeclaration(parameter)) { + if (ts.isBindingPattern(parameter.name)) { + // set breakpoint in binding pattern + return spanInBindingPattern(parameter.name); + } + else if (canHaveSpanInParameterDeclaration(parameter)) { return textSpan(parameter); } else { @@ -51724,7 +52420,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 2 /* Export */) || - (functionDeclaration.parent.kind === 216 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); + (functionDeclaration.parent.kind === 217 /* ClassDeclaration */ && functionDeclaration.kind !== 145 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -51747,34 +52443,39 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 200 /* WhileStatement */: - case 198 /* IfStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 201 /* WhileStatement */: + case 199 /* IfStatement */: + case 203 /* 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 201 /* ForStatement */: + case 202 /* ForStatement */: + case 204 /* 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(forLikeStaement) { + if (forLikeStaement.initializer.kind === 215 /* VariableDeclarationList */) { + // declaration list, set breakpoint in first declaration + var variableDeclarationList = forLikeStaement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } + } + else { + // Expression - set breakpoint in it + return spanInNode(forLikeStaement.initializer); + } + } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 214 /* VariableDeclarationList */) { - var variableDeclarationList = forStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } - } - else { - return spanInNode(forStatement.initializer); - } + return spanInInitializerOfForLike(forStatement); } if (forStatement.condition) { return textSpan(forStatement.condition); @@ -51783,16 +52484,44 @@ var ts; return textSpan(forStatement.incrementor); } } + function spanInBindingPattern(bindingPattern) { + // Set breakpoint in first binding element + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + // Empty binding pattern of binding element, set breakpoint on binding element + if (bindingPattern.parent.kind === 166 /* BindingElement */) { + return textSpan(bindingPattern.parent); + } + // Variable declaration is used as the span + return textSpanFromVariableDeclaration(bindingPattern.parent); + } + function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { + ts.Debug.assert(node.kind !== 165 /* ArrayBindingPattern */ && node.kind !== 164 /* ObjectBindingPattern */); + var elements = node.kind === 167 /* ArrayLiteralExpression */ ? + node.elements : + node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + // Could be ArrayLiteral from destructuring assignment or + // 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 === 184 /* BinaryExpression */ ? node.parent : node); + } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -51800,24 +52529,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 221 /* ModuleBlock */: + case 222 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 219 /* EnumDeclaration */: - case 216 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 246 /* CatchClause */: + case 247 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -51825,33 +52554,66 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; + case 164 /* 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); // Default to parent node default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + // Breakpoint in last binding element or binding pattern if it contains no elements + var objectLiteral = node.parent; + return textSpan(ts.lastOrUndefined(objectLiteral.properties) || objectLiteral); + } + return spanInNode(node.parent); + } + } + function spanInCloseBracketToken(node) { + switch (node.parent.kind) { + case 165 /* 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); + default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + // Breakpoint in last binding element or binding pattern if it contains no elements + var arrayLiteral = node.parent; + return textSpan(ts.lastOrUndefined(arrayLiteral.elements) || arrayLiteral); + } + // Default to parent node return spanInNode(node.parent); } } function spanInOpenParenToken(node) { - if (node.parent.kind === 199 /* DoStatement */) { - // Go to while keyword and do action instead + if (node.parent.kind === 200 /* DoStatement */ || + node.parent.kind === 171 /* CallExpression */ || + node.parent.kind === 172 /* NewExpression */) { return spanInPreviousNode(node); } + if (node.parent.kind === 175 /* ParenthesizedExpression */) { + return spanInNextNode(node); + } // Default to parent node return spanInNode(node.parent); } function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 200 /* WhileStatement */: - case 199 /* DoStatement */: - case 201 /* ForStatement */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 145 /* Constructor */: + case 201 /* WhileStatement */: + case 200 /* DoStatement */: + case 202 /* ForStatement */: + case 204 /* ForOfStatement */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 175 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -51860,21 +52622,31 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 247 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || + node.parent.kind === 248 /* PropertyAssignment */ || + node.parent.kind === 139 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 173 /* TypeAssertionExpression */) { - return spanInNode(node.parent.expression); + if (node.parent.kind === 174 /* TypeAssertionExpression */) { + return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 199 /* DoStatement */) { + if (node.parent.kind === 200 /* DoStatement */) { // Set span on while expression - return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); + return textSpanEndingAtNextToken(node, node.parent.expression); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInOfKeyword(node) { + if (node.parent.kind === 204 /* ForOfStatement */) { + // set using next token + return spanInNextNode(node); } // Default to parent node return spanInNode(node.parent); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 797f9ec728c..3cd6e23dc1d 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -167,161 +167,162 @@ declare namespace ts { SymbolKeyword = 131, TypeKeyword = 132, FromKeyword = 133, - OfKeyword = 134, - QualifiedName = 135, - ComputedPropertyName = 136, - TypeParameter = 137, - Parameter = 138, - Decorator = 139, - PropertySignature = 140, - PropertyDeclaration = 141, - MethodSignature = 142, - MethodDeclaration = 143, - Constructor = 144, - GetAccessor = 145, - SetAccessor = 146, - CallSignature = 147, - ConstructSignature = 148, - IndexSignature = 149, - TypePredicate = 150, - TypeReference = 151, - FunctionType = 152, - ConstructorType = 153, - TypeQuery = 154, - TypeLiteral = 155, - ArrayType = 156, - TupleType = 157, - UnionType = 158, - IntersectionType = 159, - ParenthesizedType = 160, - ThisType = 161, - StringLiteralType = 162, - ObjectBindingPattern = 163, - ArrayBindingPattern = 164, - BindingElement = 165, - ArrayLiteralExpression = 166, - ObjectLiteralExpression = 167, - PropertyAccessExpression = 168, - ElementAccessExpression = 169, - CallExpression = 170, - NewExpression = 171, - TaggedTemplateExpression = 172, - TypeAssertionExpression = 173, - ParenthesizedExpression = 174, - FunctionExpression = 175, - ArrowFunction = 176, - DeleteExpression = 177, - TypeOfExpression = 178, - VoidExpression = 179, - AwaitExpression = 180, - PrefixUnaryExpression = 181, - PostfixUnaryExpression = 182, - BinaryExpression = 183, - ConditionalExpression = 184, - TemplateExpression = 185, - YieldExpression = 186, - SpreadElementExpression = 187, - ClassExpression = 188, - OmittedExpression = 189, - ExpressionWithTypeArguments = 190, - AsExpression = 191, - TemplateSpan = 192, - SemicolonClassElement = 193, - Block = 194, - VariableStatement = 195, - EmptyStatement = 196, - ExpressionStatement = 197, - IfStatement = 198, - DoStatement = 199, - WhileStatement = 200, - ForStatement = 201, - ForInStatement = 202, - ForOfStatement = 203, - ContinueStatement = 204, - BreakStatement = 205, - ReturnStatement = 206, - WithStatement = 207, - SwitchStatement = 208, - LabeledStatement = 209, - ThrowStatement = 210, - TryStatement = 211, - DebuggerStatement = 212, - VariableDeclaration = 213, - VariableDeclarationList = 214, - FunctionDeclaration = 215, - ClassDeclaration = 216, - InterfaceDeclaration = 217, - TypeAliasDeclaration = 218, - EnumDeclaration = 219, - ModuleDeclaration = 220, - ModuleBlock = 221, - CaseBlock = 222, - ImportEqualsDeclaration = 223, - ImportDeclaration = 224, - ImportClause = 225, - NamespaceImport = 226, - NamedImports = 227, - ImportSpecifier = 228, - ExportAssignment = 229, - ExportDeclaration = 230, - NamedExports = 231, - ExportSpecifier = 232, - MissingDeclaration = 233, - ExternalModuleReference = 234, - JsxElement = 235, - JsxSelfClosingElement = 236, - JsxOpeningElement = 237, - JsxText = 238, - JsxClosingElement = 239, - JsxAttribute = 240, - JsxSpreadAttribute = 241, - JsxExpression = 242, - CaseClause = 243, - DefaultClause = 244, - HeritageClause = 245, - CatchClause = 246, - PropertyAssignment = 247, - ShorthandPropertyAssignment = 248, - EnumMember = 249, - SourceFile = 250, - JSDocTypeExpression = 251, - JSDocAllType = 252, - JSDocUnknownType = 253, - JSDocArrayType = 254, - JSDocUnionType = 255, - JSDocTupleType = 256, - JSDocNullableType = 257, - JSDocNonNullableType = 258, - JSDocRecordType = 259, - JSDocRecordMember = 260, - JSDocTypeReference = 261, - JSDocOptionalType = 262, - JSDocFunctionType = 263, - JSDocVariadicType = 264, - JSDocConstructorType = 265, - JSDocThisType = 266, - JSDocComment = 267, - JSDocTag = 268, - JSDocParameterTag = 269, - JSDocReturnTag = 270, - JSDocTypeTag = 271, - JSDocTemplateTag = 272, - SyntaxList = 273, - Count = 274, + GlobalKeyword = 134, + OfKeyword = 135, + QualifiedName = 136, + ComputedPropertyName = 137, + TypeParameter = 138, + Parameter = 139, + Decorator = 140, + PropertySignature = 141, + PropertyDeclaration = 142, + MethodSignature = 143, + MethodDeclaration = 144, + Constructor = 145, + GetAccessor = 146, + SetAccessor = 147, + CallSignature = 148, + ConstructSignature = 149, + IndexSignature = 150, + TypePredicate = 151, + TypeReference = 152, + FunctionType = 153, + ConstructorType = 154, + TypeQuery = 155, + TypeLiteral = 156, + ArrayType = 157, + TupleType = 158, + UnionType = 159, + IntersectionType = 160, + ParenthesizedType = 161, + ThisType = 162, + StringLiteralType = 163, + ObjectBindingPattern = 164, + ArrayBindingPattern = 165, + BindingElement = 166, + ArrayLiteralExpression = 167, + ObjectLiteralExpression = 168, + PropertyAccessExpression = 169, + ElementAccessExpression = 170, + CallExpression = 171, + NewExpression = 172, + TaggedTemplateExpression = 173, + TypeAssertionExpression = 174, + ParenthesizedExpression = 175, + FunctionExpression = 176, + ArrowFunction = 177, + DeleteExpression = 178, + TypeOfExpression = 179, + VoidExpression = 180, + AwaitExpression = 181, + PrefixUnaryExpression = 182, + PostfixUnaryExpression = 183, + BinaryExpression = 184, + ConditionalExpression = 185, + TemplateExpression = 186, + YieldExpression = 187, + SpreadElementExpression = 188, + ClassExpression = 189, + OmittedExpression = 190, + ExpressionWithTypeArguments = 191, + AsExpression = 192, + TemplateSpan = 193, + SemicolonClassElement = 194, + Block = 195, + VariableStatement = 196, + EmptyStatement = 197, + ExpressionStatement = 198, + IfStatement = 199, + DoStatement = 200, + WhileStatement = 201, + ForStatement = 202, + ForInStatement = 203, + ForOfStatement = 204, + ContinueStatement = 205, + BreakStatement = 206, + ReturnStatement = 207, + WithStatement = 208, + SwitchStatement = 209, + LabeledStatement = 210, + ThrowStatement = 211, + TryStatement = 212, + DebuggerStatement = 213, + VariableDeclaration = 214, + VariableDeclarationList = 215, + FunctionDeclaration = 216, + ClassDeclaration = 217, + InterfaceDeclaration = 218, + TypeAliasDeclaration = 219, + EnumDeclaration = 220, + ModuleDeclaration = 221, + ModuleBlock = 222, + CaseBlock = 223, + ImportEqualsDeclaration = 224, + ImportDeclaration = 225, + ImportClause = 226, + NamespaceImport = 227, + NamedImports = 228, + ImportSpecifier = 229, + ExportAssignment = 230, + ExportDeclaration = 231, + NamedExports = 232, + ExportSpecifier = 233, + MissingDeclaration = 234, + ExternalModuleReference = 235, + JsxElement = 236, + JsxSelfClosingElement = 237, + JsxOpeningElement = 238, + JsxText = 239, + JsxClosingElement = 240, + JsxAttribute = 241, + JsxSpreadAttribute = 242, + JsxExpression = 243, + CaseClause = 244, + DefaultClause = 245, + HeritageClause = 246, + CatchClause = 247, + PropertyAssignment = 248, + ShorthandPropertyAssignment = 249, + EnumMember = 250, + SourceFile = 251, + JSDocTypeExpression = 252, + JSDocAllType = 253, + JSDocUnknownType = 254, + JSDocArrayType = 255, + JSDocUnionType = 256, + JSDocTupleType = 257, + JSDocNullableType = 258, + JSDocNonNullableType = 259, + JSDocRecordType = 260, + JSDocRecordMember = 261, + JSDocTypeReference = 262, + JSDocOptionalType = 263, + JSDocFunctionType = 264, + JSDocVariadicType = 265, + JSDocConstructorType = 266, + JSDocThisType = 267, + JSDocComment = 268, + JSDocTag = 269, + JSDocParameterTag = 270, + JSDocReturnTag = 271, + JSDocTypeTag = 272, + JSDocTemplateTag = 273, + SyntaxList = 274, + Count = 275, FirstAssignment = 56, LastAssignment = 68, FirstReservedWord = 70, LastReservedWord = 105, FirstKeyword = 70, - LastKeyword = 134, + LastKeyword = 135, FirstFutureReservedWord = 106, LastFutureReservedWord = 114, - FirstTypeNode = 150, - LastTypeNode = 162, + FirstTypeNode = 151, + LastTypeNode = 163, FirstPunctuation = 15, LastPunctuation = 68, FirstToken = 0, - LastToken = 134, + LastToken = 135, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -330,7 +331,7 @@ declare namespace ts { LastTemplateToken = 14, FirstBinaryOperator = 25, LastBinaryOperator = 68, - FirstNode = 135, + FirstNode = 136, } enum NodeFlags { None = 0, @@ -354,10 +355,16 @@ declare namespace ts { ContainsThis = 262144, HasImplicitReturn = 524288, HasExplicitReturn = 1048576, + GlobalAugmentation = 2097152, + HasClassExtends = 4194304, + HasDecorators = 8388608, + HasParamDecorators = 16777216, + HasAsyncFunctions = 33554432, Modifier = 1022, AccessibilityModifier = 56, BlockScoped = 24576, ReachabilityCheckFlags = 1572864, + EmitHelperFlags = 62914560, } enum JsxFlags { None = 0, @@ -1141,6 +1148,7 @@ declare namespace ts { getSymbolAtLocation(node: Node): Symbol; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; getShorthandAssignmentValueSymbol(location: Node): Symbol; + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getTypeAtLocation(node: Node): Type; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; @@ -1154,6 +1162,7 @@ declare namespace ts { isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; + isUnknownSymbol(symbol: Symbol): boolean; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; @@ -1543,6 +1552,8 @@ declare namespace ts { } } declare namespace ts { + type FileWatcherCallback = (path: string, removed?: boolean) => void; + type DirectoryWatcherCallback = (path: string) => void; interface System { args: string[]; newLine: string; @@ -1550,8 +1561,8 @@ declare namespace ts { write(s: string): void; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; - watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher; + watchFile?(path: Path, callback: FileWatcherCallback): FileWatcher; + watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -1565,6 +1576,10 @@ declare namespace ts { interface FileWatcher { close(): void; } + interface DirectoryWatcher extends FileWatcher { + directoryPath: Path; + referenceCount: number; + } var sys: System; } declare namespace ts { @@ -2237,6 +2252,9 @@ declare namespace ts { static jsxOpenTagName: string; static jsxCloseTagName: string; static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } enum ClassificationType { comment = 1, @@ -2260,6 +2278,9 @@ declare namespace ts { jsxOpenTagName = 19, jsxCloseTagName = 20, jsxSelfClosingTagName = 21, + jsxAttribute = 22, + jsxText = 23, + jsxAttributeStringLiteralValue = 24, } interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; @@ -2283,7 +2304,6 @@ declare namespace ts { function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 6608f585b61..bbe9a4b07e3 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -163,182 +163,183 @@ var ts; SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 134] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 135] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 136] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 137] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 138] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 139] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 140] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 142] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 143] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 144] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 145] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 146] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 147] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 148] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 149] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 150] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 161] = "ThisType"; - SyntaxKind[SyntaxKind["StringLiteralType"] = 162] = "StringLiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 151] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 152] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 153] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 154] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 155] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 156] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 157] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 158] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 159] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 160] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 161] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 162] = "ThisType"; + SyntaxKind[SyntaxKind["StringLiteralType"] = 163] = "StringLiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 163] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 164] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 165] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 164] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 165] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 166] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 166] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 167] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 168] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 169] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 170] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 171] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 172] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 173] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 174] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 175] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 176] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 177] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 178] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 179] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 180] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 181] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 182] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 183] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 184] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 185] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 186] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 187] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 188] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 189] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 190] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 191] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 167] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 168] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 169] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 170] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 171] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 172] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 173] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 174] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 175] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 176] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 177] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 178] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 179] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 180] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 181] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 182] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 183] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 184] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 186] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 187] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 188] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 189] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 190] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 191] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 192] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 192] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 193] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 193] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 194] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 194] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 195] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 196] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 197] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 198] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 199] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 200] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 201] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 202] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 203] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 204] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 205] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 206] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 207] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 208] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 209] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 210] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 211] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 212] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 213] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 214] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 215] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 216] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 217] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 218] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 219] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 220] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 221] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 222] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 223] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 224] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 225] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 226] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 227] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 228] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 229] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 230] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 231] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 232] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 233] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 195] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 196] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 197] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 198] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 199] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 200] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 201] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 202] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 203] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 204] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 205] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 206] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 207] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 208] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 209] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 210] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 211] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 212] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 213] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 214] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 215] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 216] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 217] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 218] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 219] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 220] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 221] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 222] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 223] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 224] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 225] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 226] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 227] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 228] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 229] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 230] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 231] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 232] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 233] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 234] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 234] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 235] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 235] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 236] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 237] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 238] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 239] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 240] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 241] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 242] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 236] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 237] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 238] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 239] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 240] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 241] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 242] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 243] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 243] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 244] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 245] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 246] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 244] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 245] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 246] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 247] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 247] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 248] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 248] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 249] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 249] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 250] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 250] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 251] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 251] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 252] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 252] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 253] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 253] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 254] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 255] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 256] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 257] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 258] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 259] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 260] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 261] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 262] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 263] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 264] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 265] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 266] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 267] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 268] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 269] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 270] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 271] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 272] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 254] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 255] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 256] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 257] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 258] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 259] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 260] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 261] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 262] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 263] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 264] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 265] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 266] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 267] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 268] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 269] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 270] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 271] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 272] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 273] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 273] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 274] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 274] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 275] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 135] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 150] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 162] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 163] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 135] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -347,7 +348,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 136] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -372,10 +373,16 @@ var ts; NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 2097152] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 4194304] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 62914560] = "EmitHelperFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ @@ -584,11 +591,6 @@ var ts; NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; - NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; - NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; - NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -1532,7 +1534,8 @@ var ts; directoryComponents.length--; } // Find the component that differs - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + var joinStartIndex; + for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } @@ -1681,6 +1684,12 @@ var ts; return copiedList; } ts.copyListRemovingItem = copyListRemovingItem; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; })(ts || (ts = {})); /// var ts; @@ -1829,7 +1838,7 @@ var ts; var _os = require("os"); // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond - function createWatchedFileSet(interval, chunkSize) { + function createPollingWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } var watchedFiles = []; @@ -1843,13 +1852,13 @@ var ts; if (!watchedFile) { return; } - _fs.stat(watchedFile.fileName, function (err, stats) { + _fs.stat(watchedFile.filePath, function (err, stats) { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.filePath); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + watchedFile.mtime = getModifiedTime(watchedFile.filePath); + watchedFile.callback(watchedFile.filePath, watchedFile.mtime.getTime() === 0); } }); } @@ -1875,11 +1884,11 @@ var ts; nextFileToCheck = nextToCheck; }, interval); } - function addFile(fileName, callback) { + function addFile(filePath, callback) { var file = { - fileName: fileName, + filePath: filePath, callback: callback, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(filePath) }; watchedFiles.push(file); if (watchedFiles.length === 1) { @@ -1898,6 +1907,77 @@ var ts; removeFile: removeFile }; } + function createWatchedFileSet() { + var dirWatchers = ts.createFileMap(); + // One file can have multiple watchers + var fileWatcherCallbacks = ts.createFileMap(); + return { addFile: addFile, removeFile: removeFile }; + function reduceDirWatcherRefCountForFile(filePath) { + var dirPath = ts.getDirectoryPath(filePath); + if (dirWatchers.contains(dirPath)) { + var watcher = dirWatchers.get(dirPath); + watcher.referenceCount -= 1; + if (watcher.referenceCount <= 0) { + watcher.close(); + dirWatchers.remove(dirPath); + } + } + } + function addDirWatcher(dirPath) { + if (dirWatchers.contains(dirPath)) { + var watcher_1 = dirWatchers.get(dirPath); + watcher_1.referenceCount += 1; + return; + } + var watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); + watcher.referenceCount = 1; + dirWatchers.set(dirPath, watcher); + return; + } + function addFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + fileWatcherCallbacks.get(filePath).push(callback); + } + else { + fileWatcherCallbacks.set(filePath, [callback]); + } + } + function addFile(filePath, callback) { + addFileWatcherCallback(filePath, callback); + addDirWatcher(ts.getDirectoryPath(filePath)); + return { filePath: filePath, callback: callback }; + } + function removeFile(watchedFile) { + removeFileWatcherCallback(watchedFile.filePath, watchedFile.callback); + reduceDirWatcherRefCountForFile(watchedFile.filePath); + } + function removeFileWatcherCallback(filePath, callback) { + if (fileWatcherCallbacks.contains(filePath)) { + var newCallbacks = ts.copyListRemovingItem(callback, fileWatcherCallbacks.get(filePath)); + if (newCallbacks.length === 0) { + fileWatcherCallbacks.remove(filePath); + } + else { + fileWatcherCallbacks.set(filePath, newCallbacks); + } + } + } + /** + * @param watcherPath is the path from which the watcher is triggered. + */ + function fileEventHandler(eventName, relativeFileName, baseDirPath) { + // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" + var filePath = typeof relativeFileName !== "string" + ? undefined + : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); + if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { + var fileCallback = _a[_i]; + fileCallback(filePath); + } + } + } + } // REVIEW: for now this implementation uses polling. // The advantage of polling is that it works reliably // on all os and with network mounted files. @@ -1911,7 +1991,11 @@ var ts; // changes for large reference sets? If so, do we want // to increase the chunk size or decrease the interval // time dynamically to match the large reference set? + var pollingWatchedFileSet = createPollingWatchedFileSet(); var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1960,7 +2044,7 @@ var ts; } } function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; + return useCaseSensitiveFileNames ? path : path.toLowerCase(); } function readDirectory(path, extension, exclude) { var result = []; @@ -2000,20 +2084,28 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (filePath, callback) { // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 // and https://github.com/Microsoft/TypeScript/issues/4643), therefore // if the current node.js version is newer than 4, use `fs.watch` instead. - var watchedFile = watchedFileSet.addFile(fileName, callback); + var watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet; + var watchedFile = watchSet.addFile(filePath, callback); return { - close: function () { return watchedFileSet.removeFile(watchedFile); } + close: function () { return watchSet.removeFile(watchedFile); } }; }, watchDirectory: function (path, callback, recursive) { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + var options; + if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + options = { persistent: true, recursive: !!recursive }; + } + else { + options = { persistent: true }; + } + return _fs.watch(path, options, function (eventName, relativeFileName) { // In watchDirectory we only care about adding and removing files (when event name is // "rename"); changes made within files are handled by corresponding fileWatchers (when // event name is "change") @@ -2283,7 +2375,6 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -2519,7 +2610,6 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, - A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods: { code: 2519, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_r_2519", message: "A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, @@ -2548,6 +2638,16 @@ var ts; Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, + Cannot_re_export_name_that_is_not_defined_in_the_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_re_export_name_that_is_not_defined_in_the_module_2661", message: "Cannot re-export name that is not defined in the module." }, + 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." }, + Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope_2665", message: "Module augmentation cannot introduce new names in the top level scope." }, + 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." }, + Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, + Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, 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}'." }, @@ -2712,6 +2812,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, 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'." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, 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." }, 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." }, @@ -2810,6 +2911,7 @@ var ts; "protected": 111 /* ProtectedKeyword */, "public": 112 /* PublicKeyword */, "require": 127 /* RequireKeyword */, + "global": 134 /* GlobalKeyword */, "return": 94 /* ReturnKeyword */, "set": 129 /* SetKeyword */, "static": 113 /* StaticKeyword */, @@ -2830,7 +2932,7 @@ var ts; "yield": 114 /* YieldKeyword */, "async": 118 /* AsyncKeyword */, "await": 119 /* AwaitKeyword */, - "of": 134 /* OfKeyword */, + "of": 135 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -4246,7 +4348,7 @@ var ts; break; } } - return token = 238 /* JsxText */; + return token = 239 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -4429,7 +4531,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 250 /* SourceFile */) { + while (node && node.kind !== 251 /* SourceFile */) { node = node.parent; } return node; @@ -4532,6 +4634,31 @@ var ts; isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isAmbientModule(node) { + return node && node.kind === 221 /* ModuleDeclaration */ && + (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 2097152 /* GlobalAugmentation */); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + // external module augmentation is a ambient module declaration that is either: + // - defined in the top level scope and source file is an external module + // - defined inside ambient module declaration located in the top level scope and source file not an external module + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 251 /* SourceFile */: + return isExternalModule(node.parent); + case 222 /* ModuleBlock */: + return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { @@ -4541,15 +4668,15 @@ var ts; return current; } switch (current.kind) { - case 250 /* SourceFile */: - case 222 /* CaseBlock */: - case 246 /* CatchClause */: - case 220 /* ModuleDeclaration */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 251 /* SourceFile */: + case 223 /* CaseBlock */: + case 247 /* CatchClause */: + case 221 /* ModuleDeclaration */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: return current; - case 194 /* Block */: + case 195 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4562,9 +4689,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 213 /* VariableDeclaration */ && + declaration.kind === 214 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 246 /* CatchClause */; + declaration.parent.kind === 247 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4603,7 +4730,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 250 /* SourceFile */: + case 251 /* 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 @@ -4612,17 +4739,18 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 220 /* ModuleDeclaration */: - case 219 /* EnumDeclaration */: - case 249 /* EnumMember */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 220 /* EnumDeclaration */: + case 250 /* EnumMember */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 219 /* TypeAliasDeclaration */: errorNode = node.name; break; } @@ -4650,11 +4778,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 219 /* EnumDeclaration */ && isConst(node); + return node.kind === 220 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 165 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 166 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4669,14 +4797,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 213 /* VariableDeclaration */) { + if (node.kind === 214 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 214 /* VariableDeclarationList */) { + if (node && node.kind === 215 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 195 /* VariableStatement */) { + if (node && node.kind === 196 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4691,7 +4819,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 197 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 198 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4707,7 +4835,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? + var commentRanges = (node.kind === 139 /* Parameter */ || node.kind === 138 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -4722,7 +4850,7 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (150 /* FirstTypeNode */ <= node.kind && node.kind <= 162 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 163 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -4733,26 +4861,26 @@ var ts; case 131 /* SymbolKeyword */: return true; case 103 /* VoidKeyword */: - return node.parent.kind !== 179 /* VoidExpression */; - case 190 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 180 /* VoidExpression */; + case 191 /* 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 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 169 /* 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 === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 168 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135 /* QualifiedName */: - case 168 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 136 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 154 /* TypeQuery */) { + if (parent_1.kind === 155 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4761,38 +4889,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (150 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 162 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 163 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return node === parent_1.constraint; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 138 /* Parameter */: - case 213 /* VariableDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 139 /* Parameter */: + case 214 /* VariableDeclaration */: return node === parent_1.type; - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 145 /* Constructor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return node === parent_1.type; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return node === parent_1.type; - case 173 /* TypeAssertionExpression */: + case 174 /* TypeAssertionExpression */: return node === parent_1.type; - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4806,23 +4934,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return visitor(node); - case 222 /* CaseBlock */: - case 194 /* Block */: - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 207 /* WithStatement */: - case 208 /* SwitchStatement */: - case 243 /* CaseClause */: - case 244 /* DefaultClause */: - case 209 /* LabeledStatement */: - case 211 /* TryStatement */: - case 246 /* CatchClause */: + case 223 /* CaseBlock */: + case 195 /* Block */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 208 /* WithStatement */: + case 209 /* SwitchStatement */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: + case 210 /* LabeledStatement */: + case 212 /* TryStatement */: + case 247 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4832,18 +4960,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: - case 220 /* ModuleDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 217 /* ClassDeclaration */: + case 189 /* 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. @@ -4851,7 +4979,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 137 /* 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); @@ -4870,14 +4998,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 165 /* BindingElement */: - case 249 /* EnumMember */: - case 138 /* Parameter */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 248 /* ShorthandPropertyAssignment */: - case 213 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 250 /* EnumMember */: + case 139 /* Parameter */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 249 /* ShorthandPropertyAssignment */: + case 214 /* VariableDeclaration */: return true; } } @@ -4885,11 +5013,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); + return node && (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 216 /* ClassDeclaration */ || node.kind === 188 /* ClassExpression */); + return node && (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -4898,32 +5026,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 144 /* Constructor */: - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 145 /* Constructor */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: return true; } return false; @@ -4931,24 +5059,24 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: return true; - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 194 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 195 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 167 /* ObjectLiteralExpression */; + return node && node.kind === 144 /* MethodDeclaration */ && node.parent.kind === 168 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { @@ -4980,7 +5108,7 @@ var ts; return undefined; } switch (node.kind) { - case 136 /* ComputedPropertyName */: + case 137 /* 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 @@ -4995,9 +5123,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 139 /* Decorator */: + case 140 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 139 /* 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; @@ -5008,26 +5136,26 @@ var ts; node = node.parent; } break; - case 176 /* ArrowFunction */: + case 177 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 220 /* ModuleDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 219 /* EnumDeclaration */: - case 250 /* SourceFile */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 221 /* ModuleDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 220 /* EnumDeclaration */: + case 251 /* SourceFile */: return node; } } @@ -5048,26 +5176,26 @@ var ts; return node; } switch (node.kind) { - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: node = node.parent; break; - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return node; - case 139 /* Decorator */: + case 140 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 139 /* 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; @@ -5085,12 +5213,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 151 /* TypeReference */: + case 152 /* TypeReference */: return node.typeName; - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return node.expression; case 69 /* Identifier */: - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return node; } } @@ -5098,7 +5226,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5107,58 +5235,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: // classes are valid targets return true; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 216 /* ClassDeclaration */; - case 138 /* 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 && node.parent.parent.kind === 216 /* ClassDeclaration */; - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: + return node.parent.kind === 217 /* ClassDeclaration */; + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 144 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 216 /* ClassDeclaration */; + return node.body !== undefined + && node.parent.kind === 217 /* ClassDeclaration */; + case 139 /* 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 === 145 /* Constructor */ + || node.parent.kind === 144 /* MethodDeclaration */ + || node.parent.kind === 147 /* SetAccessor */) + && node.parent.parent.kind === 217 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { - switch (node.kind) { - case 216 /* ClassDeclaration */: - if (node.decorators) { - return true; - } - return false; - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - if (node.decorators) { - return true; - } - return false; - case 145 /* GetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; + return node.decorators !== undefined + && nodeCanBeDecorated(node); } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 168 /* PropertyAccessExpression */; + return node.kind === 169 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 169 /* ElementAccessExpression */; + return node.kind === 170 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -5168,42 +5278,42 @@ var ts; case 99 /* TrueKeyword */: case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 166 /* ArrayLiteralExpression */: - case 167 /* ObjectLiteralExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 172 /* TaggedTemplateExpression */: - case 191 /* AsExpression */: - case 173 /* TypeAssertionExpression */: - case 174 /* ParenthesizedExpression */: - case 175 /* FunctionExpression */: - case 188 /* ClassExpression */: - case 176 /* ArrowFunction */: - case 179 /* VoidExpression */: - case 177 /* DeleteExpression */: - case 178 /* TypeOfExpression */: - case 181 /* PrefixUnaryExpression */: - case 182 /* PostfixUnaryExpression */: - case 183 /* BinaryExpression */: - case 184 /* ConditionalExpression */: - case 187 /* SpreadElementExpression */: - case 185 /* TemplateExpression */: + case 167 /* ArrayLiteralExpression */: + case 168 /* ObjectLiteralExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 173 /* TaggedTemplateExpression */: + case 192 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 175 /* ParenthesizedExpression */: + case 176 /* FunctionExpression */: + case 189 /* ClassExpression */: + case 177 /* ArrowFunction */: + case 180 /* VoidExpression */: + case 178 /* DeleteExpression */: + case 179 /* TypeOfExpression */: + case 182 /* PrefixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: + case 184 /* BinaryExpression */: + case 185 /* ConditionalExpression */: + case 188 /* SpreadElementExpression */: + case 186 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 189 /* OmittedExpression */: - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: - case 186 /* YieldExpression */: - case 180 /* AwaitExpression */: + case 190 /* OmittedExpression */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: + case 187 /* YieldExpression */: + case 181 /* AwaitExpression */: return true; - case 135 /* QualifiedName */: - while (node.parent.kind === 135 /* QualifiedName */) { + case 136 /* QualifiedName */: + while (node.parent.kind === 136 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 154 /* TypeQuery */; + return node.parent.kind === 155 /* TypeQuery */; case 69 /* Identifier */: - if (node.parent.kind === 154 /* TypeQuery */) { + if (node.parent.kind === 155 /* TypeQuery */) { return true; } // fall through @@ -5212,47 +5322,47 @@ var ts; case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 213 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 249 /* EnumMember */: - case 247 /* PropertyAssignment */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 139 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 250 /* EnumMember */: + case 248 /* PropertyAssignment */: + case 166 /* BindingElement */: return parent_2.initializer === node; - case 197 /* ExpressionStatement */: - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 206 /* ReturnStatement */: - case 207 /* WithStatement */: - case 208 /* SwitchStatement */: - case 243 /* CaseClause */: - case 210 /* ThrowStatement */: - case 208 /* SwitchStatement */: + case 198 /* ExpressionStatement */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 207 /* ReturnStatement */: + case 208 /* WithStatement */: + case 209 /* SwitchStatement */: + case 244 /* CaseClause */: + case 211 /* ThrowStatement */: + case 209 /* SwitchStatement */: return parent_2.expression === node; - case 201 /* ForStatement */: + case 202 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 214 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 215 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 214 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215 /* VariableDeclarationList */) || forInStatement.expression === node; - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: return node === parent_2.expression; - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return node === parent_2.expression; - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: return node === parent_2.expression; - case 139 /* Decorator */: - case 242 /* JsxExpression */: - case 241 /* JsxSpreadAttribute */: + case 140 /* Decorator */: + case 243 /* JsxExpression */: + case 242 /* JsxSpreadAttribute */: return true; - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5276,7 +5386,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 234 /* ExternalModuleReference */; + return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5285,7 +5395,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 223 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 234 /* ExternalModuleReference */; + return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 235 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5303,7 +5413,7 @@ var ts; */ function isRequireCall(expression) { // of the form 'require("name")' - return expression.kind === 170 /* CallExpression */ && + return expression.kind === 171 /* CallExpression */ && expression.expression.kind === 69 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1 && @@ -5313,11 +5423,11 @@ var ts; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 183 /* BinaryExpression */) { + if (expression.kind !== 184 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 168 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 169 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -5335,7 +5445,7 @@ var ts; else if (lhs.expression.kind === 97 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 168 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 169 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 /* Identifier */ && innerPropertyAccess.name.text === "prototype") { @@ -5346,30 +5456,33 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 224 /* ImportDeclaration */) { + if (node.kind === 225 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 223 /* ImportEqualsDeclaration */) { + if (node.kind === 224 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 234 /* ExternalModuleReference */) { + if (reference.kind === 235 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 230 /* ExportDeclaration */) { + if (node.kind === 231 /* ExportDeclaration */) { return node.moduleSpecifier; } + if (node.kind === 221 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return node.name; + } } ts.getExternalModuleName = getExternalModuleName; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 138 /* Parameter */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 248 /* ShorthandPropertyAssignment */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 139 /* Parameter */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 249 /* ShorthandPropertyAssignment */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5377,9 +5490,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 263 /* JSDocFunctionType */ && + return node.kind === 264 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 265 /* JSDocConstructorType */; + node.parameters[0].type.kind === 266 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5393,15 +5506,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 271 /* JSDocTypeTag */); + return getJSDocTag(node, 272 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 270 /* JSDocReturnTag */); + return getJSDocTag(node, 271 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 272 /* JSDocTemplateTag */); + return getJSDocTag(node, 273 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5412,7 +5525,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 269 /* JSDocParameterTag */) { + if (t.kind === 270 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5431,12 +5544,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 264 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 265 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 264 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 265 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5457,7 +5570,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 164 /* ArrayBindingPattern */ || node.kind === 163 /* ObjectBindingPattern */); + return !!node && (node.kind === 165 /* ArrayBindingPattern */ || node.kind === 164 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -5481,34 +5594,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 176 /* ArrowFunction */: - case 165 /* BindingElement */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 144 /* Constructor */: - case 219 /* EnumDeclaration */: - case 249 /* EnumMember */: - case 232 /* ExportSpecifier */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 225 /* ImportClause */: - case 223 /* ImportEqualsDeclaration */: - case 228 /* ImportSpecifier */: - case 217 /* InterfaceDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 220 /* ModuleDeclaration */: - case 226 /* NamespaceImport */: - case 138 /* Parameter */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 146 /* SetAccessor */: - case 248 /* ShorthandPropertyAssignment */: - case 218 /* TypeAliasDeclaration */: - case 137 /* TypeParameter */: - case 213 /* VariableDeclaration */: + case 177 /* ArrowFunction */: + case 166 /* BindingElement */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 145 /* Constructor */: + case 220 /* EnumDeclaration */: + case 250 /* EnumMember */: + case 233 /* ExportSpecifier */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 146 /* GetAccessor */: + case 226 /* ImportClause */: + case 224 /* ImportEqualsDeclaration */: + case 229 /* ImportSpecifier */: + case 218 /* InterfaceDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 221 /* ModuleDeclaration */: + case 227 /* NamespaceImport */: + case 139 /* Parameter */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 147 /* SetAccessor */: + case 249 /* ShorthandPropertyAssignment */: + case 219 /* TypeAliasDeclaration */: + case 138 /* TypeParameter */: + case 214 /* VariableDeclaration */: return true; } return false; @@ -5516,25 +5629,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: - case 212 /* DebuggerStatement */: - case 199 /* DoStatement */: - case 197 /* ExpressionStatement */: - case 196 /* EmptyStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 201 /* ForStatement */: - case 198 /* IfStatement */: - case 209 /* LabeledStatement */: - case 206 /* ReturnStatement */: - case 208 /* SwitchStatement */: - case 210 /* ThrowStatement */: - case 211 /* TryStatement */: - case 195 /* VariableStatement */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 229 /* ExportAssignment */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 213 /* DebuggerStatement */: + case 200 /* DoStatement */: + case 198 /* ExpressionStatement */: + case 197 /* EmptyStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 202 /* ForStatement */: + case 199 /* IfStatement */: + case 210 /* LabeledStatement */: + case 207 /* ReturnStatement */: + case 209 /* SwitchStatement */: + case 211 /* ThrowStatement */: + case 212 /* TryStatement */: + case 196 /* VariableStatement */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 230 /* ExportAssignment */: return true; default: return false; @@ -5543,13 +5656,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: + case 145 /* Constructor */: + case 142 /* PropertyDeclaration */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 143 /* MethodSignature */: + case 150 /* IndexSignature */: return true; default: return false; @@ -5562,7 +5675,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 228 /* ImportSpecifier */ || parent.kind === 232 /* ExportSpecifier */) { + if (parent.kind === 229 /* ImportSpecifier */ || parent.kind === 233 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5577,31 +5690,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 249 /* EnumMember */: - case 247 /* PropertyAssignment */: - case 168 /* PropertyAccessExpression */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 250 /* EnumMember */: + case 248 /* PropertyAssignment */: + case 169 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 135 /* QualifiedName */) { + while (parent.kind === 136 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 154 /* TypeQuery */; + return parent.kind === 155 /* TypeQuery */; } return false; - case 165 /* BindingElement */: - case 228 /* ImportSpecifier */: + case 166 /* BindingElement */: + case 229 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 232 /* ExportSpecifier */: + case 233 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -5617,12 +5730,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 223 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ImportClause */ && !!node.name || - node.kind === 226 /* NamespaceImport */ || - node.kind === 228 /* ImportSpecifier */ || - node.kind === 232 /* ExportSpecifier */ || - node.kind === 229 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; + return node.kind === 224 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ImportClause */ && !!node.name || + node.kind === 227 /* NamespaceImport */ || + node.kind === 229 /* ImportSpecifier */ || + node.kind === 233 /* ExportSpecifier */ || + node.kind === 230 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5704,7 +5817,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 135 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5731,7 +5844,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 136 /* ComputedPropertyName */ && + return name.kind === 137 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -5749,7 +5862,7 @@ var ts; if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 136 /* ComputedPropertyName */) { + if (name.kind === 137 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5789,18 +5902,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 138 /* Parameter */; + return root.kind === 139 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 165 /* BindingElement */) { + while (node.kind === 166 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 220 /* ModuleDeclaration */ || n.kind === 250 /* SourceFile */; + return isFunctionLike(n) || n.kind === 221 /* ModuleDeclaration */ || n.kind === 251 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; /** @@ -5850,7 +5963,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 135 /* QualifiedName */; + return node.kind === 136 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -6180,7 +6293,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 145 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6197,10 +6310,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 145 /* GetAccessor */) { + if (accessor.kind === 146 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 146 /* SetAccessor */) { + else if (accessor.kind === 147 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6209,7 +6322,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) + if ((member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6220,10 +6333,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 145 /* GetAccessor */ && !getAccessor) { + if (member.kind === 146 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 146 /* SetAccessor */ && !setAccessor) { + if (member.kind === 147 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6433,24 +6546,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 171 /* NewExpression */: - case 170 /* CallExpression */: - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: - case 172 /* TaggedTemplateExpression */: - case 166 /* ArrayLiteralExpression */: - case 174 /* ParenthesizedExpression */: - case 167 /* ObjectLiteralExpression */: - case 188 /* ClassExpression */: - case 175 /* FunctionExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 172 /* NewExpression */: + case 171 /* CallExpression */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: + case 173 /* TaggedTemplateExpression */: + case 167 /* ArrayLiteralExpression */: + case 175 /* ParenthesizedExpression */: + case 168 /* ObjectLiteralExpression */: + case 189 /* ClassExpression */: + case 176 /* FunctionExpression */: case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: case 84 /* FalseKeyword */: case 93 /* NullKeyword */: case 97 /* ThisKeyword */: @@ -6467,7 +6580,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 190 /* ExpressionWithTypeArguments */ && + return node.kind === 191 /* ExpressionWithTypeArguments */ && node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } @@ -6490,16 +6603,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 167 /* ObjectLiteralExpression */) { + if (kind === 168 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 166 /* ArrayLiteralExpression */) { + if (kind === 167 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6854,9 +6967,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 137 /* TypeParameter */) { + if (d && d.kind === 138 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 217 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218 /* InterfaceDeclaration */) { return current; } } @@ -6864,7 +6977,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent); + return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 145 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -6876,7 +6989,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 250 /* SourceFile */) { + if (kind === 251 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -6919,26 +7032,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 248 /* ShorthandPropertyAssignment */: + case 249 /* 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 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* PropertyAssignment */: - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 139 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 248 /* PropertyAssignment */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6947,24 +7060,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6975,290 +7088,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 157 /* TupleType */: + case 158 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 173 /* TypeAssertionExpression */: + case 174 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 178 /* TypeOfExpression */: + case 179 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 179 /* VoidExpression */: + case 180 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 180 /* AwaitExpression */: + case 181 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 191 /* AsExpression */: + case 192 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 187 /* SpreadElementExpression */: + case 188 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 214 /* VariableDeclarationList */: + case 215 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 198 /* IfStatement */: + case 199 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 199 /* DoStatement */: + case 200 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 202 /* ForInStatement */: + case 203 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* ForOfStatement */: + case 204 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* ContinueStatement */: - case 205 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 206 /* BreakStatement */: return visitNode(cbNode, node.label); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 243 /* CaseClause */: + case 244 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 244 /* DefaultClause */: + case 245 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 211 /* TryStatement */: + case 212 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 139 /* Decorator */: + case 140 /* Decorator */: return visitNode(cbNode, node.expression); - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* 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 217 /* InterfaceDeclaration */: + case 218 /* 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 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 225 /* ImportClause */: + case 226 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 226 /* NamespaceImport */: + case 227 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 227 /* NamedImports */: - case 231 /* NamedExports */: + case 228 /* NamedImports */: + case 232 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 245 /* HeritageClause */: + case 246 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 234 /* ExternalModuleReference */: + case 235 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 233 /* MissingDeclaration */: + case 234 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 235 /* JsxElement */: + case 236 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 236 /* JsxSelfClosingElement */: - case 237 /* JsxOpeningElement */: + case 237 /* JsxSelfClosingElement */: + case 238 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 240 /* JsxAttribute */: + case 241 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 241 /* JsxSpreadAttribute */: + case 242 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 239 /* JsxClosingElement */: + case 240 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 251 /* JSDocTypeExpression */: + case 252 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 255 /* JSDocUnionType */: + case 256 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 256 /* JSDocTupleType */: + case 257 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 254 /* JSDocArrayType */: + case 255 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 258 /* JSDocNonNullableType */: + case 259 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 257 /* JSDocNullableType */: + case 258 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 259 /* JSDocRecordType */: + case 260 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 261 /* JSDocTypeReference */: + case 262 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 262 /* JSDocOptionalType */: + case 263 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 263 /* JSDocFunctionType */: + case 264 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 264 /* JSDocVariadicType */: + case 265 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 265 /* JSDocConstructorType */: + case 266 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 266 /* JSDocThisType */: + case 267 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 260 /* JSDocRecordMember */: + case 261 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 267 /* JSDocComment */: + case 268 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 269 /* JSDocParameterTag */: + case 270 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 270 /* JSDocReturnTag */: + case 271 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 271 /* JSDocTypeTag */: + case 272 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 272 /* JSDocTemplateTag */: + case 273 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7466,9 +7579,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 195 /* VariableStatement */: - case 215 /* FunctionDeclaration */: - case 138 /* Parameter */: + case 196 /* VariableStatement */: + case 216 /* FunctionDeclaration */: + case 139 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7511,7 +7624,7 @@ var ts; function createSourceFile(fileName, languageVersion) { // 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(250 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(251 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -7685,16 +7798,18 @@ var ts; } return result; } - // Invokes the provided callback then unconditionally restores the parser to the state it - // was in immediately prior to invoking the callback. The result of invoking the callback - // is returned from this function. + /** Invokes the provided callback then unconditionally restores the parser to the state it + * was in immediately prior to invoking the callback. The result of invoking the callback + * is returned from this function. + */ function lookAhead(callback) { return speculationHelper(callback, /*isLookAhead*/ true); } - // Invokes the provided callback. If the callback returns something falsy, then it restores - // the parser to the state it was in immediately prior to invoking the callback. If the - // callback returns something truthy, then the parser state is not rolled back. The result - // of invoking the callback is returned from this function. + /** Invokes the provided callback. If the callback returns something falsy, then it restores + * the parser to the state it was in immediately prior to invoking the callback. If the + * callback returns something truthy, then the parser state is not rolled back. The result + * of invoking the callback is returned from this function. + */ function tryParse(callback) { return speculationHelper(callback, /*isLookAhead*/ false); } @@ -7861,7 +7976,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(136 /* ComputedPropertyName */); + var node = createNode(137 /* ComputedPropertyName */); parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -8262,14 +8377,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 144 /* Constructor */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: - case 193 /* SemicolonClassElement */: + case 145 /* Constructor */: + case 150 /* IndexSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 194 /* SemicolonClassElement */: return true; - case 143 /* MethodDeclaration */: + case 144 /* 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. @@ -8284,8 +8399,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: return true; } } @@ -8294,58 +8409,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: - case 195 /* VariableStatement */: - case 194 /* Block */: - case 198 /* IfStatement */: - case 197 /* ExpressionStatement */: - case 210 /* ThrowStatement */: - case 206 /* ReturnStatement */: - case 208 /* SwitchStatement */: - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 201 /* ForStatement */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 196 /* EmptyStatement */: - case 211 /* TryStatement */: - case 209 /* LabeledStatement */: - case 199 /* DoStatement */: - case 212 /* DebuggerStatement */: - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 230 /* ExportDeclaration */: - case 229 /* ExportAssignment */: - case 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 218 /* TypeAliasDeclaration */: + case 216 /* FunctionDeclaration */: + case 196 /* VariableStatement */: + case 195 /* Block */: + case 199 /* IfStatement */: + case 198 /* ExpressionStatement */: + case 211 /* ThrowStatement */: + case 207 /* ReturnStatement */: + case 209 /* SwitchStatement */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 202 /* ForStatement */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 197 /* EmptyStatement */: + case 212 /* TryStatement */: + case 210 /* LabeledStatement */: + case 200 /* DoStatement */: + case 213 /* DebuggerStatement */: + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 231 /* ExportDeclaration */: + case 230 /* ExportAssignment */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 219 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 249 /* EnumMember */; + return node.kind === 250 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 148 /* ConstructSignature */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 140 /* PropertySignature */: - case 147 /* CallSignature */: + case 149 /* ConstructSignature */: + case 143 /* MethodSignature */: + case 150 /* IndexSignature */: + case 141 /* PropertySignature */: + case 148 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 213 /* VariableDeclaration */) { + if (node.kind !== 214 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8366,7 +8481,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 138 /* Parameter */) { + if (node.kind !== 139 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8483,7 +8598,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(135 /* QualifiedName */, entity.pos); + var node = createNode(136 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8522,7 +8637,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(185 /* TemplateExpression */); + var template = createNode(186 /* TemplateExpression */); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8535,7 +8650,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(192 /* TemplateSpan */); + var span = createNode(193 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8549,7 +8664,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(162 /* StringLiteralType */, /*internName*/ true); + return parseLiteralLikeNode(163 /* StringLiteralType */, /*internName*/ true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -8584,12 +8699,9 @@ var ts; return node; } // TYPES - function parseTypeReferenceOrTypePredicate() { + function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(typeName); - } - var node = createNode(151 /* TypeReference */, typeName.pos); + var node = createNode(152 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -8598,24 +8710,24 @@ var ts; } function parseTypePredicate(lhs) { nextToken(); - var node = createNode(150 /* TypePredicate */, lhs.pos); + var node = createNode(151 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(161 /* ThisType */); + var node = createNode(162 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(154 /* TypeQuery */); + var node = createNode(155 /* TypeQuery */); parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(137 /* TypeParameter */); + var node = createNode(138 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8659,7 +8771,7 @@ var ts; } } function parseParameter() { - var node = createNode(138 /* Parameter */); + var node = createNode(139 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8702,10 +8814,10 @@ var ts; signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } else if (parseOptional(returnToken)) { - signature.type = parseType(); + signature.type = parseTypeOrTypePredicate(); } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { @@ -8753,7 +8865,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 148 /* ConstructSignature */) { + if (kind === 149 /* ConstructSignature */) { parseExpected(92 /* NewKeyword */); } fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -8817,7 +8929,7 @@ var ts; return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149 /* IndexSignature */, fullStart); + var node = createNode(150 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -8830,7 +8942,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(142 /* MethodSignature */, fullStart); + var method = createNode(143 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -8840,7 +8952,7 @@ var ts; return finishNode(method); } else { - var property = createNode(140 /* PropertySignature */, fullStart); + var property = createNode(141 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8888,7 +9000,7 @@ var ts; switch (token) { case 17 /* OpenParenToken */: case 25 /* LessThanToken */: - return parseSignatureMember(147 /* CallSignature */); + return parseSignatureMember(148 /* CallSignature */); case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -8896,7 +9008,7 @@ var ts; : parsePropertyOrMethodSignature(); case 92 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148 /* ConstructSignature */); + return parseSignatureMember(149 /* ConstructSignature */); } // fall through. case 9 /* StringLiteral */: @@ -8933,7 +9045,7 @@ var ts; return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(155 /* TypeLiteral */); + var node = createNode(156 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -8949,12 +9061,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(157 /* TupleType */); + var node = createNode(158 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(160 /* ParenthesizedType */); + var node = createNode(161 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -8962,7 +9074,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 153 /* ConstructorType */) { + if (kind === 154 /* ConstructorType */) { parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -8981,7 +9093,7 @@ var ts; case 131 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); + return node || parseTypeReference(); case 9 /* StringLiteral */: return parseStringLiteralTypeNode(); case 103 /* VoidKeyword */: @@ -9004,7 +9116,7 @@ var ts; case 17 /* OpenParenToken */: return parseParenthesizedType(); default: - return parseTypeReferenceOrTypePredicate(); + return parseTypeReference(); } } function isStartOfType() { @@ -9039,7 +9151,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(156 /* ArrayType */, type.pos); + var node = createNode(157 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9061,10 +9173,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(160 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(159 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9101,6 +9213,26 @@ var ts; } return false; } + function parseTypeOrTypePredicate() { + var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); + var type = parseType(); + if (typePredicateVariable) { + var node = createNode(151 /* TypePredicate */, typePredicateVariable.pos); + node.parameterName = typePredicateVariable; + node.type = type; + return finishNode(node); + } + else { + return type; + } + } + function parseTypePredicatePrefix() { + var id = parseIdentifier(); + if (token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + return id; + } + } 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. @@ -9108,10 +9240,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152 /* FunctionType */); + return parseFunctionOrConstructorType(153 /* FunctionType */); } if (token === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(153 /* ConstructorType */); + return parseFunctionOrConstructorType(154 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -9304,7 +9436,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(186 /* YieldExpression */); + var node = createNode(187 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9324,8 +9456,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(176 /* ArrowFunction */, identifier.pos); - var parameter = createNode(138 /* Parameter */, identifier.pos); + var node = createNode(177 /* ArrowFunction */, identifier.pos); + var parameter = createNode(139 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9477,7 +9609,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(176 /* ArrowFunction */); + var node = createNode(177 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. @@ -9543,7 +9675,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(184 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(185 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -9556,7 +9688,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 135 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9664,39 +9796,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(183 /* BinaryExpression */, left.pos); + var node = createNode(184 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(191 /* AsExpression */, left.pos); + var node = createNode(192 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(181 /* PrefixUnaryExpression */); + var node = createNode(182 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(177 /* DeleteExpression */); + var node = createNode(178 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(178 /* TypeOfExpression */); + var node = createNode(179 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(179 /* VoidExpression */); + var node = createNode(180 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9712,7 +9844,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(180 /* AwaitExpression */); + var node = createNode(181 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9738,7 +9870,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 173 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 174 /* 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 { @@ -9828,7 +9960,7 @@ var ts; */ function parseIncrementExpression() { if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { - var node = createNode(181 /* PrefixUnaryExpression */); + var node = createNode(182 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -9841,7 +9973,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(182 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(183 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9945,7 +10077,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(168 /* PropertyAccessExpression */, expression.pos); + var node = createNode(169 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -9964,8 +10096,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 237 /* JsxOpeningElement */) { - var node = createNode(235 /* JsxElement */, opening.pos); + if (opening.kind === 238 /* JsxOpeningElement */) { + var node = createNode(236 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -9975,7 +10107,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 236 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 237 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -9990,7 +10122,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(183 /* BinaryExpression */, result.pos); + var badNode = createNode(184 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -10002,13 +10134,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(238 /* JsxText */, scanner.getStartPos()); + var node = createNode(239 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 238 /* JsxText */: + case 239 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10050,7 +10182,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(237 /* JsxOpeningElement */, fullStart); + node = createNode(238 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -10062,7 +10194,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(236 /* JsxSelfClosingElement */, fullStart); + node = createNode(237 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10073,7 +10205,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(135 /* QualifiedName */, elementName.pos); + var node = createNode(136 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10081,7 +10213,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(242 /* JsxExpression */); + var node = createNode(243 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -10100,7 +10232,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(240 /* JsxAttribute */); + var node = createNode(241 /* JsxAttribute */); node.name = parseIdentifierName(); if (parseOptional(56 /* EqualsToken */)) { switch (token) { @@ -10115,7 +10247,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(241 /* JsxSpreadAttribute */); + var node = createNode(242 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10123,7 +10255,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(239 /* JsxClosingElement */); + var node = createNode(240 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10136,7 +10268,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(173 /* TypeAssertionExpression */); + var node = createNode(174 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); @@ -10147,7 +10279,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(168 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(169 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10156,7 +10288,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(169 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(170 /* 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. @@ -10172,7 +10304,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(172 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(173 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10195,7 +10327,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(170 /* CallExpression */, expression.pos); + var callExpr = createNode(171 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10203,7 +10335,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(170 /* CallExpression */, expression.pos); + var callExpr = createNode(171 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10313,28 +10445,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(174 /* ParenthesizedExpression */); + var node = createNode(175 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(187 /* SpreadElementExpression */); + var node = createNode(188 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(189 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(190 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(166 /* ArrayLiteralExpression */); + var node = createNode(167 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 1024 /* MultiLine */; @@ -10344,10 +10476,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(146 /* GetAccessor */, fullStart, decorators, modifiers); } else if (parseContextualModifier(129 /* SetKeyword */)) { - return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(147 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10374,7 +10506,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(248 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(249 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56 /* EqualsToken */); @@ -10385,7 +10517,7 @@ var ts; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(247 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(248 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -10395,7 +10527,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(167 /* ObjectLiteralExpression */); + var node = createNode(168 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 1024 /* MultiLine */; @@ -10414,7 +10546,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(175 /* FunctionExpression */); + var node = createNode(176 /* FunctionExpression */); setModifiers(node, parseModifiers()); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); @@ -10436,7 +10568,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(171 /* NewExpression */); + var node = createNode(172 /* NewExpression */); parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -10447,7 +10579,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(194 /* Block */); + var node = createNode(195 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10477,12 +10609,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(196 /* EmptyStatement */); + var node = createNode(197 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(198 /* IfStatement */); + var node = createNode(199 /* IfStatement */); parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10492,7 +10624,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(199 /* DoStatement */); + var node = createNode(200 /* DoStatement */); parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); parseExpected(104 /* WhileKeyword */); @@ -10507,7 +10639,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(200 /* WhileStatement */); + var node = createNode(201 /* WhileStatement */); parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10530,21 +10662,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(202 /* ForInStatement */, pos); + var forInStatement = createNode(203 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(134 /* OfKeyword */)) { - var forOfStatement = createNode(203 /* ForOfStatement */, pos); + else if (parseOptional(135 /* OfKeyword */)) { + var forOfStatement = createNode(204 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(201 /* ForStatement */, pos); + var forStatement = createNode(202 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10562,7 +10694,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 205 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10570,7 +10702,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(206 /* ReturnStatement */); + var node = createNode(207 /* ReturnStatement */); parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -10579,7 +10711,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(207 /* WithStatement */); + var node = createNode(208 /* WithStatement */); parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10588,7 +10720,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(243 /* CaseClause */); + var node = createNode(244 /* CaseClause */); parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(54 /* ColonToken */); @@ -10596,7 +10728,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(244 /* DefaultClause */); + var node = createNode(245 /* DefaultClause */); parseExpected(77 /* DefaultKeyword */); parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -10606,12 +10738,12 @@ var ts; return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(208 /* SwitchStatement */); + var node = createNode(209 /* SwitchStatement */); parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(222 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(223 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10626,7 +10758,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(210 /* ThrowStatement */); + var node = createNode(211 /* ThrowStatement */); parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -10634,7 +10766,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(211 /* TryStatement */); + var node = createNode(212 /* TryStatement */); parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -10647,7 +10779,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(246 /* CatchClause */); + var result = createNode(247 /* CatchClause */); parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -10657,7 +10789,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(212 /* DebuggerStatement */); + var node = createNode(213 /* DebuggerStatement */); parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -10669,13 +10801,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(209 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(210 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(197 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(198 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -10742,6 +10874,8 @@ var ts; return false; } continue; + case 134 /* GlobalKeyword */: + return nextToken() === 15 /* OpenBraceToken */; case 89 /* ImportKeyword */: nextToken(); return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || @@ -10801,6 +10935,7 @@ var ts; case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: case 132 /* TypeKeyword */: + case 134 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 112 /* PublicKeyword */: @@ -10849,9 +10984,9 @@ var ts; case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(204 /* ContinueStatement */); + return parseBreakOrContinueStatement(205 /* ContinueStatement */); case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(205 /* BreakStatement */); + return parseBreakOrContinueStatement(206 /* BreakStatement */); case 94 /* ReturnKeyword */: return parseReturnStatement(); case 105 /* WithKeyword */: @@ -10884,6 +11019,7 @@ var ts; case 112 /* PublicKeyword */: case 115 /* AbstractKeyword */: case 113 /* StaticKeyword */: + case 134 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10910,6 +11046,7 @@ var ts; return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); + case 134 /* GlobalKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -10924,7 +11061,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(233 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(234 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10946,16 +11083,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(189 /* OmittedExpression */); + return createNode(190 /* OmittedExpression */); } - var node = createNode(165 /* BindingElement */); + var node = createNode(166 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(165 /* BindingElement */); + var node = createNode(166 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54 /* ColonToken */) { @@ -10970,14 +11107,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(163 /* ObjectBindingPattern */); + var node = createNode(164 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(164 /* ArrayBindingPattern */); + var node = createNode(165 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -10996,7 +11133,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(213 /* VariableDeclaration */); + var node = createNode(214 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11005,7 +11142,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(214 /* VariableDeclarationList */); + var node = createNode(215 /* VariableDeclarationList */); switch (token) { case 102 /* VarKeyword */: break; @@ -11028,7 +11165,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 === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 135 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11043,7 +11180,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(195 /* VariableStatement */, fullStart); + var node = createNode(196 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -11051,7 +11188,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* FunctionDeclaration */, fullStart); + var node = createNode(216 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); @@ -11064,7 +11201,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144 /* Constructor */, pos); + var node = createNode(145 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121 /* ConstructorKeyword */); @@ -11073,7 +11210,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143 /* MethodDeclaration */, fullStart); + var method = createNode(144 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11086,7 +11223,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141 /* PropertyDeclaration */, fullStart); + var property = createNode(142 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11212,7 +11349,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(139 /* Decorator */, decoratorStart); + var decorator = createNode(140 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11277,7 +11414,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(193 /* SemicolonClassElement */); + var result = createNode(194 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11315,10 +11452,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 188 /* ClassExpression */); + /*modifiers*/ undefined, 189 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 216 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -11362,7 +11499,7 @@ var ts; } function parseHeritageClause() { if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { - var node = createNode(245 /* HeritageClause */); + var node = createNode(246 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11371,7 +11508,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(190 /* ExpressionWithTypeArguments */); + var node = createNode(191 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11385,7 +11522,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217 /* InterfaceDeclaration */, fullStart); + var node = createNode(218 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107 /* InterfaceKeyword */); @@ -11396,7 +11533,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* TypeAliasDeclaration */, fullStart); + var node = createNode(219 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(132 /* TypeKeyword */); @@ -11412,13 +11549,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(249 /* EnumMember */, scanner.getStartPos()); + var node = createNode(250 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219 /* EnumDeclaration */, fullStart); + var node = createNode(220 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81 /* EnumKeyword */); @@ -11433,7 +11570,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(221 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(222 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11444,7 +11581,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(220 /* ModuleDeclaration */, fullStart); + var node = createNode(221 /* 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 & 65536 /* Namespace */; @@ -11458,16 +11595,27 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* ModuleDeclaration */, fullStart); + var node = createNode(221 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(/*internName*/ true); + if (token === 134 /* GlobalKeyword */) { + // parse 'global' as name of global scope augmentation + node.name = parseIdentifier(); + node.flags |= 2097152 /* GlobalAugmentation */; + } + else { + node.name = parseLiteralNode(/*internName*/ true); + } node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126 /* NamespaceKeyword */)) { + if (token === 134 /* GlobalKeyword */) { + // global augmentation + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + else if (parseOptional(126 /* NamespaceKeyword */)) { flags |= 65536 /* Namespace */; } else { @@ -11498,7 +11646,7 @@ var ts; // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(223 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(224 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -11509,7 +11657,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(224 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(225 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11532,7 +11680,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(225 /* ImportClause */, fullStart); + var importClause = createNode(226 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11542,7 +11690,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(227 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(228 /* NamedImports */); } return finishNode(importClause); } @@ -11552,7 +11700,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(234 /* ExternalModuleReference */); + var node = createNode(235 /* ExternalModuleReference */); parseExpected(127 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -11575,7 +11723,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(226 /* NamespaceImport */); + var namespaceImport = createNode(227 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -11590,14 +11738,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 227 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 228 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(232 /* ExportSpecifier */); + return parseImportOrExportSpecifier(233 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(228 /* ImportSpecifier */); + return parseImportOrExportSpecifier(229 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11622,14 +11770,14 @@ var ts; else { node.name = identifierName; } - if (kind === 228 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 229 /* 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(230 /* ExportDeclaration */, fullStart); + var node = createNode(231 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { @@ -11637,7 +11785,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(231 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(232 /* 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. @@ -11650,7 +11798,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(229 /* ExportAssignment */, fullStart); + var node = createNode(230 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56 /* EqualsToken */)) { @@ -11725,10 +11873,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 2 /* Export */ - || node.kind === 223 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 234 /* ExternalModuleReference */ - || node.kind === 224 /* ImportDeclaration */ - || node.kind === 229 /* ExportAssignment */ - || node.kind === 230 /* ExportDeclaration */ + || node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */ + || node.kind === 225 /* ImportDeclaration */ + || node.kind === 230 /* ExportAssignment */ + || node.kind === 231 /* ExportDeclaration */ ? node : undefined; }); @@ -11803,7 +11951,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(251 /* JSDocTypeExpression */); + var result = createNode(252 /* JSDocTypeExpression */); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11814,12 +11962,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47 /* BarToken */) { - var unionType = createNode(255 /* JSDocUnionType */, type.pos); + var unionType = createNode(256 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56 /* EqualsToken */) { - var optionalType = createNode(262 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(263 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11830,20 +11978,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(254 /* JSDocArrayType */, type.pos); + var arrayType = createNode(255 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 53 /* QuestionToken */) { - var nullableType = createNode(257 /* JSDocNullableType */, type.pos); + var nullableType = createNode(258 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49 /* ExclamationToken */) { - var nonNullableType = createNode(258 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(259 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11888,27 +12036,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(266 /* JSDocThisType */); + var result = createNode(267 /* JSDocThisType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(265 /* JSDocConstructorType */); + var result = createNode(266 /* JSDocConstructorType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(264 /* JSDocVariadicType */); + var result = createNode(265 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(263 /* JSDocFunctionType */); + var result = createNode(264 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -11921,12 +12069,12 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(138 /* Parameter */); + var parameter = createNode(139 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(261 /* JSDocTypeReference */); + var result = createNode(262 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(21 /* DotToken */)) { if (token === 25 /* LessThanToken */) { @@ -11956,13 +12104,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(135 /* QualifiedName */, left.pos); + var result = createNode(136 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(259 /* JSDocRecordType */); + var result = createNode(260 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -11970,7 +12118,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(260 /* JSDocRecordMember */); + var result = createNode(261 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 54 /* ColonToken */) { nextToken(); @@ -11979,13 +12127,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(258 /* JSDocNonNullableType */); + var result = createNode(259 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(256 /* JSDocTupleType */); + var result = createNode(257 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -11999,7 +12147,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(255 /* JSDocUnionType */); + var result = createNode(256 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12017,7 +12165,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(252 /* JSDocAllType */); + var result = createNode(253 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12040,11 +12188,11 @@ var ts; token === 27 /* GreaterThanToken */ || token === 56 /* EqualsToken */ || token === 47 /* BarToken */) { - var result = createNode(253 /* JSDocUnknownType */, pos); + var result = createNode(254 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(257 /* JSDocNullableType */, pos); + var result = createNode(258 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -12132,7 +12280,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(267 /* JSDocComment */, start); + var result = createNode(268 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12169,7 +12317,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(268 /* JSDocTag */, atToken.pos); + var result = createNode(269 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12220,7 +12368,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(269 /* JSDocParameterTag */, atToken.pos); + var result = createNode(270 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12230,27 +12378,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(270 /* JSDocReturnTag */, atToken.pos); + var result = createNode(271 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(271 /* JSDocTypeTag */, atToken.pos); + var result = createNode(272 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12263,7 +12411,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(138 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12274,7 +12422,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(272 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(273 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12804,16 +12952,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 217 /* InterfaceDeclaration */ || node.kind === 218 /* TypeAliasDeclaration */) { + if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 219 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 224 /* ImportDeclaration */ || node.kind === 223 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { + else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 221 /* ModuleBlock */) { + else if (node.kind === 222 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -12832,7 +12980,7 @@ var ts; }); return state; } - else if (node.kind === 220 /* ModuleDeclaration */) { + else if (node.kind === 221 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -12882,6 +13030,11 @@ var ts; var labelStack; var labelIndexMap; var implicitLabels; + // state used for emit helpers + var hasClassExtends; + var hasAsyncFunctions; + var hasDecorators; + var hasParameterDecorators; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -12911,6 +13064,10 @@ var ts; labelStack = undefined; labelIndexMap = undefined; implicitLabels = undefined; + hasClassExtends = false; + hasAsyncFunctions = false; + hasDecorators = false; + hasParameterDecorators = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -12933,7 +13090,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 220 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -12943,10 +13100,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 220 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { - return "\"" + node.name.text + "\""; + if (ts.isAmbientModule(node)) { + return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* 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)) { @@ -12958,21 +13115,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 144 /* Constructor */: + case 145 /* Constructor */: return "__constructor"; - case 152 /* FunctionType */: - case 147 /* CallSignature */: + case 153 /* FunctionType */: + case 148 /* CallSignature */: return "__call"; - case 153 /* ConstructorType */: - case 148 /* ConstructSignature */: + case 154 /* ConstructorType */: + case 149 /* ConstructSignature */: return "__new"; - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: return "__index"; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return "__export"; - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -12987,8 +13144,8 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 215 /* FunctionDeclaration */: - case 216 /* ClassDeclaration */: + case 216 /* FunctionDeclaration */: + case 217 /* ClassDeclaration */: return node.flags & 512 /* Default */ ? "default" : undefined; } } @@ -13065,7 +13222,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 232 /* ExportSpecifier */ || (node.kind === 223 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 233 /* ExportSpecifier */ || (node.kind === 224 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -13084,7 +13241,11 @@ var ts; // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & 131072 /* ExportContext */) { + // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge + // 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 & 131072 /* ExportContext */)) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -13148,10 +13309,12 @@ var ts; var flags = node.flags; // reset all reachability check related flags on node (for incremental scenarios) flags &= ~1572864 /* ReachabilityCheckFlags */; - if (kind === 217 /* InterfaceDeclaration */) { + // reset all emit helper flags on node (for incremental scenarios) + flags &= ~62914560 /* EmitHelperFlags */; + if (kind === 218 /* InterfaceDeclaration */) { seenThisKeyword = false; } - var saveState = kind === 250 /* SourceFile */ || kind === 221 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + var saveState = kind === 251 /* SourceFile */ || kind === 222 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -13169,9 +13332,23 @@ var ts; flags |= 1048576 /* HasExplicitReturn */; } } - if (kind === 217 /* InterfaceDeclaration */) { + if (kind === 218 /* InterfaceDeclaration */) { flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; } + if (kind === 251 /* SourceFile */) { + if (hasClassExtends) { + flags |= 4194304 /* HasClassExtends */; + } + if (hasDecorators) { + flags |= 8388608 /* HasDecorators */; + } + if (hasParameterDecorators) { + flags |= 16777216 /* HasParamDecorators */; + } + if (hasAsyncFunctions) { + flags |= 33554432 /* HasAsyncFunctions */; + } + } node.flags = flags; if (saveState) { hasExplicitReturn = savedHasExplicitReturn; @@ -13194,40 +13371,40 @@ var ts; return; } switch (node.kind) { - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: bindWhileStatement(node); break; - case 199 /* DoStatement */: + case 200 /* DoStatement */: bindDoStatement(node); break; - case 201 /* ForStatement */: + case 202 /* ForStatement */: bindForStatement(node); break; - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 198 /* IfStatement */: + case 199 /* IfStatement */: bindIfStatement(node); break; - case 206 /* ReturnStatement */: - case 210 /* ThrowStatement */: + case 207 /* ReturnStatement */: + case 211 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 211 /* TryStatement */: + case 212 /* TryStatement */: bindTryStatement(node); break; - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: bindSwitchStatement(node); break; - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: bindCaseBlock(node); break; - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: bindLabeledStatement(node); break; default: @@ -13302,7 +13479,7 @@ var ts; function bindReturnOrThrow(n) { // bind expression (don't affect reachability) bind(n.expression); - if (n.kind === 206 /* ReturnStatement */) { + if (n.kind === 207 /* ReturnStatement */) { hasExplicitReturn = true; } currentReachabilityState = 4 /* Unreachable */; @@ -13311,7 +13488,7 @@ var ts; // call bind on label (don't affect reachability) bind(n.label); // for continue case touch label so it will be marked a used - var isValidJump = jumpToLabel(n.label, n.kind === 205 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + var isValidJump = jumpToLabel(n.label, n.kind === 206 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); if (isValidJump) { currentReachabilityState = 4 /* Unreachable */; } @@ -13337,7 +13514,7 @@ var ts; // bind expression (don't affect reachability) bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 244 /* DefaultClause */; }); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245 /* DefaultClause */; }); // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); @@ -13364,37 +13541,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 167 /* ObjectLiteralExpression */: + case 189 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 156 /* TypeLiteral */: + case 168 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 215 /* FunctionDeclaration */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 220 /* ModuleDeclaration */: - case 250 /* SourceFile */: - case 218 /* TypeAliasDeclaration */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 221 /* ModuleDeclaration */: + case 251 /* SourceFile */: + case 219 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 246 /* CatchClause */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 222 /* CaseBlock */: + case 247 /* CatchClause */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 223 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 194 /* Block */: + case 195 /* 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. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -13431,38 +13608,38 @@ 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 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 217 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155 /* TypeLiteral */: - case 167 /* ObjectLiteralExpression */: - case 217 /* InterfaceDeclaration */: + case 156 /* TypeLiteral */: + case 168 /* ObjectLiteralExpression */: + case 218 /* InterfaceDeclaration */: // 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 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 218 /* TypeAliasDeclaration */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 219 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -13483,11 +13660,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 250 /* SourceFile */ ? node : node.body; - if (body.kind === 250 /* SourceFile */ || body.kind === 221 /* ModuleBlock */) { + var body = node.kind === 251 /* SourceFile */ ? node : node.body; + if (body.kind === 251 /* SourceFile */ || body.kind === 222 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 230 /* ExportDeclaration */ || stat.kind === 229 /* ExportAssignment */) { + if (stat.kind === 231 /* ExportDeclaration */ || stat.kind === 230 /* ExportAssignment */) { return true; } } @@ -13506,7 +13683,10 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 9 /* StringLiteral */) { + if (ts.isAmbientModule(node)) { + if (node.flags & 2 /* Export */) { + errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); + } declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -13571,7 +13751,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 === 247 /* PropertyAssignment */ || prop.kind === 248 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ + var currentKind = prop.kind === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */ || prop.kind === 144 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -13593,10 +13773,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -13756,17 +13936,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 250 /* SourceFile */: - case 221 /* ModuleBlock */: + case 251 /* SourceFile */: + case 222 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -13796,7 +13976,7 @@ var ts; /* Strict mode checks */ case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -13820,100 +14000,97 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return checkStrictModeCatchClause(node); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return checkStrictModeWithStatement(node); - case 161 /* ThisType */: + case 162 /* ThisType */: seenThisKeyword = true; return; - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return checkTypePredicate(node); - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 138 /* Parameter */: + case 139 /* Parameter */: return bindParameter(node); - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 247 /* PropertyAssignment */: - case 248 /* ShorthandPropertyAssignment */: + case 248 /* PropertyAssignment */: + case 249 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* 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) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 215 /* FunctionDeclaration */: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 144 /* Constructor */: + case 216 /* FunctionDeclaration */: + return bindFunctionDeclaration(node); + case 145 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 145 /* GetAccessor */: + case 146 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 146 /* SetAccessor */: + case 147 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 170 /* CallExpression */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + return bindFunctionExpression(node); + case 171 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 217 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 223 /* ImportEqualsDeclaration */: - case 226 /* NamespaceImport */: - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 227 /* NamespaceImport */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 225 /* ImportClause */: + case 226 /* ImportClause */: return bindImportClause(node); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return bindExportDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return bindExportAssignment(node); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -13922,7 +14099,7 @@ var ts; if (parameterName && parameterName.kind === 69 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 161 /* ThisType */) { + if (parameterName && parameterName.kind === 162 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -13937,7 +14114,7 @@ var ts; bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 229 /* ExportAssignment */ ? node.expression : node.right; + var boundExpression = node.kind === 230 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); @@ -13985,7 +14162,7 @@ var ts; } function bindThisPropertyAssignment(node) { // Declare a 'member' in case it turns out the container was an ES5 class - if (container.kind === 175 /* FunctionExpression */ || container.kind === 215 /* FunctionDeclaration */) { + if (container.kind === 176 /* FunctionExpression */ || container.kind === 216 /* FunctionDeclaration */) { container.symbol.members = container.symbol.members || {}; declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -14014,7 +14191,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 216 /* ClassDeclaration */) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { + hasClassExtends = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } + if (node.kind === 217 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -14076,6 +14261,12 @@ var ts; } } function bindParameter(node) { + if (!ts.isDeclarationFile(file) && + !ts.isInAmbientContext(node) && + ts.nodeIsDecorated(node)) { + hasDecorators = true; + hasParameterDecorators = true; + } if (inStrictMode) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) @@ -14094,7 +14285,34 @@ var ts; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } } + function bindFunctionDeclaration(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); + } + function bindFunctionExpression(node) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { + if (ts.isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + if (ts.nodeIsDecorated(node)) { + hasDecorators = true; + } + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -14159,13 +14377,13 @@ var ts; case 4 /* Unreachable */: var reportError = // report error on all statements except empty ones - (ts.isStatement(node) && node.kind !== 196 /* EmptyStatement */) || + (ts.isStatement(node) && node.kind !== 197 /* EmptyStatement */) || // report error on class declarations - node.kind === 216 /* ClassDeclaration */ || + node.kind === 217 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 220 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 221 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 219 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 220 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8 /* ReportedUnreachable */; // unreachable code is reported if @@ -14179,7 +14397,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 !== 195 /* VariableStatement */ || + (node.kind !== 196 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -14264,6 +14482,7 @@ var ts; getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, // The language service will always care about the narrowed type of a symbol, because that is @@ -14280,6 +14499,7 @@ var ts; getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, @@ -14355,11 +14575,6 @@ var ts; var unionTypes = {}; var intersectionTypes = {}; var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -14504,7 +14719,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 220 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 220 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 221 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 221 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -14559,6 +14774,30 @@ var ts; } } } + function mergeModuleAugmentation(moduleName) { + var moduleAugmentation = moduleName.parent; + if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { + // this is a combined symbol for multiple augmentations within the same file. + // its symbol already has accumulated information for all declarations + // so we need to add it just once - do the work only for first declaration + ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); + return; + } + if (ts.isGlobalScopeAugmentation(moduleAugmentation)) { + mergeSymbolTable(globals, moduleAugmentation.symbol.exports); + } + else { + // find a module that about to be augmented + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); + if (!mainModule) { + return; + } + // if module symbol has already been merged - it is safe to use it. + // otherwise clone it + mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + } function addToSymbolTable(target, source, message) { for (var id in source) { if (ts.hasProperty(source, id)) { @@ -14585,18 +14824,8 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } - function getSourceFile(node) { - return ts.getAncestor(node, 250 /* SourceFile */); - } function isGlobalSourceFile(node) { - return node.kind === 250 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); - } - /** Is this type one of the apparent types created from the primitive types. */ - function isPrimitiveApparentType(type) { - return type === globalStringType || - type === globalNumberType || - type === globalBooleanType || - type === globalESSymbolType; + return node.kind === 251 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -14645,7 +14874,7 @@ var ts; if (declaration.pos <= usage.pos) { // declaration is before usage // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 213 /* VariableDeclaration */ || + return declaration.kind !== 214 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -14653,14 +14882,14 @@ var ts; return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 195 /* VariableStatement */ || - declaration.parent.parent.kind === 201 /* ForStatement */) { + if (declaration.parent.parent.kind === 196 /* VariableStatement */ || + declaration.parent.parent.kind === 202 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 203 /* ForOfStatement */ || - declaration.parent.parent.kind === 202 /* ForInStatement */) { + else if (declaration.parent.parent.kind === 204 /* ForOfStatement */ || + declaration.parent.parent.kind === 203 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); @@ -14677,7 +14906,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 /* PropertyDeclaration */ && + current.parent.kind === 142 /* PropertyDeclaration */ && (current.parent.flags & 64 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -14710,8 +14939,8 @@ var ts; if (meaning & result.flags & 793056 /* Type */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 138 /* Parameter */ || - lastLocation.kind === 137 /* TypeParameter */ + lastLocation.kind === 139 /* Parameter */ || + lastLocation.kind === 138 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -14720,9 +14949,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 === 138 /* Parameter */ || + lastLocation.kind === 139 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 138 /* Parameter */); + result.valueDeclaration.kind === 139 /* Parameter */); } } if (useResult) { @@ -14734,13 +14963,12 @@ var ts; } } switch (location.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 250 /* SourceFile */ || - (location.kind === 220 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + if (location.kind === 251 /* 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"]) { @@ -14763,7 +14991,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 232 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 233 /* ExportSpecifier */)) { break; } } @@ -14771,13 +14999,13 @@ var ts; break loop; } break; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* 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 @@ -14794,9 +15022,9 @@ var ts; } } break; - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 64 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -14807,7 +15035,7 @@ var ts; } break loop; } - if (location.kind === 188 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 189 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -14823,9 +15051,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 217 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 218 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -14833,19 +15061,19 @@ var ts; } } break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 175 /* FunctionExpression */: + case 176 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -14858,7 +15086,7 @@ var ts; } } break; - case 139 /* Decorator */: + case 140 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -14867,7 +15095,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 === 138 /* Parameter */) { + if (location.parent && location.parent.kind === 139 /* Parameter */) { location = location.parent; } // @@ -14889,7 +15117,9 @@ var ts; } if (!result) { if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } } return undefined; } @@ -14922,12 +15152,44 @@ var ts; } return result; } + function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { + if (!errorLocation || (errorLocation.kind === 69 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + return false; + } + var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); + var location = container; + while (location) { + if (ts.isClassLike(location.parent)) { + var classSymbol = getSymbolOfNode(location.parent); + if (!classSymbol) { + break; + } + // Check to see if a static member exists. + var constructorType = getTypeOfSymbol(classSymbol); + if (getPropertyOfType(constructorType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg), symbolToString(classSymbol)); + return true; + } + // No static member is present. + // Check if we're in an instance method and look for a relevant instance member. + if (location === container && !(location.flags & 64 /* Static */)) { + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + if (getPropertyOfType(instanceType, name)) { + error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return true; + } + } + } + location = location.parent; + } + return false; + } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); // 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 213 /* VariableDeclaration */), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -14948,10 +15210,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 223 /* ImportEqualsDeclaration */) { + if (node.kind === 224 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 224 /* ImportDeclaration */) { + while (node && node.kind !== 225 /* ImportDeclaration */) { node = node.parent; } return node; @@ -14961,7 +15223,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 234 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 235 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -15063,17 +15325,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 225 /* ImportClause */: + case 226 /* ImportClause */: return getTargetOfImportClause(node); - case 226 /* NamespaceImport */: + case 227 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 228 /* ImportSpecifier */: + case 229 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 232 /* ExportSpecifier */: + case 233 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -15118,11 +15380,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 229 /* ExportAssignment */) { + if (node.kind === 230 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 232 /* ExportSpecifier */) { + else if (node.kind === 233 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -15135,7 +15397,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 223 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 224 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -15148,13 +15410,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 136 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 223 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 224 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -15174,9 +15436,9 @@ var ts; return undefined; } } - else if (name.kind === 135 /* QualifiedName */ || name.kind === 168 /* PropertyAccessExpression */) { - var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 136 /* QualifiedName */ || name.kind === 169 /* PropertyAccessExpression */) { + var left = name.kind === 136 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 136 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -15196,6 +15458,9 @@ var ts; return symbol.flags & meaning ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { + return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); + } + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } @@ -15210,19 +15475,28 @@ var ts; if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { - return symbol; + // merged symbol is module declaration symbol combined with all augmentations + return getMergedSymbol(symbol); } } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReferenceLiteral.text); var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { - return sourceFile.symbol; + // merged symbol is module declaration symbol combined with all augmentations + return getMergedSymbol(sourceFile.symbol); } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; + if (moduleNotFoundError) { + // report errors only if it was requested + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + } + return undefined; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + if (moduleNotFoundError) { + // report errors only if it was requested + error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + } + return undefined; } // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. @@ -15350,7 +15624,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 === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 145 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -15421,17 +15695,17 @@ var ts; } } switch (location_1.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -15472,7 +15746,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 232 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -15509,7 +15783,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, 232 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -15582,8 +15856,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 220 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 250 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 251 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -15619,12 +15892,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 154 /* TypeQuery */) { + if (entityName.parent.kind === 155 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 168 /* PropertyAccessExpression */ || - entityName.parent.kind === 223 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 136 /* QualifiedName */ || entityName.kind === 169 /* PropertyAccessExpression */ || + entityName.parent.kind === 224 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -15679,15 +15952,20 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 160 /* ParenthesizedType */) { + while (node.kind === 161 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 218 /* TypeAliasDeclaration */) { + if (node.kind === 219 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } + function isTopLevelInExternalModuleAugmentation(node) { + return node && node.parent && + node.parent.kind === 222 /* ModuleBlock */ && + ts.isExternalModuleAugmentation(node.parent.parent); + } function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -15696,10 +15974,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return "(Anonymous class)"; - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -15954,7 +16232,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 250 /* SourceFile */ || declaration.parent.kind === 221 /* ModuleBlock */; + return declaration.parent.kind === 251 /* SourceFile */ || declaration.parent.kind === 222 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -16215,70 +16493,74 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 165 /* BindingElement */: + case 166 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 213 /* VariableDeclaration */: + case 214 /* 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 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 215 /* FunctionDeclaration */: - case 219 /* EnumDeclaration */: - case 223 /* ImportEqualsDeclaration */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 216 /* FunctionDeclaration */: + case 220 /* EnumDeclaration */: + case 224 /* ImportEqualsDeclaration */: + // external module augmentation is always visible + if (ts.isExternalModuleAugmentation(node)) { + return true; + } var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && - !(node.kind !== 223 /* ImportEqualsDeclaration */ && parent_4.kind !== 250 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 224 /* ImportEqualsDeclaration */ && parent_4.kind !== 251 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.flags & (16 /* Private */ | 32 /* 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 144 /* Constructor */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: - case 138 /* Parameter */: - case 221 /* ModuleBlock */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: - case 151 /* TypeReference */: - case 156 /* ArrayType */: - case 157 /* TupleType */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - case 160 /* ParenthesizedType */: + case 145 /* Constructor */: + case 149 /* ConstructSignature */: + case 148 /* CallSignature */: + case 150 /* IndexSignature */: + case 139 /* Parameter */: + case 222 /* ModuleBlock */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 156 /* TypeLiteral */: + case 152 /* TypeReference */: + case 157 /* ArrayType */: + case 158 /* TupleType */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: + case 161 /* 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 225 /* ImportClause */: - case 226 /* NamespaceImport */: - case 228 /* ImportSpecifier */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: + case 229 /* ImportSpecifier */: return false; // Type parameters are always visible - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: // Source file is always visible - case 250 /* SourceFile */: + case 251 /* SourceFile */: return true; // Export assignments do not create name bindings outside the module - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -16287,10 +16569,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 229 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 230 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 232 /* ExportSpecifier */) { + else if (node.parent.kind === 233 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -16313,7 +16595,9 @@ var ts; var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); + if (importSymbol) { + buildVisibleNodeList(importSymbol.declarations); + } } }); } @@ -16382,14 +16666,14 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 213 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 214 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 // Every class automatically contains a static property member named 'prototype', // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. // It is an error to explicitly declare a static property member with the name 'prototype'. - var classType = getDeclaredTypeOfSymbol(prototype.parent); + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } // Return the type of the given property in the given type, or undefined if no such property exists @@ -16413,7 +16697,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -16421,7 +16705,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 136 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 137 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { @@ -16441,7 +16725,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 163 /* ObjectBindingPattern */) { + if (pattern.kind === 164 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { @@ -16489,11 +16773,11 @@ var ts; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { - // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 202 /* ForInStatement */) { - return anyType; + // A variable declared in a for..in statement is always of type string + if (declaration.parent.parent.kind === 203 /* ForInStatement */) { + return stringType; } - if (declaration.parent.parent.kind === 203 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 204 /* 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, @@ -16507,11 +16791,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138 /* Parameter */) { + if (declaration.kind === 139 /* 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 === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); + if (func.kind === 147 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -16527,7 +16811,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 248 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 249 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -16583,7 +16867,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 189 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 190 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -16599,7 +16883,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) { - return pattern.kind === 163 /* ObjectBindingPattern */ + return pattern.kind === 164 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -16621,10 +16905,10 @@ 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 === 247 /* PropertyAssignment */) { + if (declaration.kind === 248 /* PropertyAssignment */) { return type; } - if (type.flags & 134217728 /* PredicateType */ && (declaration.kind === 141 /* PropertyDeclaration */ || declaration.kind === 140 /* PropertySignature */)) { + if (type.flags & 134217728 /* PredicateType */ && (declaration.kind === 142 /* PropertyDeclaration */ || declaration.kind === 141 /* PropertySignature */)) { return type; } return getWidenedType(type); @@ -16634,7 +16918,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 139 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -16649,21 +16933,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 246 /* CatchClause */) { + if (declaration.parent.kind === 247 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 229 /* ExportAssignment */) { + if (declaration.kind === 230 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle module.exports = expr - if (declaration.kind === 183 /* BinaryExpression */) { + if (declaration.kind === 184 /* BinaryExpression */) { return links.type = checkExpression(declaration.right); } - if (declaration.kind === 168 /* PropertyAccessExpression */) { + if (declaration.kind === 169 /* PropertyAccessExpression */) { // Declarations only exist for property access expressions for certain // special assignment kinds - if (declaration.parent.kind === 183 /* BinaryExpression */) { + if (declaration.parent.kind === 184 /* BinaryExpression */) { // Handle exports.p = expr or this.p = expr or className.prototype.method = expr return links.type = checkExpressionCached(declaration.parent.right); } @@ -16693,7 +16977,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 145 /* GetAccessor */) { + if (accessor.kind === 146 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -16709,8 +16993,8 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 146 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 147 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -16739,7 +17023,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 146 /* 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)); } } @@ -16839,9 +17123,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 216 /* ClassDeclaration */ || node.kind === 188 /* ClassExpression */ || - node.kind === 215 /* FunctionDeclaration */ || node.kind === 175 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */ || node.kind === 176 /* ArrowFunction */) { + if (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */ || + node.kind === 216 /* FunctionDeclaration */ || node.kind === 176 /* FunctionExpression */ || + node.kind === 144 /* MethodDeclaration */ || node.kind === 177 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -16851,7 +17135,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, 217 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 218 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -16860,8 +17144,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 217 /* InterfaceDeclaration */ || node.kind === 216 /* ClassDeclaration */ || - node.kind === 188 /* ClassExpression */ || node.kind === 218 /* TypeAliasDeclaration */) { + if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 217 /* ClassDeclaration */ || + node.kind === 189 /* ClassExpression */ || node.kind === 219 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -17001,7 +17285,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 218 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -17033,7 +17317,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 217 /* InterfaceDeclaration */) { + if (declaration.kind === 218 /* InterfaceDeclaration */) { if (declaration.flags & 262144 /* ContainsThis */) { return false; } @@ -17089,7 +17373,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 218 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 219 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -17122,7 +17406,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -17178,11 +17462,11 @@ var ts; case 120 /* BooleanKeyword */: case 131 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: return true; - case 156 /* ArrayType */: + case 157 /* ArrayType */: return isIndependentType(node.elementType); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -17195,7 +17479,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 !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 145 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -17216,12 +17500,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -17783,7 +18067,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 144 /* Constructor */ ? + var classType = declaration.kind === 145 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : @@ -17800,7 +18084,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 162 /* StringLiteralType */) { + if (param.type && param.type.kind === 163 /* StringLiteralType */) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -17826,8 +18110,8 @@ var ts; else { // 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 === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); + if (declaration.kind === 146 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 147 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -17845,19 +18129,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: // 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). @@ -17944,7 +18228,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 145 /* Constructor */ || signature.declaration.kind === 149 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -17981,7 +18265,7 @@ var ts; : undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 138 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -18014,7 +18298,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138 /* TypeParameter */).parent); } function getTypeListId(types) { if (types) { @@ -18113,7 +18397,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 152 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -18145,9 +18429,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: return declaration; } } @@ -18388,9 +18672,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 === 217 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 218 /* InterfaceDeclaration */)) { if (!(container.flags & 64 /* Static */) && - (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { + (container.kind !== 145 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -18434,36 +18718,36 @@ var ts; return esSymbolType; case 103 /* VoidKeyword */: return voidType; - case 161 /* ThisType */: + case 162 /* ThisType */: return getTypeFromThisTypeNode(node); - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: return getTypeFromStringLiteralTypeNode(node); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return getTypeFromTypeReference(node); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return getTypeFromPredicateTypeNode(node); - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 157 /* TupleType */: + case 158 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 158 /* UnionType */: + case 159 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 159 /* IntersectionType */: + case 160 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 156 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 69 /* Identifier */: - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -18654,27 +18938,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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 247 /* PropertyAssignment */: + case 248 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -18703,6 +18987,9 @@ var ts; function compareTypesIdentical(source, target) { return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } + function compareTypesAssignable(source, target) { + return checkTypeRelatedTo(source, target, assignableRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } @@ -18715,47 +19002,60 @@ var ts; function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } + function isSignatureAssignableTo(source, target, ignoreReturnTypes) { + return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function isSignatureAssignableTo(source, target, ignoreReturnTypes) { + function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return true; + return -1 /* True */; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return 0 /* False */; } // Spec 1.0 Section 3.8.3 & 3.8.4: // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); + var result = -1 /* True */; var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); + var sourceParams = source.parameters; + var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var related = isTypeAssignableTo(t, s) || isTypeAssignableTo(s, t); + var s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target); + var related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors); if (!related) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); + } + return 0 /* False */; } + result &= related; } if (!ignoreReturnTypes) { var targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) { - return true; + return result; } var sourceReturnType = getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions if (targetReturnType.flags & 134217728 /* PredicateType */ && targetReturnType.predicate.kind === 1 /* Identifier */) { if (!(sourceReturnType.flags & 134217728 /* PredicateType */)) { - return false; + if (reportErrors) { + errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; } } - return isTypeAssignableTo(sourceReturnType, targetReturnType); + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); } - return true; + return result; } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); @@ -18812,22 +19112,12 @@ var ts; var expandingFlags; var depth = 0; var overflow = false; - var elaborateErrors = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } else if (errorInfo) { - // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), - // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, - // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context - // where errors were being reported. - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } if (containingMessageChain) { errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); } @@ -18835,6 +19125,7 @@ var ts; } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { + ts.Debug.assert(!!errorNode); errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } function reportRelationError(message, source, target) { @@ -18973,14 +19264,14 @@ var ts; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - var apparentType = getApparentType(source); + 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 (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + if (apparentSource.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 16777726 /* Primitive */); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } @@ -19043,6 +19334,7 @@ var ts; // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. + ts.Debug.assert(!!errorNode); errorNode = prop.valueDeclaration; reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } @@ -19140,7 +19432,7 @@ var ts; var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { - if (elaborateErrors && related === 2 /* Failed */) { + if (reportErrors && related === 2 /* Failed */) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. relation[id] = 3 /* FailedAndReported */; @@ -19354,7 +19646,7 @@ var ts; } // don't elaborate the primitive apparent types (like Number) // because the actual primitives will have already been reported. - if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } return 0 /* False */; @@ -19363,72 +19655,10 @@ var ts; return result; } /** - * See signatureAssignableTo, signatureAssignableTo + * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, reportErrors) { - // TODO (drosen): De-duplicate code between related functions. - if (source === target) { - return -1 /* True */; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0 /* False */; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1 /* True */; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, /*reportErrors*/ false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0 /* False */; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) { - return result; - } - var sourceReturnType = getReturnTypeOfSignature(source); - // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions - if (targetReturnType.flags & 134217728 /* PredicateType */ && targetReturnType.predicate.kind === 1 /* Identifier */) { - if (!(sourceReturnType.flags & 134217728 /* PredicateType */)) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0 /* False */; - } - } - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -19844,22 +20074,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 138 /* Parameter */: + case 139 /* 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 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -20196,10 +20426,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 154 /* TypeQuery */: + case 155 /* TypeQuery */: return true; case 69 /* Identifier */: - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: node = node.parent; continue; default: @@ -20241,55 +20471,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: - case 166 /* ArrayLiteralExpression */: - case 167 /* ObjectLiteralExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: - case 174 /* ParenthesizedExpression */: - case 181 /* PrefixUnaryExpression */: - case 177 /* DeleteExpression */: - case 180 /* AwaitExpression */: - case 178 /* TypeOfExpression */: - case 179 /* VoidExpression */: - case 182 /* PostfixUnaryExpression */: - case 186 /* YieldExpression */: - case 184 /* ConditionalExpression */: - case 187 /* SpreadElementExpression */: - case 194 /* Block */: - case 195 /* VariableStatement */: - case 197 /* ExpressionStatement */: - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 206 /* ReturnStatement */: - case 207 /* WithStatement */: - case 208 /* SwitchStatement */: - case 243 /* CaseClause */: - case 244 /* DefaultClause */: - case 209 /* LabeledStatement */: - case 210 /* ThrowStatement */: - case 211 /* TryStatement */: - case 246 /* CatchClause */: - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: - case 240 /* JsxAttribute */: - case 241 /* JsxSpreadAttribute */: - case 237 /* JsxOpeningElement */: - case 242 /* JsxExpression */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: + case 167 /* ArrayLiteralExpression */: + case 168 /* ObjectLiteralExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: + case 175 /* ParenthesizedExpression */: + case 182 /* PrefixUnaryExpression */: + case 178 /* DeleteExpression */: + case 181 /* AwaitExpression */: + case 179 /* TypeOfExpression */: + case 180 /* VoidExpression */: + case 183 /* PostfixUnaryExpression */: + case 187 /* YieldExpression */: + case 185 /* ConditionalExpression */: + case 188 /* SpreadElementExpression */: + case 195 /* Block */: + case 196 /* VariableStatement */: + case 198 /* ExpressionStatement */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 207 /* ReturnStatement */: + case 208 /* WithStatement */: + case 209 /* SwitchStatement */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: + case 210 /* LabeledStatement */: + case 211 /* ThrowStatement */: + case 212 /* TryStatement */: + case 247 /* CatchClause */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: + case 241 /* JsxAttribute */: + case 242 /* JsxSpreadAttribute */: + case 238 /* JsxOpeningElement */: + case 243 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -20301,7 +20531,7 @@ var ts; // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & 3 /* Variable */) { if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - var declaration = ts.getDeclarationOfKind(symbol, 213 /* VariableDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* VariableDeclaration */); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -20309,13 +20539,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 198 /* IfStatement */: - case 184 /* ConditionalExpression */: - case 183 /* BinaryExpression */: + case 199 /* IfStatement */: + case 185 /* ConditionalExpression */: + case 184 /* BinaryExpression */: nodeStack.push({ node: node, child: child }); break; - case 250 /* SourceFile */: - case 220 /* ModuleDeclaration */: + case 251 /* SourceFile */: + case 221 /* ModuleDeclaration */: // Stop at the first containing file or module declaration break loop; } @@ -20327,19 +20557,19 @@ var ts; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 198 /* IfStatement */: + case 199 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node_1.expression) { type = narrowType(type, node_1.expression, /*assumeTrue*/ child === node_1.thenStatement); } break; - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node_1.condition) { type = narrowType(type, node_1.condition, /*assumeTrue*/ child === node_1.whenTrue); } break; - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node_1.right) { if (node_1.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { @@ -20367,7 +20597,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 178 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 179 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; @@ -20383,10 +20613,6 @@ var ts; if (typeInfo && typeInfo.type === undefinedType) { return type; } - // If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive - if (!!(type.flags & 1 /* Any */) && typeInfo && assumeTrue) { - return typeInfo.type; - } var flags; if (typeInfo) { flags = typeInfo.flags; @@ -20397,6 +20623,10 @@ var ts; } // At this point we can bail if it's not a union if (!(type.flags & 16384 /* Union */)) { + // If we're on the true branch and the type is a subtype, we should return the primitive type + if (assumeTrue && typeInfo && isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } // If the active non-union type would be removed from a union by this type guard, return an empty union return filterUnion(type) ? type : emptyUnionType; } @@ -20525,7 +20755,7 @@ var ts; return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); } function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 169 /* ElementAccessExpression */ || expression.kind === 168 /* PropertyAccessExpression */) { + if (expression.kind === 170 /* ElementAccessExpression */ || expression.kind === 169 /* PropertyAccessExpression */) { var accessExpression = expression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 /* Identifier */ && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { @@ -20538,8 +20768,8 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } @@ -20547,11 +20777,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 170 /* CallExpression */: + case 171 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -20566,20 +20796,20 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; - case 169 /* ElementAccessExpression */: - case 168 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 169 /* PropertyAccessExpression */: return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 174 /* ParenthesizedExpression */) { + while (expression.kind === 175 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -20594,7 +20824,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 176 /* ArrowFunction */) { + if (container.kind === 177 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -20625,7 +20855,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 246 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 247 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -20641,12 +20871,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container container = symbol.valueDeclaration; - while (container.kind !== 214 /* VariableDeclarationList */) { + while (container.kind !== 215 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 195 /* VariableStatement */) { + if (container.kind === 196 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -20667,7 +20897,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { + if (container.kind === 142 /* PropertyDeclaration */ || container.kind === 145 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -20681,32 +20911,32 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 176 /* ArrowFunction */) { + if (container.kind === 177 /* 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 /* ES6 */); } switch (container.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* 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 219 /* EnumDeclaration */: + case 220 /* 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 144 /* Constructor */: + case 145 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: if (container.flags & 64 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -20719,7 +20949,7 @@ var ts; } // 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 (ts.isInJavaScriptFile(node) && container.kind === 175 /* FunctionExpression */) { + if (ts.isInJavaScriptFile(node) && container.kind === 176 /* FunctionExpression */) { if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.protoype.y = f @@ -20736,19 +20966,19 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138 /* Parameter */) { + if (n.kind === 139 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 170 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 176 /* ArrowFunction */) { + while (container && container.kind === 177 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } @@ -20762,16 +20992,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 136 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 137 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 136 /* ComputedPropertyName */) { + if (current && current.kind === 137 /* 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 === 167 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -20792,7 +21022,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 167 /* ObjectLiteralExpression */) { + if (container.parent.kind === 168 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -20812,7 +21042,7 @@ var ts; } return unknownType; } - if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 145 /* 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; @@ -20827,7 +21057,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 === 144 /* Constructor */; + return container.kind === 145 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -20835,21 +21065,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 === 167 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */) { if (container.flags & 64 /* Static */) { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */; + return container.kind === 144 /* MethodDeclaration */ || + container.kind === 143 /* MethodSignature */ || + container.kind === 146 /* GetAccessor */ || + container.kind === 147 /* SetAccessor */; } else { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */ || - container.kind === 141 /* PropertyDeclaration */ || - container.kind === 140 /* PropertySignature */ || - container.kind === 144 /* Constructor */; + return container.kind === 144 /* MethodDeclaration */ || + container.kind === 143 /* MethodSignature */ || + container.kind === 146 /* GetAccessor */ || + container.kind === 147 /* SetAccessor */ || + container.kind === 142 /* PropertyDeclaration */ || + container.kind === 141 /* PropertySignature */ || + container.kind === 145 /* Constructor */; } } } @@ -20891,7 +21121,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 138 /* Parameter */) { + if (declaration.kind === 139 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -20924,7 +21154,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 139 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -20935,8 +21165,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 === 144 /* Constructor */ || - functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { + functionDecl.kind === 145 /* Constructor */ || + functionDecl.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -20958,7 +21188,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 172 /* TaggedTemplateExpression */) { + if (template.parent.kind === 173 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -21089,13 +21319,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 240 /* JsxAttribute */) { + if (attribute.kind === 241 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 241 /* JsxSpreadAttribute */) { + else if (attribute.kind === 242 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -21133,40 +21363,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 213 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 139 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 166 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 176 /* ArrowFunction */: - case 206 /* ReturnStatement */: + case 177 /* ArrowFunction */: + case 207 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 247 /* PropertyAssignment */: + case 248 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 192 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 185 /* TemplateExpression */); + case 193 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 186 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return getContextualType(parent); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return getContextualType(parent); - case 240 /* JsxAttribute */: - case 241 /* JsxSpreadAttribute */: + case 241 /* JsxAttribute */: + case 242 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -21183,7 +21413,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 175 /* FunctionExpression */ || node.kind === 176 /* ArrowFunction */; + return node.kind === 176 /* FunctionExpression */ || node.kind === 177 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -21197,7 +21427,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -21260,13 +21490,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 183 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 184 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 247 /* PropertyAssignment */) { + if (parent.kind === 248 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 166 /* ArrayLiteralExpression */) { + if (parent.kind === 167 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -21282,8 +21512,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 165 /* BindingElement */ && !!node.initializer) || - (node.kind === 183 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 166 /* BindingElement */ && !!node.initializer) || + (node.kind === 184 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -21292,7 +21522,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 187 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 188 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -21316,7 +21546,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 187 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 188 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -21331,7 +21561,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 === 164 /* ArrayBindingPattern */ || pattern.kind === 166 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 165 /* ArrayBindingPattern */ || pattern.kind === 167 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -21339,7 +21569,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 189 /* OmittedExpression */) { + if (patternElement.kind !== 190 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -21354,7 +21584,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 137 /* 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, @@ -21411,24 +21641,24 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 163 /* ObjectBindingPattern */ || contextualType.pattern.kind === 167 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 164 /* ObjectBindingPattern */ || contextualType.pattern.kind === 168 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 247 /* PropertyAssignment */ || - memberDecl.kind === 248 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 248 /* PropertyAssignment */ || + memberDecl.kind === 249 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 247 /* PropertyAssignment */) { + if (memberDecl.kind === 248 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 143 /* MethodDeclaration */) { + else if (memberDecl.kind === 144 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 248 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 249 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -21436,8 +21666,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 === 247 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 248 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 248 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 249 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -21471,7 +21701,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 146 /* GetAccessor */ || memberDecl.kind === 147 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -21538,13 +21768,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: checkJsxExpression(child); break; - case 235 /* JsxElement */: + case 236 /* JsxElement */: checkJsxElement(child); break; - case 236 /* JsxSelfClosingElement */: + case 237 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -21562,7 +21792,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135 /* QualifiedName */) { + if (tagName.kind === 136 /* QualifiedName */) { return false; } else { @@ -21672,6 +21902,7 @@ var ts; if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } + return unknownSymbol; } } function lookupClassTag(node) { @@ -21771,21 +22002,25 @@ var ts; if (links.jsxFlags & 4 /* ValueElement */) { // Get the element instance type (the result of newing or invoking this tag) var elemInstanceType = getJsxElementInstanceType(node); - // Is this is a stateless function component? See if its single signature is - // assignable to the JSX Element Type - var callSignature = getSingleCallSignature(getTypeOfSymbol(sym)); - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType) && (paramType.flags & 80896 /* ObjectType */)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); + var elemClassType = getJsxGlobalElementClassType(); + if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { + // Is this is a stateless function component? See if its single signature's return type is + // assignable to the JSX Element Type + var elemType = getTypeOfSymbol(sym); + var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); + var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return links.resolvedJsxType = paramType; } - return paramType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } @@ -21902,11 +22137,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 === 240 /* JsxAttribute */) { + if (node.attributes[i].kind === 241 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 241 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 242 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -21936,7 +22171,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 : 141 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 142 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; @@ -21953,7 +22188,7 @@ var ts; var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (left.kind === 95 /* SuperKeyword */) { - var errorNode = node.kind === 168 /* PropertyAccessExpression */ ? + var errorNode = node.kind === 169 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -21963,7 +22198,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 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 144 /* 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); @@ -22050,7 +22285,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 168 /* PropertyAccessExpression */ + var left = node.kind === 169 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -22062,11 +22297,58 @@ var ts; } return true; } + /** + * Return the symbol of the for-in variable declared or referenced by the given for-in statement. + */ + function getForInVariableSymbol(node) { + var initializer = node.initializer; + if (initializer.kind === 215 /* VariableDeclarationList */) { + var variable = initializer.declarations[0]; + if (variable && !ts.isBindingPattern(variable.name)) { + return getSymbolOfNode(variable); + } + } + else if (initializer.kind === 69 /* Identifier */) { + return getResolvedSymbol(initializer); + } + return undefined; + } + /** + * Return true if the given type is considered to have numeric property names. + */ + function hasNumericPropertyNames(type) { + return getIndexTypeOfType(type, 1 /* Number */) && !getIndexTypeOfType(type, 0 /* String */); + } + /** + * Return true if given node is an expression consisting of an identifier (possibly parenthesized) + * that references a for-in variable for an object with numeric property names. + */ + function isForInVariableForNumericPropertyNames(expr) { + var e = skipParenthesizedNodes(expr); + if (e.kind === 69 /* Identifier */) { + var symbol = getResolvedSymbol(e); + if (symbol.flags & 3 /* Variable */) { + var child = expr; + var node = expr.parent; + while (node) { + if (node.kind === 203 /* ForInStatement */ && + child === node.statement && + getForInVariableSymbol(node) === symbol && + hasNumericPropertyNames(checkExpression(node.expression))) { + return true; + } + child = node; + node = node.parent; + } + } + } + return false; + } function checkIndexedAccess(node) { // Grammar checking if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 171 /* NewExpression */ && node.parent.expression === node) { + var sourceFile = ts.getSourceFileOfNode(node); + if (node.parent.kind === 172 /* 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); @@ -22115,7 +22397,7 @@ var ts; // Check for compatible indexer types. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); if (numberIndexType) { return numberIndexType; @@ -22128,7 +22410,9 @@ var ts; } // Fall back to any. if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + 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; } @@ -22147,7 +22431,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 169 /* ElementAccessExpression */ || indexArgumentExpression.kind === 168 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 170 /* ElementAccessExpression */ || indexArgumentExpression.kind === 169 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -22202,10 +22486,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 139 /* Decorator */) { + else if (node.kind !== 140 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -22271,7 +22555,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 187 /* SpreadElementExpression */) { + if (arg && arg.kind === 188 /* SpreadElementExpression */) { return i; } } @@ -22283,13 +22567,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 === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* 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 adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 185 /* TemplateExpression */) { + if (tagExpression.template.kind === 186 /* 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; @@ -22306,7 +22590,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 139 /* Decorator */) { + else if (node.kind === 140 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -22315,7 +22599,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 === 171 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 172 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -22394,7 +22678,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 !== 189 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 190 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -22454,7 +22738,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 !== 189 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 190 /* 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, arg); @@ -22486,16 +22770,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 172 /* TaggedTemplateExpression */) { + if (node.kind === 173 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 185 /* TemplateExpression */) { + if (template.kind === 186 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 139 /* Decorator */) { + else if (node.kind === 140 /* 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. @@ -22520,19 +22804,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139 /* Decorator */) { + if (node.kind === 140 /* Decorator */) { switch (node.parent.kind) { - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* 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. @@ -22542,7 +22826,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 138 /* Parameter */: + case 139 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -22566,25 +22850,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* 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 === 138 /* Parameter */) { + if (node.kind === 139 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 144 /* Constructor */) { + if (node.kind === 145 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 142 /* PropertyDeclaration */ || + node.kind === 144 /* MethodDeclaration */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* 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 @@ -22611,21 +22895,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 138 /* Parameter */) { + if (node.kind === 139 /* Parameter */) { node = node.parent; - if (node.kind === 144 /* Constructor */) { + if (node.kind === 145 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 142 /* PropertyDeclaration */ || + node.kind === 144 /* MethodDeclaration */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* 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 @@ -22636,7 +22920,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralTypeForText(element.name.text); - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; @@ -22662,21 +22946,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 paramter decorator - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 138 /* Parameter */) { + if (node.kind === 139 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 141 /* PropertyDeclaration */) { + if (node.kind === 142 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 144 /* MethodDeclaration */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -22708,10 +22992,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 === 139 /* Decorator */) { + if (node.kind === 140 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 172 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -22723,8 +23007,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 === 139 /* Decorator */ || - (argIndex === 0 && node.kind === 172 /* TaggedTemplateExpression */)) { + if (node.kind === 140 /* Decorator */ || + (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -22733,11 +23017,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139 /* Decorator */) { + if (node.kind === 140 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 172 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -22746,8 +23030,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 172 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 139 /* Decorator */; + var isTaggedTemplate = node.kind === 173 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 140 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -23093,16 +23377,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138 /* Parameter */: + case 139 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -23139,16 +23423,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 170 /* CallExpression */) { + if (node.kind === 171 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 171 /* NewExpression */) { + else if (node.kind === 172 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 172 /* TaggedTemplateExpression */) { + else if (node.kind === 173 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 139 /* Decorator */) { + else if (node.kind === 140 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -23176,12 +23460,12 @@ var ts; if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 171 /* NewExpression */) { + if (node.kind === 172 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 144 /* Constructor */ && - declaration.kind !== 148 /* ConstructSignature */ && - declaration.kind !== 153 /* ConstructorType */) { + declaration.kind !== 145 /* Constructor */ && + declaration.kind !== 149 /* ConstructSignature */ && + declaration.kind !== 154 /* ConstructorType */) { // 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 // in a JS file @@ -23242,7 +23526,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189 /* OmittedExpression */) { + if (element.kind !== 190 /* OmittedExpression */) { if (element.name.kind === 69 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -23307,7 +23591,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 194 /* Block */) { + if (func.body.kind !== 195 /* 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 @@ -23437,7 +23721,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 !== 194 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { return; } var hasExplicitReturn = func.flags & 1048576 /* HasExplicitReturn */; @@ -23463,20 +23747,16 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 175 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 176 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); @@ -23510,18 +23790,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 144 /* MethodDeclaration */ && node.kind !== 143 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { // return is not necessary in the body of generators @@ -23536,7 +23813,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 194 /* Block */) { + if (node.body.kind === 195 /* Block */) { checkSourceElement(node.body); } else { @@ -23588,17 +23865,17 @@ var ts; // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 168 /* PropertyAccessExpression */: { + case 169 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: // old compiler doesn't check indexed access return true; - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -23607,11 +23884,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: { + case 169 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; } - case 169 /* ElementAccessExpression */: { + case 170 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9 /* StringLiteral */) { @@ -23621,7 +23898,7 @@ var ts; } return false; } - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -23767,9 +24044,9 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 247 /* PropertyAssignment */ || p.kind === 248 /* ShorthandPropertyAssignment */) { + if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { var name_13 = p.name; - if (name_13.kind === 136 /* ComputedPropertyName */) { + if (name_13.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(name_13); } if (isComputedNonLiteralName(name_13)) { @@ -23782,7 +24059,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - if (p.kind === 248 /* ShorthandPropertyAssignment */) { + if (p.kind === 249 /* ShorthandPropertyAssignment */) { checkDestructuringAssignment(p, type); } else { @@ -23808,8 +24085,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189 /* OmittedExpression */) { - if (e.kind !== 187 /* SpreadElementExpression */) { + if (e.kind !== 190 /* OmittedExpression */) { + if (e.kind !== 188 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -23834,7 +24111,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 183 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 184 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -23848,7 +24125,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 248 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 249 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -23858,14 +24135,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 183 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 167 /* ObjectLiteralExpression */) { + if (target.kind === 168 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 166 /* ArrayLiteralExpression */) { + if (target.kind === 167 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -23882,7 +24159,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 167 /* ObjectLiteralExpression */ || left.kind === 166 /* ArrayLiteralExpression */)) { + if (operator === 56 /* EqualsToken */ && (left.kind === 168 /* ObjectLiteralExpression */ || left.kind === 167 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -24151,7 +24428,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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -24162,7 +24439,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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -24192,7 +24469,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 135 /* QualifiedName */) { + if (node.kind === 136 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -24204,9 +24481,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 169 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 136 /* 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); } @@ -24233,7 +24510,7 @@ var ts; return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: return checkStringLiteralExpression(node); @@ -24241,58 +24518,58 @@ var ts; return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return checkCallExpression(node); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return checkClassExpression(node); - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 178 /* TypeOfExpression */: + case 179 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 173 /* TypeAssertionExpression */: - case 191 /* AsExpression */: + case 174 /* TypeAssertionExpression */: + case 192 /* AsExpression */: return checkAssertion(node); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return checkDeleteExpression(node); - case 179 /* VoidExpression */: + case 180 /* VoidExpression */: return checkVoidExpression(node); - case 180 /* AwaitExpression */: + case 181 /* AwaitExpression */: return checkAwaitExpression(node); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 187 /* SpreadElementExpression */: + case 188 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 189 /* OmittedExpression */: + case 190 /* OmittedExpression */: return undefinedType; - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return checkYieldExpression(node); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return checkJsxExpression(node); - case 235 /* JsxElement */: + case 236 /* JsxElement */: return checkJsxElement(node); - case 236 /* JsxSelfClosingElement */: + case 237 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 237 /* JsxOpeningElement */: + case 238 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -24320,7 +24597,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 56 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 145 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -24337,9 +24614,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 143 /* MethodDeclaration */ || - node.kind === 215 /* FunctionDeclaration */ || - node.kind === 175 /* FunctionExpression */; + return node.kind === 144 /* MethodDeclaration */ || + node.kind === 216 /* FunctionDeclaration */ || + node.kind === 176 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -24353,105 +24630,98 @@ var ts; } return -1; } - function isInLegalParameterTypePredicatePosition(node) { - switch (node.parent.kind) { - case 176 /* ArrowFunction */: - case 147 /* CallSignature */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 152 /* FunctionType */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return node === node.parent.type; + function checkTypePredicate(node) { + var parent = getTypePredicateParent(node); + if (!parent) { + return; + } + var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); + if (!returnType || !(returnType.flags & 134217728 /* PredicateType */)) { + return; + } + var parameterName = node.parameterName; + if (parameterName.kind === 162 /* ThisType */) { + getTypeFromThisTypeNode(parameterName); + } + else { + var typePredicate = returnType.predicate; + if (typePredicate.parameterIndex >= 0) { + if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type); + } + } + else if (parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { + var name_14 = _a[_i].name; + if ((name_14.kind === 164 /* ObjectBindingPattern */ || + name_14.kind === 165 /* ArrayBindingPattern */) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + hasReportedError = true; + break; + } + } + if (!hasReportedError) { + error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } } - return false; } - function isInLegalThisTypePredicatePosition(node) { - if (isInLegalParameterTypePredicatePosition(node)) { - return true; - } + function getTypePredicateParent(node) { switch (node.parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 145 /* GetAccessor */: - return node === node.parent.type; + case 177 /* ArrowFunction */: + case 148 /* CallSignature */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 153 /* FunctionType */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + var parent_6 = node.parent; + if (node === parent_6.type) { + return parent_6; + } + } + } + function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var name_15 = _a[_i].name; + if (name_15.kind === 69 /* Identifier */ && + name_15.text === predicateVariableName) { + error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); + return true; + } + else if (name_15.kind === 165 /* ArrayBindingPattern */ || + name_15.kind === 164 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + return true; + } + } } - return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 149 /* IndexSignature */) { + if (node.kind === 150 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 152 /* FunctionType */ || node.kind === 215 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || - node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || - node.kind === 148 /* ConstructSignature */) { + else if (node.kind === 153 /* FunctionType */ || node.kind === 216 /* FunctionDeclaration */ || node.kind === 154 /* ConstructorType */ || + node.kind === 148 /* CallSignature */ || node.kind === 145 /* Constructor */ || + node.kind === 149 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150 /* TypePredicate */) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - if (!returnType || !(returnType.flags & 134217728 /* PredicateType */)) { - return; - } - var typePredicate = returnType.predicate; - var typePredicateNode = node.type; - checkSourceElement(typePredicateNode); - if (ts.isIdentifierTypePredicate(typePredicate)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 163 /* ObjectBindingPattern */ || - param.name.kind === 164 /* ArrayBindingPattern */) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 /* Identifier */ && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 164 /* ArrayBindingPattern */ || - element.name.kind === 163 /* ObjectBindingPattern */) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - } - else { - checkSourceElement(node.type); - } - } + checkSourceElement(node.type); if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 147 /* CallSignature */: + case 148 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -24479,7 +24749,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 217 /* InterfaceDeclaration */) { + if (node.kind === 218 /* 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 @@ -24556,7 +24826,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 170 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + return n.kind === 171 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -24577,12 +24847,12 @@ var ts; if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 175 /* FunctionExpression */ && n.kind !== 215 /* FunctionDeclaration */) { + else if (n.kind !== 176 /* FunctionExpression */ && n.kind !== 216 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 141 /* PropertyDeclaration */ && + return n.kind === 142 /* PropertyDeclaration */ && !(n.flags & 64 /* Static */) && !!n.initializer; } @@ -24612,7 +24882,7 @@ var ts; var superCallStatement; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 197 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 198 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -24640,7 +24910,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 145 /* GetAccessor */) { + if (node.kind === 146 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { if (node.flags & 1048576 /* HasExplicitReturn */) { if (compilerOptions.noImplicitReturns) { @@ -24655,13 +24925,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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* 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 === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; + var otherKind = node.kind === 146 /* GetAccessor */ ? 147 /* SetAccessor */ : 146 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { @@ -24680,7 +24950,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 167 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 168 /* ObjectLiteralExpression */) { checkSourceElement(node.body); } else { @@ -24771,9 +25041,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 217 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 218 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 148 /* CallSignature */ || signatureDeclarationNode.kind === 149 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 148 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -24793,9 +25063,9 @@ var ts; var flags = ts.getCombinedNodeFlags(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 !== 217 /* InterfaceDeclaration */ && - n.parent.kind !== 216 /* ClassDeclaration */ && - n.parent.kind !== 188 /* ClassExpression */ && + if (n.parent.kind !== 218 /* InterfaceDeclaration */ && + n.parent.kind !== 217 /* ClassDeclaration */ && + n.parent.kind !== 189 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 4 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -24883,7 +25153,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 === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && + var reportError = (node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && (node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -24925,7 +25195,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 217 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 218 /* InterfaceDeclaration */ || node.parent.kind === 156 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -24936,7 +25206,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 === 215 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { + if (node.kind === 216 /* FunctionDeclaration */ || node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */ || node.kind === 145 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -25076,16 +25346,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 220 /* ModuleDeclaration */: - return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 221 /* ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -25335,22 +25605,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 138 /* Parameter */: + case 139 /* 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 141 /* PropertyDeclaration */: + case 142 /* 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 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -25363,9 +25633,9 @@ var ts; // 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 === 151 /* TypeReference */) { + if (node && node.kind === 152 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* 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 @@ -25412,28 +25682,24 @@ 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 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 139 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } - emitDecorate = true; - if (node.kind === 138 /* Parameter */) { - emitParam = true; - } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { @@ -25448,13 +25714,10 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } // 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 === 136 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 137 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -25470,7 +25733,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.forEach(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(getSourceFile(declaration)) ? + function (declaration) { return declaration.kind === node.kind && !ts.isSourceFileJavaScript(ts.getSourceFileOfNode(declaration)) ? declaration : undefined; }); // Only type check the symbol once if (node === firstDeclaration) { @@ -25505,7 +25768,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 194 /* Block */) { + if (node.kind === 195 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -25525,12 +25788,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 140 /* PropertySignature */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 142 /* MethodSignature */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { + if (node.kind === 142 /* PropertyDeclaration */ || + node.kind === 141 /* PropertySignature */ || + node.kind === 144 /* MethodDeclaration */ || + node.kind === 143 /* MethodSignature */ || + node.kind === 146 /* GetAccessor */ || + node.kind === 147 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -25539,7 +25802,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 139 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -25592,12 +25855,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 220 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 221 /* 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 === 250 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 251 /* 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)); } @@ -25632,7 +25895,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 === 213 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 214 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -25642,24 +25905,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 214 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 195 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 196 /* 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 === 194 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 221 /* ModuleBlock */ || - container.kind === 220 /* ModuleDeclaration */ || - container.kind === 250 /* SourceFile */); + (container.kind === 195 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 222 /* ModuleBlock */ || + container.kind === 221 /* ModuleDeclaration */ || + container.kind === 251 /* 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_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + var name_16 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); } } } @@ -25667,7 +25930,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 !== 138 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 139 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -25678,7 +25941,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 139 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -25704,15 +25967,15 @@ 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 === 136 /* ComputedPropertyName */) { + if (node.name.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 165 /* BindingElement */) { + if (node.kind === 166 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 136 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 137 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } } @@ -25721,13 +25984,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 === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 139 /* 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)) { - if (node.initializer) { + // Don't validate for-in initializer as it is already an error + if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -25737,7 +26001,8 @@ var ts; var type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer - if (node.initializer) { + // Don't validate for-in initializer as it is already an error + if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -25753,10 +26018,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { + if (node.kind !== 142 /* PropertyDeclaration */ && node.kind !== 141 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 213 /* VariableDeclaration */ || node.kind === 165 /* BindingElement */) { + if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -25779,7 +26044,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 === 167 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 168 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -25800,7 +26065,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 196 /* EmptyStatement */) { + if (node.thenStatement.kind === 197 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -25820,12 +26085,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -25845,14 +26110,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 === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* 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 === 166 /* ArrayLiteralExpression */ || varExpr.kind === 167 /* ObjectLiteralExpression */) { + if (varExpr.kind === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* 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. @@ -25881,7 +26146,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 === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* 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); @@ -25895,7 +26160,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 === 166 /* ArrayLiteralExpression */ || varExpr.kind === 167 /* ObjectLiteralExpression */) { + if (varExpr.kind === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -26140,7 +26405,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); + return !!(node.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -26163,10 +26428,10 @@ var ts; // for generators. return; } - if (func.kind === 146 /* SetAccessor */) { + if (func.kind === 147 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 144 /* Constructor */) { + else if (func.kind === 145 /* Constructor */) { if (!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); } @@ -26208,7 +26473,7 @@ var ts; var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258 /* StringLike */); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 244 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 245 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -26220,7 +26485,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 243 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 244 /* 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 assignable to or from the type of the 'switch' expression. @@ -26245,7 +26510,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 209 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 210 /* 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; @@ -26350,7 +26615,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 137 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -26431,7 +26696,6 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; @@ -26532,7 +26796,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 || !(derivedClassDecl.flags & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 188 /* ClassExpression */) { + if (derivedClassDecl.kind === 189 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -26580,7 +26844,7 @@ var ts; } } function isAccessor(kind) { - return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; + return kind === 146 /* GetAccessor */ || kind === 147 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -26650,7 +26914,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 217 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -26760,7 +27024,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -26771,7 +27035,7 @@ var ts; case 50 /* TildeToken */: return ~value_1; } return undefined; - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -26796,11 +27060,11 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return evalConstant(e.expression); case 69 /* Identifier */: - case 169 /* ElementAccessExpression */: - case 168 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 169 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -26813,7 +27077,7 @@ var ts; } else { var expression; - if (e.kind === 169 /* ElementAccessExpression */) { + if (e.kind === 170 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -26831,7 +27095,7 @@ var ts; if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 168 /* PropertyAccessExpression */) { + else if (current.kind === 169 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -26902,7 +27166,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 219 /* EnumDeclaration */) { + if (declaration.kind !== 220 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -26925,8 +27189,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 === 216 /* ClassDeclaration */ || - (declaration.kind === 215 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 217 /* ClassDeclaration */ || + (declaration.kind === 216 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -26949,7 +27213,12 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; + var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); + var inAmbientContext = ts.isInAmbientContext(node); + if (isGlobalAugmentation && !inAmbientContext) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); + } + var isAmbientExternalModule = ts.isAmbientModule(node); var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -26958,7 +27227,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -26969,7 +27238,7 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) + && !inAmbientContext && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { @@ -26982,30 +27251,120 @@ 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, 216 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 217 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; } } - // Checks for ambient external modules. if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + if (ts.isExternalModuleAugmentation(node)) { + // body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module) + // otherwise we'll be swamped in cascading errors. + // We can detect if augmentation was applied using following rules: + // - augmentation for a global scope is always applied + // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); + if (checkBody) { + // body of ambient external module is always a module block + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + checkModuleAugmentationElement(statement, isGlobalAugmentation); + } + } } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + else if (isGlobalSourceFile(node.parent)) { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + else { + if (isGlobalAugmentation) { + error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else { + // Node is not an augmentation and is not located on the script level. + // This means that this is declaration of ambient module that is located in other module or namespace which is prohibited. + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } } } } checkSourceElement(node.body); } + function checkModuleAugmentationElement(node, isGlobalAugmentation) { + switch (node.kind) { + case 196 /* 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 230 /* ExportAssignment */: + case 231 /* ExportDeclaration */: + grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); + break; + case 224 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind !== 9 /* StringLiteral */) { + error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + break; + } + // fallthrough + case 225 /* ImportDeclaration */: + grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); + break; + case 166 /* BindingElement */: + case 214 /* VariableDeclaration */: + var name_17 = node.name; + if (ts.isBindingPattern(name_17)) { + for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + var el = _c[_b]; + // mark individual names in binding pattern + checkModuleAugmentationElement(el, isGlobalAugmentation); + } + break; + } + // fallthrough + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 216 /* FunctionDeclaration */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 219 /* TypeAliasDeclaration */: + var symbol = getSymbolOfNode(node); + if (symbol) { + // module augmentations cannot introduce new names on the top level scope of the module + // this is done it two steps + // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error + // 2. main check - report error if value declaration of the parent symbol is module augmentation) + var reportError = !(symbol.flags & 33554432 /* Merged */); + if (!reportError) { + if (isGlobalAugmentation) { + // global symbol should not have parent since it is not explicitly exported + reportError = symbol.parent !== undefined; + } + else { + // symbol should not originate in augmentation + reportError = ts.isExternalModuleAugmentation(symbol.parent.valueDeclaration); + } + } + if (reportError) { + error(node, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + } + } + break; + } + } function getFirstIdentifier(node) { while (true) { - if (node.kind === 135 /* QualifiedName */) { + if (node.kind === 136 /* QualifiedName */) { node = node.left; } - else if (node.kind === 168 /* PropertyAccessExpression */) { + else if (node.kind === 169 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -27021,20 +27380,24 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 221 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 250 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 230 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 231 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - // TypeScript 1.0 spec (April 2013): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference - // other external modules only through top - level external module names. - // Relative external module names are not permitted. - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; + // we have already reported errors on top level imports\exports in external module augmentations in checkModuleDeclaration + // no need to do this again. + if (!isTopLevelInExternalModuleAugmentation(node)) { + // TypeScript 1.0 spec (April 2013): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference + // other external modules only through top - level external module names. + // Relative external module names are not permitted. + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } } return true; } @@ -27046,7 +27409,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 232 /* ExportSpecifier */ ? + var message = node.kind === 233 /* 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)); @@ -27073,7 +27436,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -27130,8 +27493,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 221 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 250 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -27145,14 +27508,23 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 250 /* SourceFile */ && node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 220 /* ModuleDeclaration */) { + if (node.parent.kind !== 251 /* SourceFile */ && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 221 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); + var exportedName = node.propertyName || node.name; + // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) + var symbol = resolveName(exportedName, exportedName.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); + } + else { + markExportAsReferenced(node); + } } } function checkExportAssignment(node) { @@ -27160,8 +27532,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 === 250 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 220 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { + var container = node.parent.kind === 251 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 221 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -27202,7 +27574,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports["export="]; if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + if (!isTopLevelInExternalModuleAugmentation(declaration)) { + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } } // Checks for export * conflicts var exports = getExportsOfModule(moduleSymbol); @@ -27225,21 +27599,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 215 /* FunctionDeclaration */ || !!declaration.body; - } - } - function checkTypePredicate(node) { - var parameterName = node.parameterName; - if (parameterName.kind === 69 /* Identifier */ && !isInLegalParameterTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - else if (parameterName.kind === 161 /* ThisType */) { - if (!isInLegalThisTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_this_based_type_predicate_is_only_allowed_within_a_class_or_interface_s_members_get_accessors_or_return_type_positions_for_functions_and_methods); - } - else { - getTypeFromThisTypeNode(parameterName); - } + return declaration.kind !== 216 /* FunctionDeclaration */ || !!declaration.body; } } function checkSourceElement(node) { @@ -27251,118 +27611,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: return checkTypeParameter(node); - case 138 /* Parameter */: + case 139 /* Parameter */: return checkParameter(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return checkPropertyDeclaration(node); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: return checkSignatureDeclaration(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return checkMethodDeclaration(node); - case 144 /* Constructor */: + case 145 /* Constructor */: return checkConstructorDeclaration(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return checkAccessorDeclaration(node); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return checkTypeReferenceNode(node); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return checkTypePredicate(node); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return checkTypeQuery(node); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return checkTypeLiteral(node); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return checkArrayType(node); - case 157 /* TupleType */: + case 158 /* TupleType */: return checkTupleType(node); - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return checkSourceElement(node.type); - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return checkBlock(node); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return checkVariableStatement(node); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return checkExpressionStatement(node); - case 198 /* IfStatement */: + case 199 /* IfStatement */: return checkIfStatement(node); - case 199 /* DoStatement */: + case 200 /* DoStatement */: return checkDoStatement(node); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: return checkWhileStatement(node); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return checkForStatement(node); - case 202 /* ForInStatement */: + case 203 /* ForInStatement */: return checkForInStatement(node); - case 203 /* ForOfStatement */: + case 204 /* ForOfStatement */: return checkForOfStatement(node); - case 204 /* ContinueStatement */: - case 205 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 206 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return checkReturnStatement(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return checkWithStatement(node); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return checkSwitchStatement(node); - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return checkLabeledStatement(node); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: return checkThrowStatement(node); - case 211 /* TryStatement */: + case 212 /* TryStatement */: return checkTryStatement(node); - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 165 /* BindingElement */: + case 166 /* BindingElement */: return checkBindingElement(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return checkClassDeclaration(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return checkImportDeclaration(node); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return checkExportDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return checkExportAssignment(node); - case 196 /* EmptyStatement */: + case 197 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 212 /* DebuggerStatement */: + case 213 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 233 /* MissingDeclaration */: + case 234 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -27384,17 +27744,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: checkAccessorDeferred(node); break; - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -27420,10 +27780,6 @@ var ts; } // Grammar checking checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - emitAwaiter = false; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); @@ -27436,21 +27792,6 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) { - links.flags |= 8 /* EmitExtends */; - } - if (emitDecorate) { - links.flags |= 16 /* EmitDecorate */; - } - if (emitParam) { - links.flags |= 32 /* EmitParam */; - } - if (emitAwaiter) { - links.flags |= 64 /* EmitAwaiter */; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { - links.flags |= 128 /* EmitGenerator */; - } links.flags |= 1 /* TypeChecked */; } } @@ -27488,7 +27829,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 207 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 208 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -27511,25 +27852,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 188 /* ClassExpression */: + case 189 /* 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 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* 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. @@ -27538,7 +27879,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 175 /* FunctionExpression */: + case 176 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -27587,37 +27928,37 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 137 /* TypeParameter */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 219 /* EnumDeclaration */: + case 138 /* TypeParameter */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 220 /* 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 === 135 /* QualifiedName */) { + while (node.parent && node.parent.kind === 136 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 151 /* TypeReference */; + return node.parent && node.parent.kind === 152 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 168 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 169 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 190 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 191 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 136 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 223 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 224 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 230 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -27629,11 +27970,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 229 /* ExportAssignment */) { + if (entityName.parent.kind === 230 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 168 /* PropertyAccessExpression */) { + if (entityName.kind !== 169 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -27645,7 +27986,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 === 190 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 191 /* ExpressionWithTypeArguments */) { meaning = 793056 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -27658,9 +27999,9 @@ var ts; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 237 /* JsxOpeningElement */) || - (entityName.parent.kind === 236 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 239 /* JsxClosingElement */)) { + else if ((entityName.parent.kind === 238 /* JsxOpeningElement */) || + (entityName.parent.kind === 237 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 240 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -27674,14 +28015,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 168 /* PropertyAccessExpression */) { + else if (entityName.kind === 169 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 135 /* QualifiedName */) { + else if (entityName.kind === 136 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -27690,16 +28031,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 240 /* JsxAttribute */) { + else if (entityName.parent.kind === 241 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 150 /* TypePredicate */) { + if (entityName.parent.kind === 151 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -27716,12 +28057,12 @@ var ts; } if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 229 /* ExportAssignment */ + return node.parent.kind === 230 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 165 /* BindingElement */ && - node.parent.parent.kind === 163 /* ObjectBindingPattern */ && + else if (node.parent.kind === 166 /* BindingElement */ && + node.parent.parent.kind === 164 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -27732,19 +28073,19 @@ var ts; } switch (node.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97 /* ThisKeyword */: case 95 /* SuperKeyword */: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 161 /* ThisType */: + case 162 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 145 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -27752,14 +28093,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 224 /* ImportDeclaration */ || node.parent.kind === 230 /* ExportDeclaration */) && + ((node.parent.kind === 225 /* ImportDeclaration */ || node.parent.kind === 231 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 169 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -27776,11 +28117,17 @@ 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 === 248 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 107455 /* Value */); + if (location && location.kind === 249 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; } + /** Returns the target of an export specifier without following aliases */ + function getExportSpecifierLocalTargetSymbol(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); + } function getTypeOfNode(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further @@ -27858,9 +28205,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456 /* SyntheticProperty */) { var symbols = []; - var name_15 = symbol.name; + var name_18 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); + var symbol = getPropertyOfType(t, name_18); if (symbol) { symbols.push(symbol); } @@ -27920,11 +28267,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 250 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 251 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 220 /* ModuleDeclaration */ || n.kind === 219 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 221 /* ModuleDeclaration */ || n.kind === 220 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -27939,11 +28286,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 194 /* Block */: - case 222 /* CaseBlock */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 195 /* Block */: + case 223 /* CaseBlock */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: return true; } return false; @@ -27973,22 +28320,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 223 /* ImportEqualsDeclaration */: - case 225 /* ImportClause */: - case 226 /* NamespaceImport */: - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 250 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 251 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -28050,7 +28397,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 249 /* EnumMember */) { + if (node.kind === 250 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -28172,23 +28519,38 @@ var ts; } function getExternalModuleFileFromDeclaration(declaration) { var specifier = ts.getExternalModuleName(declaration); - var moduleSymbol = getSymbolAtLocation(specifier); + var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 250 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 251 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors ts.forEach(host.getSourceFiles(), function (file) { ts.bindSourceFile(file, compilerOptions); }); + var augmentations; // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } + if (file.moduleAugmentations) { + (augmentations || (augmentations = [])).push(file.moduleAugmentations); + } }); + if (augmentations) { + // merge module augmentations. + // this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed + for (var _i = 0, augmentations_1 = augmentations; _i < augmentations_1.length; _i++) { + var list = augmentations_1[_i]; + for (var _a = 0, list_2 = list; _a < list_2.length; _a++) { + var augmentation = list_2[_a]; + mergeModuleAugmentation(augmentation); + } + } + } // Setup global builtins addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedType; @@ -28262,14 +28624,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 143 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 144 /* 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 === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { + else if (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* 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); @@ -28279,38 +28641,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 220 /* ModuleDeclaration */: - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 230 /* ExportDeclaration */: - case 229 /* ExportAssignment */: - case 138 /* Parameter */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 145 /* Constructor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 150 /* IndexSignature */: + case 221 /* ModuleDeclaration */: + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 231 /* ExportDeclaration */: + case 230 /* ExportAssignment */: + case 139 /* Parameter */: break; - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && - node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 250 /* SourceFile */) { + node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 195 /* VariableStatement */: - case 218 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 250 /* SourceFile */) { + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 196 /* VariableStatement */: + case 219 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && - node.parent.kind !== 221 /* ModuleBlock */ && node.parent.kind !== 250 /* SourceFile */) { + node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -28326,7 +28688,7 @@ var ts; var modifier = _a[_i]; switch (modifier.kind) { case 74 /* ConstKeyword */: - if (node.kind !== 219 /* EnumDeclaration */ && node.parent.kind === 216 /* ClassDeclaration */) { + if (node.kind !== 220 /* EnumDeclaration */ && node.parent.kind === 217 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); } break; @@ -28354,7 +28716,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 === 221 /* ModuleBlock */ || node.parent.kind === 250 /* SourceFile */) { + else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 128 /* Abstract */) { @@ -28374,10 +28736,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 === 221 /* ModuleBlock */ || node.parent.kind === 250 /* SourceFile */) { + else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -28399,10 +28761,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 2 /* Export */; @@ -28414,13 +28776,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 221 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 4 /* Ambient */; @@ -28430,11 +28792,11 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 216 /* ClassDeclaration */) { - if (node.kind !== 143 /* MethodDeclaration */) { + if (node.kind !== 217 /* ClassDeclaration */) { + if (node.kind !== 144 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 216 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { + if (!(node.parent.kind === 217 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 64 /* Static */) { @@ -28453,7 +28815,7 @@ var ts; else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 138 /* Parameter */) { + else if (node.kind === 139 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -28461,7 +28823,7 @@ var ts; break; } } - if (node.kind === 144 /* Constructor */) { + if (node.kind === 145 /* Constructor */) { if (flags & 64 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -28479,10 +28841,10 @@ var ts; } return; } - else if ((node.kind === 224 /* ImportDeclaration */ || node.kind === 223 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { + else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 139 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256 /* Async */) { @@ -28494,10 +28856,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 143 /* MethodDeclaration */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -28563,7 +28925,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 176 /* ArrowFunction */) { + if (node.kind === 177 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -28631,7 +28993,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 189 /* OmittedExpression */) { + if (arg.kind === 190 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -28705,19 +29067,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 136 /* ComputedPropertyName */) { + if (node.kind !== 137 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 183 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 184 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* 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 === 215 /* FunctionDeclaration */ || - node.kind === 175 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 216 /* FunctionDeclaration */ || + node.kind === 176 /* FunctionExpression */ || + node.kind === 144 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -28741,21 +29103,21 @@ var ts; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; var _loop_1 = function(prop) { - var name_16 = prop.name; - if (prop.kind === 189 /* OmittedExpression */ || - name_16.kind === 136 /* ComputedPropertyName */) { + var name_19 = prop.name; + if (prop.kind === 190 /* OmittedExpression */ || + name_19.kind === 137 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_16); + checkGrammarComputedPropertyName(name_19); return "continue"; } - if (prop.kind === 248 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 249 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } // Modifiers are never allowed on properties except for 'async' on a method declaration ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 143 /* MethodDeclaration */) { + if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 144 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); @@ -28768,44 +29130,44 @@ 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 === 247 /* PropertyAssignment */ || prop.kind === 248 /* ShorthandPropertyAssignment */) { + if (prop.kind === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_16); + if (name_19.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_19); } currentKind = Property; } - else if (prop.kind === 143 /* MethodDeclaration */) { + else if (prop.kind === 144 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 145 /* GetAccessor */) { + else if (prop.kind === 146 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 146 /* SetAccessor */) { + else if (prop.kind === 147 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = currentKind; } else { - var existingKind = seen[name_16.text]; + var existingKind = seen[name_19.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; + seen[name_19.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; @@ -28820,19 +29182,19 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 241 /* JsxSpreadAttribute */) { + if (attr.kind === 242 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; + var name_20 = jsxAttr.name; + if (!ts.hasProperty(seen, name_20.text)) { + seen[name_20.text] = true; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 242 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 243 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -28841,7 +29203,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 214 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 215 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -28856,20 +29218,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 202 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 203 /* 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 === 202 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 203 /* 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 === 202 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 203 /* 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); @@ -28892,10 +29254,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 146 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 146 /* SetAccessor */) { + else if (kind === 147 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -28930,12 +29292,12 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 167 /* ObjectLiteralExpression */) { + if (node.parent.kind === 168 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (ts.isClassLike(node.parent)) { @@ -28954,10 +29316,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 === 217 /* InterfaceDeclaration */) { + else if (node.parent.kind === 218 /* 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 === 155 /* TypeLiteral */) { + else if (node.parent.kind === 156 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -28968,11 +29330,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 209 /* LabeledStatement */: + case 210 /* 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 === 204 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 205 /* 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); @@ -28980,8 +29342,8 @@ var ts; return false; } break; - case 208 /* SwitchStatement */: - if (node.kind === 205 /* BreakStatement */ && !node.label) { + case 209 /* SwitchStatement */: + if (node.kind === 206 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -28996,13 +29358,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 205 /* BreakStatement */ + var message = node.kind === 206 /* 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 === 205 /* BreakStatement */ + var message = node.kind === 206 /* 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); @@ -29014,7 +29376,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 164 /* ArrayBindingPattern */ || node.name.kind === 163 /* ObjectBindingPattern */) { + if (node.name.kind === 165 /* ArrayBindingPattern */ || node.name.kind === 164 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -29024,7 +29386,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 202 /* ForInStatement */ && node.parent.parent.kind !== 203 /* ForOfStatement */) { + if (node.parent.parent.kind !== 203 /* ForInStatement */ && node.parent.parent.kind !== 204 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -29060,7 +29422,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 189 /* OmittedExpression */) { + if (element.kind !== 190 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -29077,15 +29439,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 198 /* IfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 199 /* IfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: return false; - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -29141,7 +29503,7 @@ var ts; return true; } } - else if (node.parent.kind === 217 /* InterfaceDeclaration */) { + else if (node.parent.kind === 218 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -29149,7 +29511,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 155 /* TypeLiteral */) { + else if (node.parent.kind === 156 /* 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; } @@ -29174,12 +29536,12 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 217 /* InterfaceDeclaration */ || - node.kind === 218 /* TypeAliasDeclaration */ || - node.kind === 224 /* ImportDeclaration */ || - node.kind === 223 /* ImportEqualsDeclaration */ || - node.kind === 230 /* ExportDeclaration */ || - node.kind === 229 /* ExportAssignment */ || + if (node.kind === 218 /* InterfaceDeclaration */ || + node.kind === 219 /* TypeAliasDeclaration */ || + node.kind === 225 /* ImportDeclaration */ || + node.kind === 224 /* ImportEqualsDeclaration */ || + node.kind === 231 /* ExportDeclaration */ || + node.kind === 230 /* ExportAssignment */ || (node.flags & 4 /* Ambient */) || (node.flags & (2 /* Export */ | 512 /* Default */))) { return false; @@ -29189,7 +29551,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 === 195 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 196 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -29215,7 +29577,7 @@ var ts; // to prevent noisyness. 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 === 194 /* Block */ || node.parent.kind === 221 /* ModuleBlock */ || node.parent.kind === 250 /* SourceFile */) { + if (node.parent.kind === 195 /* Block */ || node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -29255,8 +29617,9 @@ var ts; getSourceMapData: function () { return undefined; }, setSourceFile: function (sourceFile) { }, emitStart: function (range) { }, - emitEnd: function (range) { }, + emitEnd: function (range, stopOverridingSpan) { }, emitPos: function (pos) { }, + changeEmitSourcePos: function () { }, getText: function () { return undefined; }, getSourceMappingURL: function () { return undefined; }, initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, @@ -29270,6 +29633,8 @@ var ts; var compilerOptions = host.getCompilerOptions(); var currentSourceFile; var sourceMapDir; // The directory in which sourcemap will be + var stopOverridingSpan = false; + var modifyLastSourcePos = false; // Current source map file and its index in the sources list var sourceMapSourceIndex; // Last recorded and encoded spans @@ -29284,6 +29649,7 @@ var ts; emitPos: emitPos, emitStart: emitStart, emitEnd: emitEnd, + changeEmitSourcePos: changeEmitSourcePos, getText: getText, getSourceMappingURL: getSourceMappingURL, initialize: initialize, @@ -29358,6 +29724,39 @@ var ts; lastEncodedNameIndex = undefined; sourceMapData = undefined; } + function updateLastEncodedAndRecordedSpans() { + if (modifyLastSourcePos) { + // Reset the source pos + modifyLastSourcePos = false; + // Change Last recorded Map with last encoded emit line and character + lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; + lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Pop sourceMapDecodedMappings to remove last entry + sourceMapData.sourceMapDecodedMappings.pop(); + // Change the last encoded source map + lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? + sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : + undefined; + // TODO: Update lastEncodedNameIndex + // Since we dont support this any more, lets not worry about it right now. + // When we start supporting nameIndex, we will get back to this + // Change the encoded source map + var sourceMapMappings = sourceMapData.sourceMapMappings; + var lenthToSet = sourceMapMappings.length - 1; + for (; lenthToSet >= 0; lenthToSet--) { + var currentChar = sourceMapMappings.charAt(lenthToSet); + if (currentChar === ",") { + // Separator for the entry found + break; + } + if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { + // Last line separator found + break; + } + } + sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); + } + } // Encoding for sourcemap span function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { @@ -29388,6 +29787,7 @@ var ts; sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); // 5. Relative namePosition 0 based if (lastRecordedSourceMapSpan.nameIndex >= 0) { + ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } @@ -29421,20 +29821,30 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; + stopOverridingSpan = false; } - else { + else if (!stopOverridingSpan) { // Take the new pos instead since there is no change in emittedLine and column since last location lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } + updateLastEncodedAndRecordedSpans(); + } + function getStartPos(range) { + var rangeHasDecorators = !!range.decorators; + return range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1; } function emitStart(range) { - var rangeHasDecorators = !!range.decorators; - emitPos(range.pos !== -1 ? ts.skipTrivia(currentSourceFile.text, rangeHasDecorators ? range.decorators.end : range.pos) : -1); + emitPos(getStartPos(range)); } - function emitEnd(range) { + function emitEnd(range, stopOverridingEnd) { emitPos(range.end); + stopOverridingSpan = stopOverridingEnd; + } + function changeEmitSourcePos() { + ts.Debug.assert(!modifyLastSourcePos); + modifyLastSourcePos = true; } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -29536,6 +29946,7 @@ var ts; var writeTextOfNode; var writer = createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; + var resultHasExternalModuleIndicator; var currentText; var currentLineMap; var currentIdentifiers; @@ -29577,6 +29988,7 @@ var ts; } }); } + resultHasExternalModuleIndicator = false; if (!isBundledEmit || !ts.isExternalModule(sourceFile)) { noDeclare = false; emitSourceFile(sourceFile); @@ -29596,7 +30008,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 224 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 225 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -29613,6 +30025,13 @@ var ts; allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo); moduleElementDeclarationEmitInfo = []; } + if (!isBundledEmit && ts.isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) { + // if file was external module with augmentations - this fact should be preserved in .d.ts as well. + // in case if we didn't write any external module specifiers in .d.ts we need to emit something + // that will force compiler to think that this file is an external module - 'export {}' is a reasonable choice here. + write("export {};"); + writeLine(); + } }); return { reportedDeclarationError: reportedDeclarationError, @@ -29659,10 +30078,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 213 /* VariableDeclaration */) { + if (declaration.kind === 214 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 227 /* NamedImports */ || declaration.kind === 228 /* ImportSpecifier */ || declaration.kind === 225 /* ImportClause */) { + else if (declaration.kind === 228 /* NamedImports */ || declaration.kind === 229 /* ImportSpecifier */ || declaration.kind === 226 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -29680,7 +30099,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 === 224 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 225 /* 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; @@ -29690,12 +30109,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 220 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 220 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -29803,35 +30222,35 @@ var ts; case 120 /* BooleanKeyword */: case 131 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 161 /* ThisType */: - case 162 /* StringLiteralType */: + case 162 /* ThisType */: + case 163 /* StringLiteralType */: return writeTextOfNode(currentText, type); - case 190 /* ExpressionWithTypeArguments */: + case 191 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 151 /* TypeReference */: + case 152 /* TypeReference */: return emitTypeReference(type); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return emitTypeQuery(type); - case 156 /* ArrayType */: + case 157 /* ArrayType */: return emitArrayType(type); - case 157 /* TupleType */: + case 158 /* TupleType */: return emitTupleType(type); - case 158 /* UnionType */: + case 159 /* UnionType */: return emitUnionType(type); - case 159 /* IntersectionType */: + case 160 /* IntersectionType */: return emitIntersectionType(type); - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: return emitParenType(type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 155 /* TypeLiteral */: + case 156 /* TypeLiteral */: return emitTypeLiteral(type); case 69 /* Identifier */: return emitEntityName(type); - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return emitEntityName(type); - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -29839,8 +30258,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 136 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 136 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -29849,13 +30268,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 223 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 224 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 168 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 169 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -29934,9 +30353,9 @@ var ts; var count = 0; while (true) { count++; - var name_18 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_18)) { - return name_18; + var name_21 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_21)) { + return name_21; } } } @@ -29980,10 +30399,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 223 /* ImportEqualsDeclaration */ || - (node.parent.kind === 250 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 224 /* ImportEqualsDeclaration */ || + (node.parent.kind === 251 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 250 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -29993,7 +30412,7 @@ var ts; }); } else { - if (node.kind === 224 /* ImportDeclaration */) { + if (node.kind === 225 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -30011,23 +30430,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return writeVariableStatement(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return writeClassDeclaration(node); - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -30035,7 +30454,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 === 250 /* SourceFile */) { + if (node.parent.kind === 251 /* SourceFile */) { // If the node is exported if (node.flags & 2 /* Export */) { write("export "); @@ -30043,7 +30462,7 @@ var ts; if (node.flags & 512 /* Default */) { write("default "); } - else if (node.kind !== 217 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 218 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -30092,7 +30511,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 226 /* NamespaceImport */) { + if (namedBindings.kind === 227 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -30120,7 +30539,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -30137,11 +30556,19 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { + // emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations). + // 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 indistingushable 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 !== 221 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 223 /* ImportEqualsDeclaration */) { + if (parent.kind === 224 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } + else if (parent.kind === 221 /* ModuleDeclaration */) { + moduleSpecifier = parent.name; + } else { var node = parent; moduleSpecifier = node.moduleSpecifier; @@ -30192,14 +30619,24 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 65536 /* Namespace */) { - write("namespace "); + if (ts.isGlobalScopeAugmentation(node)) { + write("global "); } else { - write("module "); + if (node.flags & 65536 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } + if (ts.isExternalModuleAugmentation(node)) { + emitExternalModuleSpecifier(node); + } + else { + writeTextOfNode(currentText, node.name); + } } - writeTextOfNode(currentText, node.name); - while (node.body.kind !== 221 /* ModuleBlock */) { + while (node.body.kind !== 222 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -30264,7 +30701,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); + return node.parent.kind === 144 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -30275,15 +30712,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 === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || - node.parent.kind === 142 /* MethodSignature */ || - node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.kind === 147 /* CallSignature */ || - node.parent.kind === 148 /* ConstructSignature */); + if (node.parent.kind === 153 /* FunctionType */ || + node.parent.kind === 154 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 156 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 144 /* MethodDeclaration */ || + node.parent.kind === 143 /* MethodSignature */ || + node.parent.kind === 153 /* FunctionType */ || + node.parent.kind === 154 /* ConstructorType */ || + node.parent.kind === 148 /* CallSignature */ || + node.parent.kind === 149 /* ConstructSignature */); emitType(node.constraint); } else { @@ -30294,31 +30731,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 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147 /* CallSignature */: + case 148 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.parent.flags & 64 /* 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 === 216 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 217 /* 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 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -30352,7 +30789,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 216 /* ClassDeclaration */) { + if (node.parent.parent.kind === 217 /* 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 : @@ -30436,7 +30873,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 !== 213 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 214 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -30446,10 +30883,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentText, node.name); // If optional property emit ? - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { + if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && node.parent.kind === 156 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 16 /* Private */)) { @@ -30458,14 +30895,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 213 /* VariableDeclaration */) { + if (node.kind === 214 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { + else if (node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -30474,7 +30911,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -30506,7 +30943,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 189 /* OmittedExpression */) { + if (element.kind !== 190 /* OmittedExpression */) { elements.push(element); } } @@ -30576,7 +31013,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 === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 146 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -30589,7 +31026,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 145 /* GetAccessor */ + return accessor.kind === 146 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -30598,7 +31035,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 147 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -30648,17 +31085,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 143 /* MethodDeclaration */) { + else if (node.kind === 144 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 144 /* Constructor */) { + else if (node.kind === 145 /* Constructor */) { write("constructor"); } else { @@ -30678,11 +31115,11 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; // Construct signature or constructor type write new Signature - if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { + if (node.kind === 149 /* ConstructSignature */ || node.kind === 154 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 149 /* IndexSignature */) { + if (node.kind === 150 /* IndexSignature */) { write("["); } else { @@ -30690,22 +31127,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149 /* IndexSignature */) { + if (node.kind === 150 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 153 /* FunctionType */ || node.kind === 154 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 156 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 16 /* Private */)) { + else if (node.kind !== 145 /* Constructor */ && !(node.flags & 16 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -30716,26 +31153,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.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 147 /* CallSignature */: + case 148 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.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 149 /* IndexSignature */: + case 150 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.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 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -30743,7 +31180,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 === 216 /* ClassDeclaration */) { + else if (node.parent.kind === 217 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -30757,7 +31194,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -30792,9 +31229,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.parent.kind === 155 /* TypeLiteral */) { + if (node.parent.kind === 153 /* FunctionType */ || + node.parent.kind === 154 /* ConstructorType */ || + node.parent.parent.kind === 156 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 16 /* Private */)) { @@ -30810,24 +31247,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 144 /* Constructor */: + case 145 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.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 147 /* CallSignature */: + case 148 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.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 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (node.parent.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -30835,7 +31272,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 === 216 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 217 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.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 : @@ -30848,7 +31285,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 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -30860,12 +31297,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 === 163 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 164 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 164 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 165 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -30876,7 +31313,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 189 /* OmittedExpression */) { + if (bindingElement.kind === 190 /* 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) @@ -30885,7 +31322,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 165 /* BindingElement */) { + else if (bindingElement.kind === 166 /* 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" @@ -30924,40 +31361,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: - case 220 /* ModuleDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 217 /* InterfaceDeclaration */: - case 216 /* ClassDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 219 /* EnumDeclaration */: + case 216 /* FunctionDeclaration */: + case 221 /* ModuleDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 218 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 220 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return emitExportDeclaration(node); - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 145 /* Constructor */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return writeFunctionDeclaration(node); - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: + case 149 /* ConstructSignature */: + case 148 /* CallSignature */: + case 150 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return emitAccessorDeclaration(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return emitPropertyDeclaration(node); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return emitSourceFile(node); } } @@ -31317,7 +31754,7 @@ var ts; 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};"; // emit output for the __param helper function var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -31415,6 +31852,7 @@ var ts; var isOwnFileEmit; /** If removeComments is true, no leading-comments needed to be emitted **/ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, _a[5 /* ES6 */] = emitES6Module, _a[2 /* AMD */] = emitAMDModule, @@ -31499,10 +31937,10 @@ var ts; // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_19)) { + var name_22 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_22)) { tempFlags |= flags; - return name_19; + return name_22; } } while (true) { @@ -31510,9 +31948,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; + var name_23 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_23)) { + return name_23; } } } @@ -31556,17 +31994,17 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return makeUniqueName(node.text); - case 220 /* ModuleDeclaration */: - case 219 /* EnumDeclaration */: + case 221 /* ModuleDeclaration */: + case 220 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 224 /* ImportDeclaration */: - case 230 /* ExportDeclaration */: + case 225 /* ImportDeclaration */: + case 231 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 215 /* FunctionDeclaration */: - case 216 /* ClassDeclaration */: - case 229 /* ExportAssignment */: + case 216 /* FunctionDeclaration */: + case 217 /* ClassDeclaration */: + case 230 /* ExportAssignment */: return generateNameForExportDefault(); - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -31836,10 +32274,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 185 /* TemplateExpression */) { + if (node.template.kind === 186 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 183 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 184 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -31874,7 +32312,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 174 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 175 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -31916,11 +32354,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: return parent.expression === template; - case 172 /* TaggedTemplateExpression */: - case 174 /* ParenthesizedExpression */: + case 173 /* TaggedTemplateExpression */: + case 175 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -31941,7 +32379,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 37 /* AsteriskToken */: case 39 /* SlashToken */: @@ -31953,8 +32391,8 @@ var ts; default: return -1 /* LessThan */; } - case 186 /* YieldExpression */: - case 184 /* ConditionalExpression */: + case 187 /* YieldExpression */: + case 185 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -32021,38 +32459,38 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 241 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 242 /* JsxSpreadAttribute */; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 241 /* JsxSpreadAttribute */) { + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].kind === 242 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_1 === 0) { + if (i === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_1 > 0) { + if (i > 0) { write(", "); } - emit(attrs[i_1].expression); + emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 240 /* JsxAttribute */); + ts.Debug.assert(attrs[i].kind === 241 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_1 > 0) { + if (i > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_1]); + emitJsxAttribute(attrs[i]); } } if (haveOpenedObjectLiteral) @@ -32062,7 +32500,7 @@ var ts; else { // One object literal with all the attributes in them write("{"); - for (var i = 0; i < attrs.length; i++) { + for (var i = 0, n = attrs.length; i < n; i++) { if (i > 0) { write(", "); } @@ -32075,11 +32513,11 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 242 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 243 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 238 /* JsxText */) { + if (children[i].kind === 239 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -32097,11 +32535,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 235 /* JsxElement */) { + if (node.kind === 236 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 236 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -32123,11 +32561,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 241 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 242 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 240 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 241 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -32135,11 +32573,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 236 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 237 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 236 /* JsxSelfClosingElement */) { + if (node.kind === 237 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -32158,11 +32596,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 235 /* JsxElement */) { + if (node.kind === 236 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 236 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -32170,11 +32608,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 165 /* BindingElement */); + ts.Debug.assert(node.kind !== 166 /* BindingElement */); if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 136 /* ComputedPropertyName */) { + else if (node.kind === 137 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -32218,62 +32656,62 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 166 /* ArrayLiteralExpression */: - case 191 /* AsExpression */: - case 183 /* BinaryExpression */: - case 170 /* CallExpression */: - case 243 /* CaseClause */: - case 136 /* ComputedPropertyName */: - case 184 /* ConditionalExpression */: - case 139 /* Decorator */: - case 177 /* DeleteExpression */: - case 199 /* DoStatement */: - case 169 /* ElementAccessExpression */: - case 229 /* ExportAssignment */: - case 197 /* ExpressionStatement */: - case 190 /* ExpressionWithTypeArguments */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 198 /* IfStatement */: - case 239 /* JsxClosingElement */: - case 236 /* JsxSelfClosingElement */: - case 237 /* JsxOpeningElement */: - case 241 /* JsxSpreadAttribute */: - case 242 /* JsxExpression */: - case 171 /* NewExpression */: - case 174 /* ParenthesizedExpression */: - case 182 /* PostfixUnaryExpression */: - case 181 /* PrefixUnaryExpression */: - case 206 /* ReturnStatement */: - case 248 /* ShorthandPropertyAssignment */: - case 187 /* SpreadElementExpression */: - case 208 /* SwitchStatement */: - case 172 /* TaggedTemplateExpression */: - case 192 /* TemplateSpan */: - case 210 /* ThrowStatement */: - case 173 /* TypeAssertionExpression */: - case 178 /* TypeOfExpression */: - case 179 /* VoidExpression */: - case 200 /* WhileStatement */: - case 207 /* WithStatement */: - case 186 /* YieldExpression */: + case 167 /* ArrayLiteralExpression */: + case 192 /* AsExpression */: + case 184 /* BinaryExpression */: + case 171 /* CallExpression */: + case 244 /* CaseClause */: + case 137 /* ComputedPropertyName */: + case 185 /* ConditionalExpression */: + case 140 /* Decorator */: + case 178 /* DeleteExpression */: + case 200 /* DoStatement */: + case 170 /* ElementAccessExpression */: + case 230 /* ExportAssignment */: + case 198 /* ExpressionStatement */: + case 191 /* ExpressionWithTypeArguments */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 199 /* IfStatement */: + case 240 /* JsxClosingElement */: + case 237 /* JsxSelfClosingElement */: + case 238 /* JsxOpeningElement */: + case 242 /* JsxSpreadAttribute */: + case 243 /* JsxExpression */: + case 172 /* NewExpression */: + case 175 /* ParenthesizedExpression */: + case 183 /* PostfixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: + case 207 /* ReturnStatement */: + case 249 /* ShorthandPropertyAssignment */: + case 188 /* SpreadElementExpression */: + case 209 /* SwitchStatement */: + case 173 /* TaggedTemplateExpression */: + case 193 /* TemplateSpan */: + case 211 /* ThrowStatement */: + case 174 /* TypeAssertionExpression */: + case 179 /* TypeOfExpression */: + case 180 /* VoidExpression */: + case 201 /* WhileStatement */: + case 208 /* WithStatement */: + case 187 /* YieldExpression */: return true; - case 165 /* BindingElement */: - case 249 /* EnumMember */: - case 138 /* Parameter */: - case 247 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 213 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 250 /* EnumMember */: + case 139 /* Parameter */: + case 248 /* PropertyAssignment */: + case 142 /* PropertyDeclaration */: + case 214 /* VariableDeclaration */: return parent.initializer === node; - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return parent.expression === node; - case 176 /* ArrowFunction */: - case 175 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 176 /* FunctionExpression */: return parent.body === node; - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return parent.left === node; } return false; @@ -32285,7 +32723,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 250 /* SourceFile */) { + if (container.kind === 251 /* SourceFile */) { // Identifier references module export if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { write("exports."); @@ -32301,17 +32739,17 @@ var ts; if (modulekind !== 5 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 225 /* ImportClause */) { + if (declaration.kind === 226 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 228 /* ImportSpecifier */) { + else if (declaration.kind === 229 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_21 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_21); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); if (languageVersion === 0 /* ES3 */ && identifier === "default") { write("[\"default\"]"); } @@ -32340,13 +32778,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 165 /* BindingElement */: - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 213 /* VariableDeclaration */: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + var parent_7 = node.parent; + switch (parent_7.kind) { + case 166 /* BindingElement */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 214 /* VariableDeclaration */: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } return false; @@ -32355,8 +32793,8 @@ var ts; if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { // in converted loop body arguments cannot be used directly. - var name_22 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_22); + var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_25); return; } } @@ -32456,10 +32894,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 183 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 184 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 184 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 185 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; @@ -32467,11 +32905,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69 /* Identifier */: - case 166 /* ArrayLiteralExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: - case 170 /* CallExpression */: - case 174 /* ParenthesizedExpression */: + case 167 /* ArrayLiteralExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 175 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -32491,17 +32929,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 187 /* SpreadElementExpression */) { + if (e.kind === 188 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 166 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 187 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 188 /* SpreadElementExpression */) { i++; } write("["); @@ -32524,7 +32962,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 187 /* SpreadElementExpression */; + return node.kind === 188 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -32594,7 +33032,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { + if (property.kind === 146 /* GetAccessor */ || property.kind === 147 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -32646,13 +33084,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 247 /* PropertyAssignment */) { + if (property.kind === 248 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 248 /* ShorthandPropertyAssignment */) { + else if (property.kind === 249 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 143 /* MethodDeclaration */) { + else if (property.kind === 144 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -32686,7 +33124,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136 /* ComputedPropertyName */) { + if (properties[i].name.kind === 137 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -32702,21 +33140,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(183 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(184 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(168 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(169 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(169 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(170 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -32724,7 +33162,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 173 /* TypeAssertionExpression */ || expr.kind === 191 /* AsExpression */) { + while (expr.kind === 174 /* TypeAssertionExpression */ || expr.kind === 192 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -32736,11 +33174,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 171 /* NewExpression */ && + expr.kind !== 172 /* NewExpression */ && expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(174 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(175 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -32775,7 +33213,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 250 /* SourceFile */; + return container && container.kind !== 251 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -32805,7 +33243,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 168 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 169 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -32816,7 +33254,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 168 /* PropertyAccessExpression */ || node.kind === 169 /* ElementAccessExpression */ + return node.kind === 169 /* PropertyAccessExpression */ || node.kind === 170 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; } @@ -32905,7 +33343,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -32923,10 +33361,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 187 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 188 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 174 /* ParenthesizedExpression */ || node.kind === 173 /* TypeAssertionExpression */ || node.kind === 191 /* AsExpression */) { + while (node.kind === 175 /* ParenthesizedExpression */ || node.kind === 174 /* TypeAssertionExpression */ || node.kind === 192 /* AsExpression */) { node = node.expression; } return node; @@ -32947,13 +33385,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 168 /* PropertyAccessExpression */) { + if (expr.kind === 169 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 169 /* ElementAccessExpression */) { + else if (expr.kind === 170 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -32998,7 +33436,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 168 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + superCall = node.expression.kind === 169 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -33067,12 +33505,12 @@ 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 (!ts.nodeIsSynthesized(node) && node.parent.kind !== 176 /* ArrowFunction */) { - if (node.expression.kind === 173 /* TypeAssertionExpression */ || node.expression.kind === 191 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 177 /* ArrowFunction */) { + if (node.expression.kind === 174 /* TypeAssertionExpression */ || node.expression.kind === 192 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 173 /* TypeAssertionExpression */ || operand.kind === 191 /* AsExpression */) { + while (operand.kind === 174 /* TypeAssertionExpression */ || operand.kind === 192 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -33083,15 +33521,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 181 /* PrefixUnaryExpression */ && - operand.kind !== 179 /* VoidExpression */ && - operand.kind !== 178 /* TypeOfExpression */ && - operand.kind !== 177 /* DeleteExpression */ && - operand.kind !== 182 /* PostfixUnaryExpression */ && - operand.kind !== 171 /* NewExpression */ && - !(operand.kind === 170 /* CallExpression */ && node.parent.kind === 171 /* NewExpression */) && - !(operand.kind === 175 /* FunctionExpression */ && node.parent.kind === 170 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 168 /* PropertyAccessExpression */)) { + if (operand.kind !== 182 /* PrefixUnaryExpression */ && + operand.kind !== 180 /* VoidExpression */ && + operand.kind !== 179 /* TypeOfExpression */ && + operand.kind !== 178 /* DeleteExpression */ && + operand.kind !== 183 /* PostfixUnaryExpression */ && + operand.kind !== 172 /* NewExpression */ && + !(operand.kind === 171 /* CallExpression */ && node.parent.kind === 172 /* NewExpression */) && + !(operand.kind === 176 /* FunctionExpression */ && node.parent.kind === 171 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 169 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -33120,7 +33558,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 213 /* VariableDeclaration */ || node.parent.kind === 165 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 /* VariableDeclaration */ || node.parent.kind === 166 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -33151,7 +33589,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 181 /* PrefixUnaryExpression */) { + if (node.operand.kind === 182 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); @@ -33207,10 +33645,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 250 /* SourceFile */) { + if (current.kind === 251 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 221 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 222 /* ModuleBlock */) { return false; } else { @@ -33230,14 +33668,14 @@ var ts; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(170 /* ElementAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true, leftHandSideExpression.expression); } else { synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; @@ -33247,7 +33685,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(168 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(169 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -33275,8 +33713,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && - (node.left.kind === 167 /* ObjectLiteralExpression */ || node.left.kind === 166 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 197 /* ExpressionStatement */); + (node.left.kind === 168 /* ObjectLiteralExpression */ || node.left.kind === 167 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 198 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && @@ -33341,7 +33779,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 194 /* Block */) { + if (node && node.kind === 195 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -33355,12 +33793,12 @@ var ts; } emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); - if (node.kind === 221 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 220 /* ModuleDeclaration */); + if (node.kind === 222 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 221 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 221 /* ModuleBlock */) { + if (node.kind === 222 /* ModuleBlock */) { emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); @@ -33368,7 +33806,7 @@ var ts; emitToken(16 /* CloseBraceToken */, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 194 /* Block */) { + if (node.kind === 195 /* Block */) { write(" "); emit(node); } @@ -33380,7 +33818,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 176 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 177 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -33393,7 +33831,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 198 /* IfStatement */) { + if (node.elseStatement.kind === 199 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -33413,7 +33851,7 @@ var ts; else { emitNormalLoopBody(node, /*emitAsEmbeddedStatement*/ true); } - if (node.statement.kind === 194 /* Block */) { + if (node.statement.kind === 195 /* Block */) { write(" "); } else { @@ -33442,7 +33880,7 @@ var ts; * Returns false if nothing was written - this can happen for source file level variable declarations * in system modules where such variable declarations are hoisted. */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { + function tryEmitStartOfVariableDeclarationList(decl) { if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; @@ -33456,32 +33894,23 @@ var ts; } return false; } - var tokenKind = 102 /* VarKeyword */; + emitStart(decl); if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 108 /* LetKeyword */; + write("let "); } else if (ts.isConst(decl)) { - tokenKind = 74 /* ConstKeyword */; + write("const "); + } + else { + write("var "); } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); } else { - switch (tokenKind) { - case 102 /* VarKeyword */: - write("var "); - break; - case 108 /* LetKeyword */: - write("let "); - break; - case 74 /* ConstKeyword */: - write("const "); - break; - } + write("var "); } + // Note here we specifically dont emit end so that if we are going to emit binding pattern + // we can alter the source map correctly return true; } function emitVariableDeclarationListSkippingUninitializedEntries(list) { @@ -33512,7 +33941,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 209 /* LabeledStatement */) { + if (node.parent.kind === 210 /* LabeledStatement */) { // if parent of the loop was labeled statement - attach the label to loop skipping converted loop body emitLabelAndColon(node.parent); } @@ -33523,10 +33952,11 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + var initializer = node.initializer; + if (initializer && initializer.kind === 215 /* VariableDeclarationList */) { loopInitializer = node.initializer; } break; @@ -33540,7 +33970,7 @@ var ts; collectNames(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 194 /* Block */; + var bodyIsBlock = node.statement.kind === 195 /* Block */; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); @@ -33661,7 +34091,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 194 /* Block */) { + else if (node.statement.kind === 195 /* Block */) { emitLines(node.statement.statements); } else { @@ -33771,9 +34201,9 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { emitCommaList(variableDeclarationList.declarations); } @@ -33797,7 +34227,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 204 /* ForOfStatement */) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -33808,17 +34238,17 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + tryEmitStartOfVariableDeclarationList(variableDeclarationList); emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 202 /* ForInStatement */) { + if (node.kind === 203 /* ForInStatement */) { write(" in "); } else { @@ -33887,18 +34317,18 @@ var ts; emitEnd(node.expression); write("; "); // _i < _a.length; - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write(" < "); emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); - emitEnd(node.initializer); + emitEnd(node.expression); write("; "); // _i++) - emitStart(node.initializer); + emitStart(node.expression); emitNodeWithoutSourceMap(counter); write("++"); - emitEnd(node.initializer); + emitEnd(node.expression); emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); @@ -33908,7 +34338,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 214 /* VariableDeclarationList */) { + if (node.initializer.kind === 215 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -33938,7 +34368,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 166 /* ArrayLiteralExpression */ || node.initializer.kind === 167 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 167 /* ArrayLiteralExpression */ || node.initializer.kind === 168 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); @@ -33966,12 +34396,12 @@ var ts; // it is possible if either // - break\continue is statement 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 === 205 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 206 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { if (!node.label) { - if (node.kind === 205 /* BreakStatement */) { + if (node.kind === 206 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; write("return \"break\";"); } @@ -33982,7 +34412,7 @@ var ts; } else { var labelMarker; - if (node.kind === 205 /* BreakStatement */) { + if (node.kind === 206 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -33995,7 +34425,7 @@ var ts; return; } } - emitToken(node.kind === 205 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -34061,7 +34491,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 243 /* CaseClause */) { + if (node.kind === 244 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -34130,7 +34560,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 220 /* ModuleDeclaration */); + } while (node && node.kind !== 221 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -34155,13 +34585,13 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(179 /* VoidExpression */); + var result = ts.createSynthesizedNode(180 /* VoidExpression */); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 250 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 229 /* ExportAssignment */); + if (node.parent.kind === 251 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 230 /* ExportAssignment */); // only allow export default at a source file level if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!isEs6Module) { @@ -34257,7 +34687,7 @@ var ts; * @param value an expression as a right-hand-side operand of the assignment * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma */ - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment, nodeForSourceMap) { if (shouldEmitCommaBeforeAssignment) { write(", "); } @@ -34267,15 +34697,21 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 213 /* VariableDeclaration */ || name.parent.kind === 165 /* BindingElement */); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 /* VariableDeclaration */ || name.parent.kind === 166 /* BindingElement */); + // If this is first var declaration, we need to start at var/let/const keyword instead + // otherwise use nodeForSourceMap as the start position + emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); + withTemporaryNoSourceMap(function () { + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + }); + emitEnd(nodeForSourceMap, /*stopOverridingSpan*/ true); if (exportChanged) { write(")"); } @@ -34286,14 +34722,19 @@ var ts; * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma */ - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment, sourceMapNode) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment, sourceMapNode || expression.parent); return identifier; } + function isFirstVariableDeclaration(root) { + return root.kind === 214 /* VariableDeclaration */ && + root.parent.kind === 215 /* VariableDeclarationList */ && + root.parent.declarations[0] === root; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -34301,19 +34742,24 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 213 /* VariableDeclaration */) { + if (root.kind === 214 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 138 /* Parameter */) { + else if (root.kind === 139 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 183 /* BinaryExpression */) { + if (root.kind === 184 /* BinaryExpression */) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); + // If first variable declaration of variable statement correct the start location + if (isFirstVariableDeclaration(root)) { + // Use emit location of "var " as next emit start entry + sourceMap.changeEmitSourcePos(); + } emitBindingElement(root, value); } /** @@ -34325,27 +34771,28 @@ var ts; * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; * false if it is necessary to always emit an identifier. */ - function ensureIdentifier(expr, reuseIdentifierExpressions) { + function ensureIdentifier(expr, reuseIdentifierExpressions, sourceMapNode) { if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { return expr; } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0, sourceMapNode); emitCount++; return identifier; } - function createDefaultValueCheck(value, defaultValue) { + function createDefaultValueCheck(value, defaultValue, sourceMapNode) { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // If the temporary variable needs to be emitted use the source Map node for assignment of that statement + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(183 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(184 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(184 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(185 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -34360,9 +34807,10 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 136 /* ComputedPropertyName */; + var nameIsComputed = propName.kind === 137 /* ComputedPropertyName */; if (nameIsComputed) { - index = ensureIdentifier(propName.expression, /*reuseIdentifierExpressions*/ false); + // TODO to handle when we look into sourcemaps for computed properties, for now use propName + index = ensureIdentifier(propName.expression, /*reuseIdentifierExpressions*/ false, propName); } else { // We create a synthetic copy of the identifier in order to avoid the rewriting that might @@ -34375,7 +34823,7 @@ var ts; : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(170 /* CallExpression */); + var call = ts.createSynthesizedNode(171 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -34383,60 +34831,65 @@ var ts; call.arguments[0] = createNumericLiteral(sliceIndex); return call; } - function emitObjectLiteralAssignment(target, value) { + function emitObjectLiteralAssignment(target, value, sourceMapNode) { var properties = target.properties; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // 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, sourceMapNode); } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 247 /* PropertyAssignment */ || p.kind === 248 /* ShorthandPropertyAssignment */) { + if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { var propName = p.name; - var target_1 = p.kind === 248 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 249 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + // Assignment for target = value.propName should highligh whole property, hence use p as source map node + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } } - function emitArrayLiteralAssignment(target, value) { + function emitArrayLiteralAssignment(target, value, sourceMapNode) { var elements = target.elements; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // 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, sourceMapNode); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 189 /* OmittedExpression */) { - if (e.kind !== 187 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + if (e.kind !== 190 /* OmittedExpression */) { + // Assignment for target = value.propName should highligh whole property, hence use e as source map node + if (e.kind !== 188 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + emitDestructuringAssignment(e.expression, createSliceCall(value, i), e); } } } } - function emitDestructuringAssignment(target, value) { - if (target.kind === 248 /* ShorthandPropertyAssignment */) { + function emitDestructuringAssignment(target, value, sourceMapNode) { + // When emitting target = value use source map node to highlight, including any temporary assignments needed for this + if (target.kind === 249 /* ShorthandPropertyAssignment */) { if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 183 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); + else if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 167 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); + if (target.kind === 168 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 166 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); + else if (target.kind === 167 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value, sourceMapNode); } else { - emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0, sourceMapNode); emitCount++; } } @@ -34447,25 +34900,32 @@ var ts; emit(value); } else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); + // Source map node for root.left = root.right is root + // but if root is synthetic, which could be in below case, use the target which is { a } + // for ({a} of {a: string}) { + // } + emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 174 /* ParenthesizedExpression */) { + if (root.parent.kind !== 175 /* ParenthesizedExpression */) { write("("); } - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - emitDestructuringAssignment(target, value); + // Temporary assignment needed to emit root should highlight whole binary expression + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, root); + // Source map node for root.left = root.right is root + emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 174 /* ParenthesizedExpression */) { + if (root.parent.kind !== 175 /* ParenthesizedExpression */) { write(")"); } } } function emitBindingElement(target, value) { + // Any temporary assignments needed to emit target = value should point to target if (target.initializer) { // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + value = value ? createDefaultValueCheck(value, target.initializer, target) : target.initializer; } else if (!value) { // Use 'void 0' in absence of value and initializer @@ -34480,16 +34940,16 @@ var ts; // to ensure value is evaluated exactly once. Additionally, if we have zero elements // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, // so in that case, we'll intentionally create that temporary. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0, target); } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 163 /* ObjectBindingPattern */) { + if (pattern.kind === 164 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 189 /* OmittedExpression */) { + else if (element.kind !== 190 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -34501,7 +34961,7 @@ var ts; } } else { - emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0, target); emitCount++; } } @@ -34529,8 +34989,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isLetDefinedInLoop && - node.parent.parent.kind !== 202 /* ForInStatement */ && - node.parent.parent.kind !== 203 /* ForOfStatement */) { + node.parent.parent.kind !== 203 /* ForInStatement */ && + node.parent.parent.kind !== 204 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -34548,7 +35008,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 189 /* OmittedExpression */) { + if (node.kind === 190 /* OmittedExpression */) { return; } var name = node.name; @@ -34560,7 +35020,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 213 /* VariableDeclaration */ && node.parent.kind !== 165 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 214 /* VariableDeclaration */ && node.parent.kind !== 166 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -34568,7 +35028,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 2 /* Export */) && modulekind === 5 /* ES6 */ && - node.parent.kind === 250 /* SourceFile */; + node.parent.kind === 251 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -34619,12 +35079,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_26 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_26); + emit(name_26); } else { emit(node.name); @@ -34729,12 +35189,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 146 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 176 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 177 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -34745,11 +35205,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 175 /* FunctionExpression */) { + if (node.kind === 176 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || modulekind !== 5 /* ES6 */; } @@ -34761,12 +35221,12 @@ var ts; // TODO (yuisu) : we should not have special cases to condition emitting comments // but have one place to fix check for these conditions. var kind = node.kind, parent = node.parent; - if (kind !== 143 /* MethodDeclaration */ && - kind !== 142 /* MethodSignature */ && + if (kind !== 144 /* MethodDeclaration */ && + kind !== 143 /* MethodSignature */ && parent && - parent.kind !== 247 /* PropertyAssignment */ && - parent.kind !== 170 /* CallExpression */ && - parent.kind !== 166 /* ArrayLiteralExpression */) { + parent.kind !== 248 /* PropertyAssignment */ && + parent.kind !== 171 /* CallExpression */ && + parent.kind !== 167 /* ArrayLiteralExpression */) { // 1. Methods will emit comments at their assignment declaration sites. // // 2. If the function is a property of object literal, emitting leading-comments @@ -34805,11 +35265,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 /* ES6 */ && kind === 215 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { + if (modulekind !== 5 /* ES6 */ && kind === 216 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 143 /* MethodDeclaration */ && kind !== 142 /* MethodSignature */) { + if (kind !== 144 /* MethodDeclaration */ && kind !== 143 /* MethodSignature */) { emitTrailingComments(node); } } @@ -34842,7 +35302,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 176 /* ArrowFunction */; + var isArrowFunction = node.kind === 177 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* 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 @@ -34961,7 +35421,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 194 /* Block */) { + if (node.body.kind === 195 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -35020,10 +35480,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 173 /* TypeAssertionExpression */) { + while (current.kind === 174 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 167 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 168 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -35097,9 +35557,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 197 /* ExpressionStatement */) { + if (statement && statement.kind === 198 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 170 /* CallExpression */) { + if (expr && expr.kind === 171 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 95 /* SuperKeyword */) { return statement; @@ -35133,7 +35593,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 136 /* ComputedPropertyName */) { + else if (memberName.kind === 137 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -35145,7 +35605,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { + if (member.kind === 142 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -35185,11 +35645,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 193 /* SemicolonClassElement */) { + if (member.kind === 194 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { + else if (member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -35206,7 +35666,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { + else if (member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -35256,22 +35716,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { + if ((member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 143 /* MethodDeclaration */ || - member.kind === 145 /* GetAccessor */ || - member.kind === 146 /* SetAccessor */) { + else if (member.kind === 144 /* MethodDeclaration */ || + member.kind === 146 /* GetAccessor */ || + member.kind === 147 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 64 /* Static */) { write("static "); } - if (member.kind === 145 /* GetAccessor */) { + if (member.kind === 146 /* GetAccessor */) { write("get "); } - else if (member.kind === 146 /* SetAccessor */) { + else if (member.kind === 147 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -35282,7 +35742,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 193 /* SemicolonClassElement */) { + else if (member.kind === 194 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -35311,11 +35771,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && !member.body) { + if (member.kind === 145 /* Constructor */ && !member.body) { emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { + if (member.kind === 142 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -35429,7 +35889,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -35506,7 +35966,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*isStatic*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 188 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -35588,7 +36048,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 250 /* SourceFile */) { + else if (node.parent.kind !== 251 /* SourceFile */) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -35600,7 +36060,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -35661,11 +36121,11 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { emitExportMemberAssignment(node); } } @@ -35749,7 +36209,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 143 /* MethodDeclaration */) { + if (member.kind === 144 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -35806,7 +36266,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0 /* ES3 */) { - if (member.kind !== 141 /* PropertyDeclaration */) { + if (member.kind !== 142 /* PropertyDeclaration */) { // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. // We have this extra argument here so that we can inject an explicit property descriptor at a later date. write(", null"); @@ -35848,10 +36308,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: + case 144 /* MethodDeclaration */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 142 /* PropertyDeclaration */: return true; } return false; @@ -35861,7 +36321,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 143 /* MethodDeclaration */: + case 144 /* MethodDeclaration */: return true; } return false; @@ -35871,9 +36331,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 216 /* ClassDeclaration */: - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: + case 217 /* ClassDeclaration */: + case 144 /* MethodDeclaration */: + case 147 /* SetAccessor */: return true; } return false; @@ -35891,19 +36351,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: write("Function"); return; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 138 /* Parameter */: + case 139 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 145 /* GetAccessor */: + case 146 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 146 /* SetAccessor */: + case 147 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -35919,23 +36379,23 @@ var ts; case 103 /* VoidKeyword */: write("void 0"); return; - case 160 /* ParenthesizedType */: + case 161 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: write("Function"); return; - case 156 /* ArrayType */: - case 157 /* TupleType */: + case 157 /* ArrayType */: + case 158 /* TupleType */: write("Array"); return; - case 150 /* TypePredicate */: + case 151 /* TypePredicate */: case 120 /* BooleanKeyword */: write("Boolean"); return; case 130 /* StringKeyword */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: write("String"); return; case 128 /* NumberKeyword */: @@ -35944,15 +36404,15 @@ var ts; case 131 /* SymbolKeyword */: write("Symbol"); return; - case 151 /* TypeReference */: + case 152 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 154 /* TypeQuery */: - case 155 /* TypeLiteral */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 155 /* TypeQuery */: + case 156 /* TypeLiteral */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: case 117 /* AnyKeyword */: - case 161 /* ThisType */: + case 162 /* ThisType */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -36025,7 +36485,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -36041,10 +36501,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 156 /* ArrayType */) { + if (parameterType.kind === 157 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 152 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -36121,7 +36581,7 @@ var ts; if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 219 /* EnumDeclaration */))) { + if (!(node.flags & 2 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220 /* EnumDeclaration */))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -36203,7 +36663,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 220 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -36227,7 +36687,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220 /* ModuleDeclaration */)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221 /* ModuleDeclaration */)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -36245,7 +36705,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 221 /* ModuleBlock */) { + if (node.body.kind === 222 /* ModuleBlock */) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -36321,16 +36781,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 223 /* ImportEqualsDeclaration */) { + if (node.kind === 224 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 224 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 225 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -36358,7 +36818,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -36384,7 +36844,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 223 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; + var isExportedImport = node.kind === 224 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); @@ -36403,7 +36863,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 224 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 225 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -36582,8 +37042,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 215 /* FunctionDeclaration */ && - expression.kind !== 216 /* ClassDeclaration */) { + if (expression.kind !== 216 /* FunctionDeclaration */ && + expression.kind !== 217 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -36620,7 +37080,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" @@ -36630,13 +37090,13 @@ var ts; externalImports.push(node); } break; - case 223 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 234 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 224 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 235 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -36654,12 +37114,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_27 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_27] || (exportSpecifiers[name_27] = [])).push(specifier); } } break; - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -36685,18 +37145,18 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 224 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 225 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 230 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 231 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode, emitRelativePathAsModuleName) { if (emitRelativePathAsModuleName) { - var name_25 = getExternalModuleNameFromDeclaration(host, resolver, importNode); - if (name_25) { - return "\"" + name_25 + "\""; + var name_28 = getExternalModuleNameFromDeclaration(host, resolver, importNode); + if (name_28) { + return "\"" + name_28 + "\""; } } var moduleName = ts.getExternalModuleName(importNode); @@ -36714,8 +37174,8 @@ var ts; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 230 /* ExportDeclaration */ || - (importNode.kind === 224 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 231 /* ExportDeclaration */ || + (importNode.kind === 225 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -36748,7 +37208,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 230 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 231 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -36780,7 +37240,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 230 /* ExportDeclaration */) { + if (externalImport.kind !== 231 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -36868,12 +37328,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; i++) { var local = hoistedVars[i]; - var name_26 = local.kind === 69 /* Identifier */ + var name_29 = local.kind === 69 /* Identifier */ ? local : local.name; - if (name_26) { + if (name_29) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_26.text); + var text = ts.unescapeIdentifier(name_29.text); if (ts.hasProperty(seen, text)) { continue; } @@ -36884,7 +37344,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 216 /* ClassDeclaration */ || local.kind === 220 /* ModuleDeclaration */ || local.kind === 219 /* EnumDeclaration */) { + if (local.kind === 217 /* ClassDeclaration */ || local.kind === 221 /* ModuleDeclaration */ || local.kind === 220 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -36918,21 +37378,21 @@ var ts; if (node.flags & 4 /* Ambient */) { return; } - if (node.kind === 215 /* FunctionDeclaration */) { + if (node.kind === 216 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 216 /* ClassDeclaration */) { + if (node.kind === 217 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 219 /* EnumDeclaration */) { + if (node.kind === 220 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -36941,7 +37401,7 @@ var ts; } return; } - if (node.kind === 220 /* ModuleDeclaration */) { + if (node.kind === 221 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -36950,17 +37410,17 @@ var ts; } return; } - if (node.kind === 213 /* VariableDeclaration */ || node.kind === 165 /* BindingElement */) { + if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_27 = node.name; - if (name_27.kind === 69 /* Identifier */) { + var name_30 = node.name; + if (name_30.kind === 69 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_27); + hoistedVars.push(name_30); } else { - ts.forEachChild(name_27, visit); + ts.forEachChild(name_30, visit); } } return; @@ -36991,7 +37451,7 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 250 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 251 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return modulekind === 4 /* System */ && isCurrentFileExternalModule; @@ -37066,21 +37526,21 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -37093,12 +37553,12 @@ var ts; write(exportFunctionForFile + "({"); writeLine(); increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; i_2++) { - if (i_2 !== 0) { + for (var i_1 = 0, len = entry.exportClause.elements.length; i_1 < len; i_1++) { + if (i_1 !== 0) { write(","); writeLine(); } - var e = entry.exportClause.elements[i_2]; + var e = entry.exportClause.elements[i_1]; write("\""); emitNodeWithCommentsAndWithoutSourcemap(e.name); write("\": " + parameterName + "[\""); @@ -37139,10 +37599,10 @@ var ts; // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case 215 /* FunctionDeclaration */: - case 224 /* ImportDeclaration */: + case 216 /* FunctionDeclaration */: + case 225 /* ImportDeclaration */: continue; - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -37151,7 +37611,7 @@ var ts; } } continue; - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; @@ -37510,22 +37970,22 @@ var ts; if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 4194304 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { + if (!decorateEmitted && node.flags & 8388608 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { + if (!paramEmitted && node.flags & 16777216 /* HasParamDecorators */) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + if (!awaiterEmitted && node.flags & 33554432 /* HasAsyncFunctions */) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -37596,28 +38056,41 @@ var ts; emitJavaScriptWorker(node); } } + function changeSourceMapEmit(writer) { + sourceMap = writer; + emitStart = writer.emitStart; + emitEnd = writer.emitEnd; + emitPos = writer.emitPos; + setSourceFile = writer.setSourceFile; + } + function withTemporaryNoSourceMap(callback) { + var prevSourceMap = sourceMap; + setSourceMapWriterEmit(ts.getNullSourceMapWriter()); + callback(); + setSourceMapWriterEmit(prevSourceMap); + } function isSpecializedCommentHandling(node) { switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 229 /* ExportAssignment */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 230 /* ExportAssignment */: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -37629,9 +38102,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 194 /* Block */ && + if (node.kind !== 195 /* Block */ && node.parent && - node.parent.kind === 176 /* ArrowFunction */ && + node.parent.kind === 177 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -37644,13 +38117,13 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return emitIdentifier(node); - case 138 /* Parameter */: + case 139 /* Parameter */: return emitParameter(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return emitMethod(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: return emitAccessor(node); case 97 /* ThisKeyword */: return emitThis(node); @@ -37670,142 +38143,142 @@ var ts; case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: return emitTemplateExpression(node); - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return emitTemplateSpan(node); - case 235 /* JsxElement */: - case 236 /* JsxSelfClosingElement */: + case 236 /* JsxElement */: + case 237 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 238 /* JsxText */: + case 239 /* JsxText */: return emitJsxText(node); - case 242 /* JsxExpression */: + case 243 /* JsxExpression */: return emitJsxExpression(node); - case 135 /* QualifiedName */: + case 136 /* QualifiedName */: return emitQualifiedName(node); - case 163 /* ObjectBindingPattern */: + case 164 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 164 /* ArrayBindingPattern */: + case 165 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 165 /* BindingElement */: + case 166 /* BindingElement */: return emitBindingElement(node); - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 247 /* PropertyAssignment */: + case 248 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 248 /* ShorthandPropertyAssignment */: + case 249 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 136 /* ComputedPropertyName */: + case 137 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 168 /* PropertyAccessExpression */: + case 169 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 170 /* CallExpression */: + case 171 /* CallExpression */: return emitCallExpression(node); - case 171 /* NewExpression */: + case 172 /* NewExpression */: return emitNewExpression(node); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 173 /* TypeAssertionExpression */: + case 174 /* TypeAssertionExpression */: return emit(node.expression); - case 191 /* AsExpression */: + case 192 /* AsExpression */: return emit(node.expression); - case 174 /* ParenthesizedExpression */: + case 175 /* ParenthesizedExpression */: return emitParenExpression(node); - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 177 /* DeleteExpression */: + case 178 /* DeleteExpression */: return emitDeleteExpression(node); - case 178 /* TypeOfExpression */: + case 179 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 179 /* VoidExpression */: + case 180 /* VoidExpression */: return emitVoidExpression(node); - case 180 /* AwaitExpression */: + case 181 /* AwaitExpression */: return emitAwaitExpression(node); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 182 /* PostfixUnaryExpression */: + case 183 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return emitBinaryExpression(node); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return emitConditionalExpression(node); - case 187 /* SpreadElementExpression */: + case 188 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 186 /* YieldExpression */: + case 187 /* YieldExpression */: return emitYieldExpression(node); - case 189 /* OmittedExpression */: + case 190 /* OmittedExpression */: return; - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return emitBlock(node); - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: return emitVariableStatement(node); - case 196 /* EmptyStatement */: + case 197 /* EmptyStatement */: return write(";"); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return emitExpressionStatement(node); - case 198 /* IfStatement */: + case 199 /* IfStatement */: return emitIfStatement(node); - case 199 /* DoStatement */: + case 200 /* DoStatement */: return emitDoStatement(node); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: return emitWhileStatement(node); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return emitForStatement(node); - case 203 /* ForOfStatement */: - case 202 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 203 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 204 /* ContinueStatement */: - case 205 /* BreakStatement */: + case 205 /* ContinueStatement */: + case 206 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: return emitReturnStatement(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: return emitWithStatement(node); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return emitSwitchStatement(node); - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 209 /* LabeledStatement */: + case 210 /* LabeledStatement */: return emitLabeledStatement(node); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: return emitThrowStatement(node); - case 211 /* TryStatement */: + case 212 /* TryStatement */: return emitTryStatement(node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return emitCatchClause(node); - case 212 /* DebuggerStatement */: + case 213 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: return emitClassExpression(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return emitClassDeclaration(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return emitEnumMember(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: return emitImportDeclaration(node); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: return emitExportDeclaration(node); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* SourceFile */: + case 251 /* SourceFile */: return emitSourceFileNode(node); } } @@ -37844,7 +38317,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 250 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 251 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -37859,7 +38332,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 250 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 251 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -38290,7 +38763,25 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + : (function (moduleNames, containingFile) { + var resolvedModuleNames = []; + // resolveModuleName does not store any results between calls. + // lookup is a local cache to avoid resolving the same module name several times + var lookup = {}; + for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { + var moduleName = moduleNames_1[_i]; + var resolvedName = void 0; + if (ts.hasProperty(lookup, moduleName)) { + resolvedName = lookup[moduleName]; + } + else { + resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule; + lookup[moduleName] = resolvedName; + } + resolvedModuleNames.push(resolvedName); + } + return resolvedModuleNames; + }); var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing @@ -38408,14 +38899,18 @@ var ts; // tripleslash references has changed return false; } - // check imports + // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed return false; } + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + return false; + } if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (var i = 0; i < moduleNames.length; i++) { @@ -38580,44 +39075,44 @@ var ts; return false; } switch (node.kind) { - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 245 /* HeritageClause */: + case 246 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: - case 215 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -38625,20 +39120,20 @@ var ts; return true; } break; - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -38646,7 +39141,7 @@ var ts; return true; } break; - case 138 /* Parameter */: + case 139 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -38662,17 +39157,17 @@ var ts; return true; } break; - case 141 /* PropertyDeclaration */: + case 142 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 173 /* TypeAssertionExpression */: + case 174 /* 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 139 /* Decorator */: + case 140 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -38750,59 +39245,77 @@ var ts; function moduleNameIsEqualTo(a, b) { return a.text === b.text; } + function getTextOfLiteral(literal) { + return literal.text; + } function collectExternalModuleReferences(file) { if (file.imports) { return; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); + var isExternalModuleFile = ts.isExternalModule(file); var imports; + var moduleAugmentations; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; - collect(node, /*allowRelativeModuleNames*/ true, /*collectOnlyRequireCalls*/ false); + collectModuleReferences(node, /*inAmbientModule*/ false); + if (isJavaScriptFile) { + collectRequireCalls(node); + } } file.imports = imports || emptyArray; + file.moduleAugmentations = moduleAugmentations || emptyArray; return; - function collect(node, allowRelativeModuleNames, collectOnlyRequireCalls) { - if (!collectOnlyRequireCalls) { - switch (node.kind) { - case 224 /* ImportDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 230 /* ExportDeclaration */: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } + function collectModuleReferences(node, inAmbientModule) { + switch (node.kind) { + case 225 /* ImportDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 231 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; - case 220 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 + } + if (!moduleNameExpr.text) { + break; + } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 221 /* ModuleDeclaration */: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { + var moduleName = node.name; + // Ambient module declarations can be interpreted as augmentations for some existing external modules. + // This will happen in two cases: + // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope + // - if current file is not external module then module augmentation is an ambient module declaration with non-relative module name + // immediately nested in top level ambient module declaration . + if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { + (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + } + else if (!inAmbientModule) { // 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. // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /*allowRelativeModuleNames*/ false, collectOnlyRequireCalls); - }); + // NOTE: body of ambient module is always a module block + for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + collectModuleReferences(statement, /*inAmbientModule*/ true); + } } - break; - } + } } - if (isJavaScriptFile) { - if (ts.isRequireCall(node)) { - (imports || (imports = [])).push(node.arguments[0]); - } - else { - ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames, /*collectOnlyRequireCalls*/ true); }); - } + } + function collectRequireCalls(node) { + if (ts.isRequireCall(node)) { + (imports || (imports = [])).push(node.arguments[0]); + } + else { + ts.forEachChild(node, collectRequireCalls); } } } @@ -38914,14 +39427,21 @@ var ts; } function processImportedModules(file, basePath) { collectExternalModuleReferences(file); - if (file.imports.length) { + if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); - for (var i = 0; i < file.imports.length; i++) { + for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { + // add file to program only if: + // - resolution was successfull + // - noResolve is falsy + // - module name come from the list fo imports + var shouldAddFile = resolution && + !options.noResolve && + i < file.imports.length; + if (shouldAddFile) { var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, @@ -39786,7 +40306,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 176 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 177 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -39798,30 +40318,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 194 /* Block */: + case 195 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 199 /* DoStatement */ || - parent_7.kind === 202 /* ForInStatement */ || - parent_7.kind === 203 /* ForOfStatement */ || - parent_7.kind === 201 /* ForStatement */ || - parent_7.kind === 198 /* IfStatement */ || - parent_7.kind === 200 /* WhileStatement */ || - parent_7.kind === 207 /* WithStatement */ || - parent_7.kind === 246 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 200 /* DoStatement */ || + parent_8.kind === 203 /* ForInStatement */ || + parent_8.kind === 204 /* ForOfStatement */ || + parent_8.kind === 202 /* ForStatement */ || + parent_8.kind === 199 /* IfStatement */ || + parent_8.kind === 201 /* WhileStatement */ || + parent_8.kind === 208 /* WithStatement */ || + parent_8.kind === 247 /* CatchClause */) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 211 /* TryStatement */) { + if (parent_8.kind === 212 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_7; + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -39844,23 +40364,23 @@ var ts; break; } // Fallthrough. - case 221 /* ModuleBlock */: { + case 222 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 167 /* ObjectLiteralExpression */: - case 222 /* CaseBlock */: { + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 168 /* ObjectLiteralExpression */: + case 223 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -39890,12 +40410,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_31 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_31); 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_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_31); if (!matches) { continue; } @@ -39908,14 +40428,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_31); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_31, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -39953,7 +40473,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 136 /* ComputedPropertyName */) { + else if (declaration.name.kind === 137 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -39974,7 +40494,7 @@ var ts; } return true; } - if (expression.kind === 168 /* PropertyAccessExpression */) { + if (expression.kind === 169 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -39987,7 +40507,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 === 136 /* ComputedPropertyName */) { + if (declaration.name.kind === 137 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -40061,17 +40581,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 220 /* ModuleDeclaration */); + } while (current.kind === 221 /* ModuleDeclaration */); // fall through - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -40082,21 +40602,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 230 /* ExportDeclaration */: + case 231 /* 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 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -40108,7 +40628,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -40117,21 +40637,21 @@ var ts; } } break; - case 165 /* BindingElement */: - case 213 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 214 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: - case 220 /* ModuleDeclaration */: - case 215 /* FunctionDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 228 /* ImportSpecifier */: - case 232 /* ExportSpecifier */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: + case 221 /* ModuleDeclaration */: + case 216 /* FunctionDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 229 /* ImportSpecifier */: + case 233 /* ExportSpecifier */: childNodes.push(node); break; } @@ -40179,17 +40699,17 @@ var ts; for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; switch (node.kind) { - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 218 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -40200,12 +40720,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 215 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 216 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 194 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 195 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 215 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 216 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -40265,7 +40785,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 138 /* Parameter */: + case 139 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -40273,36 +40793,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 145 /* GetAccessor */: + case 146 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 146 /* SetAccessor */: + case 147 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 249 /* EnumMember */: + case 250 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 147 /* CallSignature */: + case 148 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 148 /* ConstructSignature */: + case 149 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: var variableDeclarationNode; - var name_29; - if (node.kind === 165 /* BindingElement */) { - name_29 = node.name; + var name_32; + if (node.kind === 166 /* BindingElement */) { + name_32 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 213 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 214 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -40310,24 +40830,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_32 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.variableElement); } - case 144 /* Constructor */: + case 145 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 232 /* ExportSpecifier */: - case 228 /* ImportSpecifier */: - case 223 /* ImportEqualsDeclaration */: - case 225 /* ImportClause */: - case 226 /* NamespaceImport */: + case 233 /* ExportSpecifier */: + case 229 /* ImportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -40357,29 +40877,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 250 /* SourceFile */: + case 251 /* SourceFile */: return createSourceFileItem(node); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: return createClassItem(node); - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: return createEnumItem(node); - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return createModuleItem(node); - case 215 /* FunctionDeclaration */: + case 216 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { + if (ts.isAmbientModule(moduleDeclaration)) { return getTextOfNode(moduleDeclaration.name); } // 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 === 220 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -40391,7 +40911,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 194 /* Block */) { + if (node.body && node.body.kind === 195 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -40412,7 +40932,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 144 /* Constructor */ && member; + return member.kind === 145 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -40436,7 +40956,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 137 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -40445,13 +40965,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 220 /* ModuleDeclaration */) { + while (node.body.kind === 221 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 250 /* SourceFile */ + return node.kind === 251 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -41202,7 +41722,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 170 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 171 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -41210,7 +41730,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 168 /* PropertyAccessExpression */ + : expression.kind === 169 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -41243,7 +41763,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 170 /* CallExpression */ || node.parent.kind === 171 /* NewExpression */) { + if (node.parent.kind === 171 /* CallExpression */ || node.parent.kind === 172 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -41296,25 +41816,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 172 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 173 /* 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); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 172 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 173 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 185 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 192 /* TemplateSpan */ && node.parent.parent.parent.kind === 172 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 193 /* TemplateSpan */ && node.parent.parent.parent.kind === 173 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 185 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -41432,7 +41952,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 === 185 /* TemplateExpression */) { + if (template.kind === 186 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -41441,7 +41961,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 250 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 251 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -41641,40 +42161,40 @@ var ts; return false; } switch (n.kind) { - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 167 /* ObjectLiteralExpression */: - case 163 /* ObjectBindingPattern */: - case 155 /* TypeLiteral */: - case 194 /* Block */: - case 221 /* ModuleBlock */: - case 222 /* CaseBlock */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 168 /* ObjectLiteralExpression */: + case 164 /* ObjectBindingPattern */: + case 156 /* TypeLiteral */: + case 195 /* Block */: + case 222 /* ModuleBlock */: + case 223 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 171 /* NewExpression */: + case 172 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 170 /* CallExpression */: - case 174 /* ParenthesizedExpression */: - case 160 /* ParenthesizedType */: + case 171 /* CallExpression */: + case 175 /* ParenthesizedExpression */: + case 161 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 176 /* ArrowFunction */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 149 /* ConstructSignature */: + case 148 /* CallSignature */: + case 177 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -41684,64 +42204,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 198 /* IfStatement */: + case 199 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 23 /* SemicolonToken */); - case 166 /* ArrayLiteralExpression */: - case 164 /* ArrayBindingPattern */: - case 169 /* ElementAccessExpression */: - case 136 /* ComputedPropertyName */: - case 157 /* TupleType */: + case 167 /* ArrayLiteralExpression */: + case 165 /* ArrayBindingPattern */: + case 170 /* ElementAccessExpression */: + case 137 /* ComputedPropertyName */: + case 158 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 149 /* IndexSignature */: + case 150 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + case 244 /* CaseClause */: + case 245 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 200 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 201 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 199 /* DoStatement */: + case 200 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 154 /* TypeQuery */: + case 155 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 178 /* TypeOfExpression */: - case 177 /* DeleteExpression */: - case 179 /* VoidExpression */: - case 186 /* YieldExpression */: - case 187 /* SpreadElementExpression */: + case 179 /* TypeOfExpression */: + case 178 /* DeleteExpression */: + case 180 /* VoidExpression */: + case 187 /* YieldExpression */: + case 188 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 172 /* TaggedTemplateExpression */: + case 173 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 185 /* TemplateExpression */: + case 186 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 192 /* TemplateSpan */: + case 193 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 181 /* PrefixUnaryExpression */: + case 182 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 183 /* BinaryExpression */: + case 184 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 184 /* ConditionalExpression */: + case 185 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -41797,7 +42317,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 === 273 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 274 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -41903,7 +42423,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 238 /* JsxText */) { + if (isToken(n) || n.kind === 239 /* JsxText */) { return n; } var children = n.getChildren(); @@ -41911,7 +42431,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 238 /* JsxText */) { + if (isToken(n) || n.kind === 239 /* JsxText */) { return n; } var children = n.getChildren(); @@ -41925,10 +42445,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 238 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 239 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 238 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 239 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -41940,7 +42460,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 250 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 251 /* 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. @@ -41962,7 +42482,7 @@ var ts; ts.findPrecedingToken = findPrecedingToken; function isInString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); - return token && (token.kind === 9 /* StringLiteral */ || token.kind === 162 /* StringLiteralType */) && position > token.getStart(); + return token && (token.kind === 9 /* StringLiteral */ || token.kind === 163 /* StringLiteralType */) && position > token.getStart(); } ts.isInString = isInString; function isInComment(sourceFile, position) { @@ -42066,17 +42586,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 151 /* TypeReference */ || node.kind === 170 /* CallExpression */) { + if (node.kind === 152 /* TypeReference */ || node.kind === 171 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 216 /* ClassDeclaration */ || node.kind === 217 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 217 /* ClassDeclaration */ || node.kind === 218 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 135 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -42092,7 +42612,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 162 /* StringLiteralType */ + || kind === 163 /* StringLiteralType */ || kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; @@ -42135,13 +42655,40 @@ var ts; return true; } ts.compareDataObjects = compareDataObjects; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { + if (node.kind === 167 /* ArrayLiteralExpression */ || + node.kind === 168 /* ObjectLiteralExpression */) { + // [a,b,c] from: + // [a, b, c] = someExpression; + if (node.parent.kind === 184 /* BinaryExpression */ && + node.parent.left === node && + node.parent.operatorToken.kind === 56 /* EqualsToken */) { + return true; + } + // [a, b, c] from: + // for([a, b, c] of expression) + if (node.parent.kind === 204 /* ForOfStatement */ && + node.parent.initializer === node) { + return true; + } + // [a, b, c] of + // [x, [a, b, c] ] = someExpression + // or + // {x, a: {a, b, c} } = someExpression + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 248 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + return true; + } + } + return false; + } + ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 139 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -42329,7 +42876,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 228 /* ImportSpecifier */ || location.parent.kind === 232 /* ExportSpecifier */) && + (location.parent.kind === 229 /* ImportSpecifier */ || location.parent.kind === 233 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -42452,10 +42999,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 240 /* JsxAttribute */: - case 237 /* JsxOpeningElement */: - case 239 /* JsxClosingElement */: - case 236 /* JsxSelfClosingElement */: + case 241 /* JsxAttribute */: + case 238 /* JsxOpeningElement */: + case 240 /* JsxClosingElement */: + case 237 /* JsxSelfClosingElement */: return node.kind === 69 /* Identifier */; } } @@ -43059,9 +43606,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_33 in o) { + if (o[name_33] === rule) { + return name_33; } } throw new Error("Unknown rule"); @@ -43070,40 +43617,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 201 /* ForStatement */; + return context.contextNode.kind === 202 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 183 /* BinaryExpression */: - case 184 /* ConditionalExpression */: - case 191 /* AsExpression */: - case 150 /* TypePredicate */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: + case 184 /* BinaryExpression */: + case 185 /* ConditionalExpression */: + case 192 /* AsExpression */: + case 151 /* TypePredicate */: + case 159 /* UnionType */: + case 160 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 165 /* BindingElement */: + case 166 /* BindingElement */: // equals in type X = ... - case 218 /* TypeAliasDeclaration */: + case 219 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 213 /* VariableDeclaration */: + case 214 /* VariableDeclaration */: // equal in p = 0; - case 138 /* Parameter */: - case 249 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 139 /* Parameter */: + case 250 /* EnumMember */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 202 /* ForInStatement */: + case 203 /* ForInStatement */: return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 203 /* ForOfStatement */: - return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; + case 204 /* ForOfStatement */: + return context.currentTokenSpan.kind === 135 /* OfKeyword */ || context.nextTokenSpan.kind === 135 /* OfKeyword */; } return false; }; @@ -43111,7 +43658,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 184 /* ConditionalExpression */; + return context.contextNode.kind === 185 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -43155,93 +43702,93 @@ var ts; return true; } switch (node.kind) { - case 194 /* Block */: - case 222 /* CaseBlock */: - case 167 /* ObjectLiteralExpression */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 223 /* CaseBlock */: + case 168 /* ObjectLiteralExpression */: + case 222 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 147 /* CallSignature */: - case 175 /* FunctionExpression */: - case 144 /* Constructor */: - case 176 /* ArrowFunction */: + case 148 /* CallSignature */: + case 176 /* FunctionExpression */: + case 145 /* Constructor */: + case 177 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 215 /* FunctionDeclaration */ || context.contextNode.kind === 175 /* FunctionExpression */; + return context.contextNode.kind === 216 /* FunctionDeclaration */ || context.contextNode.kind === 176 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 220 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 156 /* TypeLiteral */: + case 221 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 216 /* ClassDeclaration */: - case 220 /* ModuleDeclaration */: - case 219 /* EnumDeclaration */: - case 194 /* Block */: - case 246 /* CatchClause */: - case 221 /* ModuleBlock */: - case 208 /* SwitchStatement */: + case 217 /* ClassDeclaration */: + case 221 /* ModuleDeclaration */: + case 220 /* EnumDeclaration */: + case 195 /* Block */: + case 247 /* CatchClause */: + case 222 /* ModuleBlock */: + case 209 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 198 /* IfStatement */: - case 208 /* SwitchStatement */: - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 200 /* WhileStatement */: - case 211 /* TryStatement */: - case 199 /* DoStatement */: - case 207 /* WithStatement */: + case 199 /* IfStatement */: + case 209 /* SwitchStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 201 /* WhileStatement */: + case 212 /* TryStatement */: + case 200 /* DoStatement */: + case 208 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 246 /* CatchClause */: + case 247 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 167 /* ObjectLiteralExpression */; + return context.contextNode.kind === 168 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 170 /* CallExpression */; + return context.contextNode.kind === 171 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 171 /* NewExpression */; + return context.contextNode.kind === 172 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -43253,7 +43800,7 @@ var ts; return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 176 /* ArrowFunction */; + return context.contextNode.kind === 177 /* ArrowFunction */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -43271,41 +43818,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 139 /* Decorator */; + return node.kind === 140 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 214 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 215 /* 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 === 220 /* ModuleDeclaration */; + return context.contextNode.kind === 221 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 156 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 151 /* TypeReference */: - case 173 /* TypeAssertionExpression */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 190 /* ExpressionWithTypeArguments */: + case 152 /* TypeReference */: + case 174 /* TypeAssertionExpression */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 191 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -43316,13 +43863,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 173 /* TypeAssertionExpression */; + return context.contextNode.kind === 174 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 179 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 180 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 186 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 187 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -43346,7 +43893,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 134 /* LastToken */ + 1; + this.mapRowLength = 135 /* 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); @@ -43541,7 +44088,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 135 /* LastToken */; token++) { result.push(token); } return result; @@ -43583,9 +44130,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 135 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 135 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); @@ -43815,17 +44362,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 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 194 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 250 /* SourceFile */: - case 194 /* Block */: - case 221 /* ModuleBlock */: + return body && body.kind === 195 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 251 /* SourceFile */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -44027,19 +44574,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 216 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 217 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 215 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 219 /* EnumDeclaration */: return 219 /* EnumDeclaration */; - case 145 /* GetAccessor */: return 123 /* GetKeyword */; - case 146 /* SetAccessor */: return 129 /* SetKeyword */; - case 143 /* MethodDeclaration */: + case 217 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 218 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 216 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 220 /* EnumDeclaration */: return 220 /* EnumDeclaration */; + case 146 /* GetAccessor */: return 123 /* GetKeyword */; + case 147 /* SetAccessor */: return 129 /* SetKeyword */; + case 144 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: + case 142 /* PropertyDeclaration */: + case 139 /* Parameter */: return node.name.kind; } } @@ -44179,7 +44726,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 140 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -44523,20 +45070,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 194 /* Block */: - case 221 /* ModuleBlock */: + case 195 /* Block */: + case 222 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 144 /* Constructor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 176 /* ArrowFunction */: + case 145 /* Constructor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 177 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -44544,8 +45091,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -44553,7 +45100,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 151 /* TypeReference */: + case 152 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -44669,7 +45216,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 183 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 184 /* 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 */) { @@ -44788,7 +45335,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.isStatement(current)) && - (parent.kind === 250 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 251 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -44821,7 +45368,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 198 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 199 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -44833,23 +45380,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 151 /* TypeReference */: + case 152 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 167 /* ObjectLiteralExpression */: + case 168 /* ObjectLiteralExpression */: return node.parent.properties; - case 166 /* ArrayLiteralExpression */: + case 167 /* ArrayLiteralExpression */: return node.parent.elements; - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: { + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -44860,8 +45407,8 @@ var ts; } break; } - case 171 /* NewExpression */: - case 170 /* CallExpression */: { + case 172 /* NewExpression */: + case 171 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -44891,8 +45438,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 170 /* CallExpression */ || - node.parent.kind === 171 /* NewExpression */) && + if (node.parent && (node.parent.kind === 171 /* CallExpression */ || + node.parent.kind === 172 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -44910,10 +45457,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 168 /* PropertyAccessExpression */: - case 169 /* ElementAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 169 /* PropertyAccessExpression */: + case 170 /* ElementAccessExpression */: node = node.expression; break; default: @@ -44977,45 +45524,45 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 197 /* ExpressionStatement */: - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 166 /* ArrayLiteralExpression */: - case 194 /* Block */: - case 221 /* ModuleBlock */: - case 167 /* ObjectLiteralExpression */: - case 155 /* TypeLiteral */: - case 157 /* TupleType */: - case 222 /* CaseBlock */: - case 244 /* DefaultClause */: - case 243 /* CaseClause */: - case 174 /* ParenthesizedExpression */: - case 168 /* PropertyAccessExpression */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: - case 195 /* VariableStatement */: - case 213 /* VariableDeclaration */: - case 229 /* ExportAssignment */: - case 206 /* ReturnStatement */: - case 184 /* ConditionalExpression */: - case 164 /* ArrayBindingPattern */: - case 163 /* ObjectBindingPattern */: - case 237 /* JsxOpeningElement */: - case 236 /* JsxSelfClosingElement */: - case 242 /* JsxExpression */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 138 /* Parameter */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 160 /* ParenthesizedType */: - case 172 /* TaggedTemplateExpression */: - case 180 /* AwaitExpression */: - case 227 /* NamedImports */: + case 198 /* ExpressionStatement */: + case 217 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 167 /* ArrayLiteralExpression */: + case 195 /* Block */: + case 222 /* ModuleBlock */: + case 168 /* ObjectLiteralExpression */: + case 156 /* TypeLiteral */: + case 158 /* TupleType */: + case 223 /* CaseBlock */: + case 245 /* DefaultClause */: + case 244 /* CaseClause */: + case 175 /* ParenthesizedExpression */: + case 169 /* PropertyAccessExpression */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 196 /* VariableStatement */: + case 214 /* VariableDeclaration */: + case 230 /* ExportAssignment */: + case 207 /* ReturnStatement */: + case 185 /* ConditionalExpression */: + case 165 /* ArrayBindingPattern */: + case 164 /* ObjectBindingPattern */: + case 238 /* JsxOpeningElement */: + case 237 /* JsxSelfClosingElement */: + case 243 /* JsxExpression */: + case 143 /* MethodSignature */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 139 /* Parameter */: + case 153 /* FunctionType */: + case 154 /* ConstructorType */: + case 161 /* ParenthesizedType */: + case 173 /* TaggedTemplateExpression */: + case 181 /* AwaitExpression */: + case 228 /* NamedImports */: return true; } return false; @@ -45024,22 +45571,22 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 199 /* DoStatement */: - case 200 /* WhileStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 201 /* ForStatement */: - case 198 /* IfStatement */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 176 /* ArrowFunction */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return childKind !== 194 /* Block */; - case 235 /* JsxElement */: - return childKind !== 239 /* JsxClosingElement */; + case 200 /* DoStatement */: + case 201 /* WhileStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 202 /* ForStatement */: + case 199 /* IfStatement */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 144 /* MethodDeclaration */: + case 177 /* ArrowFunction */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + return childKind !== 195 /* Block */; + case 236 /* JsxElement */: + return childKind !== 240 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -45191,7 +45738,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(273 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); + var list = createNode(274 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -45210,7 +45757,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 135 /* FirstNode */) { + if (this.kind >= 136 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -45257,7 +45804,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 136 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -45265,7 +45812,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 136 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -45314,7 +45861,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 139 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -45323,15 +45870,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 220 /* ModuleDeclaration */ && declaration.body.kind === 220 /* ModuleDeclaration */) { + if (declaration.kind === 221 /* ModuleDeclaration */ && declaration.body.kind === 221 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 220 /* ModuleDeclaration */ && declaration.parent.kind === 220 /* ModuleDeclaration */) { + while (declaration.kind === 221 /* ModuleDeclaration */ && declaration.parent.kind === 221 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 213 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -45676,9 +46223,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 136 /* ComputedPropertyName */) { + if (declaration.name.kind === 137 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 168 /* PropertyAccessExpression */) { + if (expr.kind === 169 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -45698,9 +46245,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -45720,60 +46267,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 219 /* EnumDeclaration */: - case 220 /* ModuleDeclaration */: - case 223 /* ImportEqualsDeclaration */: - case 232 /* ExportSpecifier */: - case 228 /* ImportSpecifier */: - case 223 /* ImportEqualsDeclaration */: - case 225 /* ImportClause */: - case 226 /* NamespaceImport */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 155 /* TypeLiteral */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 220 /* EnumDeclaration */: + case 221 /* ModuleDeclaration */: + case 224 /* ImportEqualsDeclaration */: + case 233 /* ExportSpecifier */: + case 229 /* ImportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 226 /* ImportClause */: + case 227 /* NamespaceImport */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 156 /* TypeLiteral */: addDeclaration(node); // fall through - case 144 /* Constructor */: - case 195 /* VariableStatement */: - case 214 /* VariableDeclarationList */: - case 163 /* ObjectBindingPattern */: - case 164 /* ArrayBindingPattern */: - case 221 /* ModuleBlock */: + case 145 /* Constructor */: + case 196 /* VariableStatement */: + case 215 /* VariableDeclarationList */: + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: + case 222 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 138 /* Parameter */: + case 139 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 56 /* AccessibilityModifier */)) { break; } // fall through - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 249 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 250 /* EnumMember */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: addDeclaration(node); break; - case 230 /* ExportDeclaration */: + case 231 /* 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 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -45785,7 +46332,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 226 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -45961,6 +46508,9 @@ var ts; ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; return ClassificationTypeNames; }()); ts.ClassificationTypeNames = ClassificationTypeNames; @@ -45986,6 +46536,9 @@ var ts; 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; function displayPartsToString(displayParts) { @@ -46001,16 +46554,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 175 /* FunctionExpression */) { + if (declaration.kind === 176 /* FunctionExpression */) { return true; } - if (declaration.kind !== 213 /* VariableDeclaration */ && declaration.kind !== 215 /* FunctionDeclaration */) { + if (declaration.kind !== 214 /* VariableDeclaration */ && declaration.kind !== 216 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_8.kind === 250 /* SourceFile */ || parent_8.kind === 221 /* ModuleBlock */) { + if (parent_9.kind === 251 /* SourceFile */ || parent_9.kind === 222 /* ModuleBlock */) { return false; } } @@ -46266,18 +46819,12 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames) { - return useCaseSensitivefileNames - ? (function (fileName) { return fileName; }) - : (function (fileName) { return fileName.toLowerCase(); }); - } - ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; - var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); + var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + +"|" + settings.allowJs; } @@ -46642,7 +47189,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 209 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 210 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -46651,12 +47198,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 69 /* Identifier */ && - (node.parent.kind === 205 /* BreakStatement */ || node.parent.kind === 204 /* ContinueStatement */) && + (node.parent.kind === 206 /* BreakStatement */ || node.parent.kind === 205 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 69 /* Identifier */ && - node.parent.kind === 209 /* LabeledStatement */ && + node.parent.kind === 210 /* LabeledStatement */ && node.parent.label === node; } /** @@ -46664,7 +47211,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 209 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 210 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -46675,25 +47222,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 168 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 170 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 171 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 220 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 221 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 69 /* Identifier */ && @@ -46702,22 +47249,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 247 /* PropertyAssignment */ || node.parent.kind === 248 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 248 /* PropertyAssignment */ || node.parent.kind === 249 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* PropertyAssignment */: - case 249 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 220 /* ModuleDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 248 /* PropertyAssignment */: + case 250 /* EnumMember */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 221 /* ModuleDeclaration */: return node.parent.name === node; - case 169 /* ElementAccessExpression */: + case 170 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -46776,7 +47323,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 135 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -46791,17 +47338,17 @@ var ts; return undefined; } switch (node.kind) { - case 250 /* SourceFile */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 219 /* EnumDeclaration */: - case 220 /* ModuleDeclaration */: + case 251 /* SourceFile */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 220 /* EnumDeclaration */: + case 221 /* ModuleDeclaration */: return node; } } @@ -46809,38 +47356,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 220 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 216 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 217 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 218 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 219 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 213 /* VariableDeclaration */: + case 221 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 217 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 218 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 219 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 220 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 214 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 215 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 216 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 146 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 147 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 249 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 223 /* ImportEqualsDeclaration */: - case 228 /* ImportSpecifier */: - case 225 /* ImportClause */: - case 232 /* ExportSpecifier */: - case 226 /* NamespaceImport */: + case 150 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 149 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 148 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 145 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 138 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 250 /* EnumMember */: return ScriptElementKind.variableElement; + case 139 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 224 /* ImportEqualsDeclaration */: + case 229 /* ImportSpecifier */: + case 226 /* ImportClause */: + case 233 /* ExportSpecifier */: + case 227 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -46878,7 +47425,7 @@ var ts; host.log(message); } } - var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -47152,9 +47699,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 271 /* JSDocTypeTag */: - case 269 /* JSDocParameterTag */: - case 270 /* JSDocReturnTag */: + case 272 /* JSDocTypeTag */: + case 270 /* JSDocParameterTag */: + case 271 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -47199,13 +47746,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_9 = contextToken.parent, kind = contextToken.kind; + var parent_10 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_9.kind === 168 /* PropertyAccessExpression */) { + if (parent_10.kind === 169 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 135 /* QualifiedName */) { + else if (parent_10.kind === 136 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -47220,8 +47767,9 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 239 /* JsxClosingElement */) { + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 240 /* JsxClosingElement */) { isStartingCloseTag = true; + location = contextToken; } } } @@ -47245,7 +47793,10 @@ var ts; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; - symbols = [typeChecker.getSymbolAtLocation(tagName)]; + var tagSymbol = typeChecker.getSymbolAtLocation(tagName); + if (!typeChecker.isUnknownSymbol(tagSymbol)) { + symbols = [tagSymbol]; + } isMemberCompletion = true; isNewIdentifierLocation = false; } @@ -47263,7 +47814,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 168 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -47319,7 +47870,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 236 /* JsxSelfClosingElement */) || (jsxContainer.kind === 237 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 237 /* JsxSelfClosingElement */) || (jsxContainer.kind === 238 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -47391,15 +47942,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 238 /* JsxText */) { + if (contextToken.kind === 239 /* JsxText */) { return true; } if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 237 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 238 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 239 /* JsxClosingElement */ || contextToken.parent.kind === 236 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 235 /* JsxElement */; + if (contextToken.parent.kind === 240 /* JsxClosingElement */ || contextToken.parent.kind === 237 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 236 /* JsxElement */; } } return false; @@ -47409,40 +47960,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 170 /* CallExpression */ // func( a, | - || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 171 /* NewExpression */ // new C(a, | - || containingNodeKind === 166 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 183 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 171 /* CallExpression */ // func( a, | + || containingNodeKind === 145 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 172 /* NewExpression */ // new C(a, | + || containingNodeKind === 167 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 184 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 153 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 170 /* CallExpression */ // func( | - || containingNodeKind === 144 /* Constructor */ // constructor( | - || containingNodeKind === 171 /* NewExpression */ // new C(a| - || containingNodeKind === 174 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 171 /* CallExpression */ // func( | + || containingNodeKind === 145 /* Constructor */ // constructor( | + || containingNodeKind === 172 /* NewExpression */ // new C(a| + || containingNodeKind === 175 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 161 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 166 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 167 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 150 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 137 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 125 /* ModuleKeyword */: // module | case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 220 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 221 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 216 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 217 /* ClassDeclaration */; // class A{ | case 56 /* EqualsToken */: - return containingNodeKind === 213 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 183 /* BinaryExpression */; // x = a| + return containingNodeKind === 214 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 184 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 185 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 186 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 192 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 193 /* TemplateSpan */; // `aa ${10} dd ${| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 142 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -47456,7 +48007,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 162 /* StringLiteralType */ + || contextToken.kind === 163 /* StringLiteralType */ || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_7 = contextToken.getStart(); @@ -47486,14 +48037,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 167 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 168 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 163 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 164 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -47539,9 +48090,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 227 /* NamedImports */ ? - 224 /* ImportDeclaration */ : - 230 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 228 /* NamedImports */ ? + 225 /* ImportDeclaration */ : + 231 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -47566,9 +48117,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 167 /* ObjectLiteralExpression */ || parent_10.kind === 163 /* ObjectBindingPattern */)) { - return parent_10; + var parent_11 = contextToken.parent; + if (parent_11 && (parent_11.kind === 168 /* ObjectLiteralExpression */ || parent_11.kind === 164 /* ObjectBindingPattern */)) { + return parent_11; } break; } @@ -47585,8 +48136,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 227 /* NamedImports */: - case 231 /* NamedExports */: + case 228 /* NamedImports */: + case 232 /* NamedExports */: return contextToken.parent; } } @@ -47595,37 +48146,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_11 = contextToken.parent; + var parent_12 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: - case 240 /* JsxAttribute */: - case 241 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 236 /* JsxSelfClosingElement */ || parent_11.kind === 237 /* JsxOpeningElement */)) { - return parent_11; + case 241 /* JsxAttribute */: + case 242 /* JsxSpreadAttribute */: + if (parent_12 && (parent_12.kind === 237 /* JsxSelfClosingElement */ || parent_12.kind === 238 /* JsxOpeningElement */)) { + return parent_12; } - else if (parent_11.kind === 240 /* JsxAttribute */) { - return parent_11.parent; + else if (parent_12.kind === 241 /* JsxAttribute */) { + return parent_12.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_11 && ((parent_11.kind === 240 /* JsxAttribute */) || (parent_11.kind === 241 /* JsxSpreadAttribute */))) { - return parent_11.parent; + if (parent_12 && ((parent_12.kind === 241 /* JsxAttribute */) || (parent_12.kind === 242 /* JsxSpreadAttribute */))) { + return parent_12.parent; } break; case 16 /* CloseBraceToken */: - if (parent_11 && - parent_11.kind === 242 /* JsxExpression */ && - parent_11.parent && - (parent_11.parent.kind === 240 /* JsxAttribute */)) { - return parent_11.parent.parent; + if (parent_12 && + parent_12.kind === 243 /* JsxExpression */ && + parent_12.parent && + (parent_12.parent.kind === 241 /* JsxAttribute */)) { + return parent_12.parent.parent; } - if (parent_11 && parent_11.kind === 241 /* JsxSpreadAttribute */) { - return parent_11.parent; + if (parent_12 && parent_12.kind === 242 /* JsxSpreadAttribute */) { + return parent_12.parent; } break; } @@ -47634,16 +48185,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 148 /* CallSignature */: + case 149 /* ConstructSignature */: + case 150 /* IndexSignature */: return true; } return false; @@ -47655,54 +48206,54 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 213 /* VariableDeclaration */ || - containingNodeKind === 214 /* VariableDeclarationList */ || - containingNodeKind === 195 /* VariableStatement */ || - containingNodeKind === 219 /* EnumDeclaration */ || + return containingNodeKind === 214 /* VariableDeclaration */ || + containingNodeKind === 215 /* VariableDeclarationList */ || + containingNodeKind === 196 /* VariableStatement */ || + containingNodeKind === 220 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 216 /* ClassDeclaration */ || - containingNodeKind === 188 /* ClassExpression */ || - containingNodeKind === 217 /* InterfaceDeclaration */ || - containingNodeKind === 164 /* ArrayBindingPattern */ || - containingNodeKind === 218 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 217 /* ClassDeclaration */ || + containingNodeKind === 189 /* ClassExpression */ || + containingNodeKind === 218 /* InterfaceDeclaration */ || + containingNodeKind === 165 /* ArrayBindingPattern */ || + containingNodeKind === 219 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 164 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 165 /* ArrayBindingPattern */; // var [.| case 54 /* ColonToken */: - return containingNodeKind === 165 /* BindingElement */; // var {x :html| + return containingNodeKind === 166 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 164 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 165 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 246 /* CatchClause */ || + return containingNodeKind === 247 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 219 /* EnumDeclaration */ || - containingNodeKind === 217 /* InterfaceDeclaration */ || - containingNodeKind === 155 /* TypeLiteral */; // const x : { | + return containingNodeKind === 220 /* EnumDeclaration */ || + containingNodeKind === 218 /* InterfaceDeclaration */ || + containingNodeKind === 156 /* TypeLiteral */; // const x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 140 /* PropertySignature */ && + return containingNodeKind === 141 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 217 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 155 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 218 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 156 /* TypeLiteral */); // const x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 216 /* ClassDeclaration */ || - containingNodeKind === 188 /* ClassExpression */ || - containingNodeKind === 217 /* InterfaceDeclaration */ || - containingNodeKind === 218 /* TypeAliasDeclaration */ || + return containingNodeKind === 217 /* ClassDeclaration */ || + containingNodeKind === 189 /* ClassExpression */ || + containingNodeKind === 218 /* InterfaceDeclaration */ || + containingNodeKind === 219 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 113 /* StaticKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; + return containingNodeKind === 142 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 138 /* Parameter */ || + return containingNodeKind === 139 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 164 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 165 /* ArrayBindingPattern */); // var [...z| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 138 /* Parameter */; + return containingNodeKind === 139 /* Parameter */; case 116 /* AsKeyword */: - return containingNodeKind === 228 /* ImportSpecifier */ || - containingNodeKind === 232 /* ExportSpecifier */ || - containingNodeKind === 226 /* NamespaceImport */; + return containingNodeKind === 229 /* ImportSpecifier */ || + containingNodeKind === 233 /* ExportSpecifier */ || + containingNodeKind === 227 /* NamespaceImport */; case 73 /* ClassKeyword */: case 81 /* EnumKeyword */: case 107 /* InterfaceKeyword */: @@ -47762,8 +48313,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_34 = element.propertyName || element.name; + exisingImportsOrExports[name_34.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -47784,10 +48335,10 @@ 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 !== 247 /* PropertyAssignment */ && - m.kind !== 248 /* ShorthandPropertyAssignment */ && - m.kind !== 165 /* BindingElement */ && - m.kind !== 143 /* MethodDeclaration */) { + if (m.kind !== 248 /* PropertyAssignment */ && + m.kind !== 249 /* ShorthandPropertyAssignment */ && + m.kind !== 166 /* BindingElement */ && + m.kind !== 144 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -47795,7 +48346,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 165 /* BindingElement */ && m.propertyName) { + if (m.kind === 166 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 69 /* Identifier */) { existingName = m.propertyName.text; @@ -47825,7 +48376,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 240 /* JsxAttribute */) { + if (attr.kind === 241 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -47851,7 +48402,23 @@ var ts; } else { if (!symbols || symbols.length === 0) { - return undefined; + if (sourceFile.languageVariant === 1 /* JSX */ && + location.parent && location.parent.kind === 240 /* 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: + // var x =
completion list at "1" will contain "div" with type any + var tagName = location.parent.parent.openingElement.tagName; + entries.push({ + name: tagName.text, + kind: undefined, + kindModifiers: undefined, + sortText: "0" + }); + } + else { + return undefined; + } } getCompletionEntriesFromSymbols(symbols, entries); } @@ -47864,10 +48431,10 @@ var ts; var entries = []; var target = program.getCompilerOptions().target; var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!uniqueNames[name_32]) { - uniqueNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks*/ true); + for (var name_35 in nameTable) { + if (!uniqueNames[name_35]) { + uniqueNames[name_35] = name_35; + var displayName = getCompletionEntryDisplayName(name_35, target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -47973,7 +48540,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 188 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -48075,7 +48642,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 168 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 169 /* 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)) { @@ -48084,7 +48651,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 170 /* CallExpression */ || location.kind === 171 /* NewExpression */) { + if (location.kind === 171 /* CallExpression */ || location.kind === 172 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -48097,7 +48664,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 171 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 172 /* NewExpression */ || callExpression.expression.kind === 95 /* 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 @@ -48150,24 +48717,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 145 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 145 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 144 /* Constructor */) { + if (functionDeclaration.kind === 145 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -48176,7 +48743,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 188 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 189 /* 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 @@ -48220,7 +48787,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 220 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 221 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -48243,17 +48810,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 148 /* ConstructSignature */) { + if (declaration.kind === 149 /* ConstructSignature */) { displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 147 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 148 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -48273,7 +48840,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 249 /* EnumMember */) { + if (declaration.kind === 250 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -48289,7 +48856,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 223 /* ImportEqualsDeclaration */) { + if (declaration.kind === 224 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -48418,14 +48985,14 @@ var ts; } var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { + if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { case 69 /* Identifier */: - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: case 97 /* ThisKeyword */: - case 161 /* ThisType */: + case 162 /* ThisType */: case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -48504,8 +49071,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 144 /* Constructor */) || - (!selectConstructors && (d.kind === 215 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 145 /* Constructor */) || + (!selectConstructors && (d.kind === 216 /* FunctionDeclaration */ || d.kind === 144 /* MethodDeclaration */ || d.kind === 143 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -48574,7 +49141,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 === 248 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 249 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -48650,7 +49217,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || - node.kind === 161 /* ThisType */ || + node.kind === 162 /* ThisType */ || node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -48704,75 +49271,75 @@ var ts; switch (node.kind) { case 88 /* IfKeyword */: case 80 /* ElseKeyword */: - if (hasKind(node.parent, 198 /* IfStatement */)) { + if (hasKind(node.parent, 199 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 206 /* ReturnStatement */)) { + if (hasKind(node.parent, 207 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 210 /* ThrowStatement */)) { + if (hasKind(node.parent, 211 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 211 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 212 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 100 /* TryKeyword */: case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 211 /* TryStatement */)) { + if (hasKind(parent(node), 212 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 208 /* SwitchStatement */)) { + if (hasKind(node.parent, 209 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 71 /* CaseKeyword */: case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 208 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 209 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 70 /* BreakKeyword */: case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 205 /* BreakStatement */) || hasKind(node.parent, 204 /* ContinueStatement */)) { + if (hasKind(node.parent, 206 /* BreakStatement */) || hasKind(node.parent, 205 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 86 /* ForKeyword */: - if (hasKind(node.parent, 201 /* ForStatement */) || - hasKind(node.parent, 202 /* ForInStatement */) || - hasKind(node.parent, 203 /* ForOfStatement */)) { + if (hasKind(node.parent, 202 /* ForStatement */) || + hasKind(node.parent, 203 /* ForInStatement */) || + hasKind(node.parent, 204 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 104 /* WhileKeyword */: case 79 /* DoKeyword */: - if (hasKind(node.parent, 200 /* WhileStatement */) || hasKind(node.parent, 199 /* DoStatement */)) { + if (hasKind(node.parent, 201 /* WhileStatement */) || hasKind(node.parent, 200 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 144 /* Constructor */)) { + if (hasKind(node.parent, 145 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 123 /* GetKeyword */: case 129 /* SetKeyword */: - if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { + if (hasKind(node.parent, 146 /* GetAccessor */) || hasKind(node.parent, 147 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 195 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 196 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -48788,10 +49355,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 /* ThrowStatement */) { + if (node.kind === 211 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 211 /* TryStatement */) { + else if (node.kind === 212 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -48818,19 +49385,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 250 /* SourceFile */) { - return parent_12; + var parent_13 = child.parent; + if (ts.isFunctionBlock(parent_13) || parent_13.kind === 251 /* SourceFile */) { + return parent_13; } // 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_12.kind === 211 /* TryStatement */) { - var tryStatement = parent_12; + if (parent_13.kind === 212 /* TryStatement */) { + var tryStatement = parent_13; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_12; + child = parent_13; } return undefined; } @@ -48839,7 +49406,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* BreakStatement */ || node.kind === 204 /* ContinueStatement */) { + if (node.kind === 206 /* BreakStatement */ || node.kind === 205 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -48854,16 +49421,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 208 /* SwitchStatement */: - if (statement.kind === 204 /* ContinueStatement */) { + case 209 /* SwitchStatement */: + if (statement.kind === 205 /* ContinueStatement */) { continue; } // Fall through. - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 200 /* WhileStatement */: - case 199 /* DoStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 201 /* WhileStatement */: + case 200 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -48882,24 +49449,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 === 216 /* ClassDeclaration */ || - container.kind === 188 /* ClassExpression */ || - (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { + if (!(container.kind === 217 /* ClassDeclaration */ || + container.kind === 189 /* ClassExpression */ || + (declaration.kind === 139 /* Parameter */ && hasKind(container, 145 /* Constructor */)))) { return undefined; } } else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 216 /* ClassDeclaration */ || container.kind === 188 /* ClassExpression */)) { + if (!(container.kind === 217 /* ClassDeclaration */ || container.kind === 189 /* ClassExpression */)) { return undefined; } } else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 221 /* ModuleBlock */ || container.kind === 250 /* SourceFile */)) { + if (!(container.kind === 222 /* ModuleBlock */ || container.kind === 251 /* SourceFile */)) { return undefined; } } else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 216 /* ClassDeclaration */ || declaration.kind === 216 /* ClassDeclaration */)) { + if (!(container.kind === 217 /* ClassDeclaration */ || declaration.kind === 217 /* ClassDeclaration */)) { return undefined; } } @@ -48911,8 +49478,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 221 /* ModuleBlock */: - case 250 /* SourceFile */: + case 222 /* ModuleBlock */: + case 251 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -48921,17 +49488,17 @@ var ts; nodes = container.statements; } break; - case 144 /* Constructor */: + case 145 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 216 /* ClassDeclaration */: - case 188 /* ClassExpression */: + case 217 /* ClassDeclaration */: + case 189 /* 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 & 56 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 144 /* Constructor */ && member; + return member.kind === 145 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -48984,8 +49551,8 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); @@ -49008,7 +49575,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 199 /* DoStatement */) { + if (loopNode.kind === 200 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { @@ -49029,13 +49596,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 201 /* ForStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - case 199 /* DoStatement */: - case 200 /* WhileStatement */: + case 202 /* ForStatement */: + case 203 /* ForInStatement */: + case 204 /* ForOfStatement */: + case 200 /* DoStatement */: + case 201 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 208 /* SwitchStatement */: + case 209 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -49089,7 +49656,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, 194 /* Block */))) { + if (!(func && hasKind(func.body, 195 /* Block */))) { return undefined; } var keywords = []; @@ -49105,7 +49672,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 198 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 199 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -49118,7 +49685,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 198 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 199 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -49235,7 +49802,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 /* ThisKeyword */ || node.kind === 161 /* ThisType */) { + if (node.kind === 97 /* ThisKeyword */ || node.kind === 162 /* ThisType */) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95 /* SuperKeyword */) { @@ -49296,10 +49863,8 @@ var ts; textSpan: ts.createTextSpan(declarations[0].getStart(), 0) }; } - function isImportOrExportSpecifierImportSymbol(symbol) { - return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 228 /* ImportSpecifier */ || declaration.kind === 232 /* ExportSpecifier */; - }); + function isImportSpecifierSymbol(symbol) { + return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 229 /* ImportSpecifier */); } function getInternedName(symbol, location, declarations) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. @@ -49325,14 +49890,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 === 175 /* FunctionExpression */ || valueDeclaration.kind === 188 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 176 /* FunctionExpression */ || valueDeclaration.kind === 189 /* 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 (d.flags & 16 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 216 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 217 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -49358,7 +49923,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 250 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 251 /* 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; @@ -49531,13 +50096,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -49569,27 +50134,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 250 /* SourceFile */: + case 251 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 176 /* 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. @@ -49598,7 +50163,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 250 /* SourceFile */) { + if (searchSpaceNode.kind === 251 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -49624,33 +50189,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 161 /* ThisType */)) { + if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 162 /* ThisType */)) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 188 /* ClassExpression */: - case 216 /* ClassDeclaration */: + case 189 /* ClassExpression */: + case 217 /* 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 && (container.flags & 64 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 250 /* SourceFile */: - if (container.kind === 250 /* SourceFile */ && !ts.isExternalModule(container)) { + case 251 /* SourceFile */: + if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -49662,9 +50227,17 @@ var ts; // The search set contains at least the current symbol var result = [symbol]; // If the symbol is an alias, add what it alaises to the list - if (isImportOrExportSpecifierImportSymbol(symbol)) { + if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } + // For export specifiers, the exported name can be refering to a local symbol, e.g.: + // import {a} from "mod"; + // export {a as somethingElse} + // We want the *local* declaration of 'a' as declared in the import, + // *not* as declared within "mod" (or farther) + if (location.parent.kind === 233 /* ExportSpecifier */) { + result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent)); + } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set @@ -49692,7 +50265,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 contructor.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 === 138 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -49704,19 +50277,44 @@ var ts; } // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {}); } }); return result; } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to serach for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (ts.hasProperty(previousIterationSymbolsCache, symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 216 /* ClassDeclaration */) { + if (declaration.kind === 217 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 217 /* InterfaceDeclaration */) { + else if (declaration.kind === 218 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -49731,7 +50329,8 @@ var ts; result.push(propertySymbol); } // Visit the typeReference as well to see if it directly or indirectly use that property - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); + previousIterationSymbolsCache[symbol.name] = symbol; + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); } } } @@ -49742,12 +50341,22 @@ var ts; } // If the reference symbol is an alias, check if what it is aliasing is one of the search // symbols. - if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + if (isImportSpecifierSymbol(referenceSymbol)) { var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; } } + // For export specifiers, it can be a local symbol, e.g. + // import {a} from "mod"; + // export {a as somethingElse} + // We want the local target of the export (i.e. the import symbol) and not the final target (i.e. "mod".a) + if (referenceLocation.parent.kind === 233 /* ExportSpecifier */) { + var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } + } // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol @@ -49767,7 +50376,7 @@ var ts; // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, /*previousIterationSymbolsCache*/ {}); return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; @@ -49777,19 +50386,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_36 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_36); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_36); if (symbol) { result_4.push(symbol); } @@ -49798,7 +50407,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_36); if (symbol_1) { return [symbol_1]; } @@ -49856,10 +50465,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 182 /* PostfixUnaryExpression */ || parent.kind === 181 /* PrefixUnaryExpression */) { + if (parent.kind === 183 /* PostfixUnaryExpression */ || parent.kind === 182 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 183 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 184 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } @@ -49890,34 +50499,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 138 /* Parameter */: - case 213 /* VariableDeclaration */: - case 165 /* BindingElement */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* PropertyAssignment */: - case 248 /* ShorthandPropertyAssignment */: - case 249 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 215 /* FunctionDeclaration */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: - case 246 /* CatchClause */: + case 139 /* Parameter */: + case 214 /* VariableDeclaration */: + case 166 /* BindingElement */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: + case 248 /* PropertyAssignment */: + case 249 /* ShorthandPropertyAssignment */: + case 250 /* EnumMember */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 145 /* Constructor */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 216 /* FunctionDeclaration */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: + case 247 /* CatchClause */: return 1 /* Value */; - case 137 /* TypeParameter */: - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: - case 155 /* TypeLiteral */: + case 138 /* TypeParameter */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: + case 156 /* TypeLiteral */: return 2 /* Type */; - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 220 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */) { + case 221 /* ModuleDeclaration */: + if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -49926,15 +50535,15 @@ var ts; else { return 4 /* Namespace */; } - case 227 /* NamedImports */: - case 228 /* ImportSpecifier */: - case 223 /* ImportEqualsDeclaration */: - case 224 /* ImportDeclaration */: - case 229 /* ExportAssignment */: - case 230 /* ExportDeclaration */: + case 228 /* NamedImports */: + case 229 /* ImportSpecifier */: + case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportDeclaration */: + case 230 /* ExportAssignment */: + case 231 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 250 /* SourceFile */: + case 251 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -49943,10 +50552,10 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 151 /* TypeReference */ || - (node.parent.kind === 190 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 152 /* TypeReference */ || + (node.parent.kind === 191 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node)) || - node.kind === 161 /* ThisType */; + node.kind === 162 /* ThisType */; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -49954,32 +50563,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 168 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 168 /* PropertyAccessExpression */) { + if (root.parent.kind === 169 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 169 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 190 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 245 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 191 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 246 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 216 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 217 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 217 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 218 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 135 /* QualifiedName */) { - while (root.parent && root.parent.kind === 135 /* QualifiedName */) { + if (root.parent.kind === 136 /* QualifiedName */) { + while (root.parent && root.parent.kind === 136 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 151 /* TypeReference */ && !isLastClause; + return root.parent.kind === 152 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 135 /* QualifiedName */) { + while (node.parent.kind === 136 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49989,15 +50598,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 135 /* QualifiedName */ && + if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 223 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 224 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 229 /* ExportAssignment */) { + if (node.parent.kind === 230 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -50037,16 +50646,16 @@ var ts; return; } switch (node.kind) { - case 168 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: + case 169 /* PropertyAccessExpression */: + case 136 /* QualifiedName */: case 9 /* StringLiteral */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: case 84 /* FalseKeyword */: case 99 /* TrueKeyword */: case 93 /* NullKeyword */: case 95 /* SuperKeyword */: case 97 /* ThisKeyword */: - case 161 /* ThisType */: + case 162 /* ThisType */: case 69 /* Identifier */: break; // Cant create the text span @@ -50063,7 +50672,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 === 220 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 221 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -50104,10 +50713,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 220 /* ModuleDeclaration */: - case 216 /* ClassDeclaration */: - case 217 /* InterfaceDeclaration */: - case 215 /* FunctionDeclaration */: + case 221 /* ModuleDeclaration */: + case 217 /* ClassDeclaration */: + case 218 /* InterfaceDeclaration */: + case 216 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -50161,7 +50770,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 220 /* ModuleDeclaration */ && + return declaration.kind === 221 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -50212,6 +50821,9 @@ var ts; case 19 /* jsxOpenTagName */: return ClassificationTypeNames.jsxOpenTagName; case 20 /* jsxCloseTagName */: return ClassificationTypeNames.jsxCloseTagName; case 21 /* jsxSelfClosingTagName */: return ClassificationTypeNames.jsxSelfClosingTagName; + case 22 /* jsxAttribute */: return ClassificationTypeNames.jsxAttribute; + case 23 /* jsxText */: return ClassificationTypeNames.jsxText; + case 24 /* jsxAttributeStringLiteralValue */: return ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -50319,16 +50931,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 269 /* JSDocParameterTag */: + case 270 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 272 /* JSDocTemplateTag */: + case 273 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 271 /* JSDocTypeTag */: + case 272 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 270 /* JSDocReturnTag */: + case 271 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -50365,7 +50977,8 @@ var ts; function classifyDisabledMergeCode(text, start, end) { // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. - for (var i = start; i < end; i++) { + var i; + for (i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { break; } @@ -50385,11 +50998,11 @@ var ts; pushClassification(start, end - start, type); } } - function classifyToken(token) { + function classifyTokenOrJsxText(token) { if (ts.nodeIsMissing(token)) { return; } - var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenStart = token.kind === 239 /* JsxText */ ? token.pos : classifyLeadingTriviaAndGetTokenStart(token); var tokenWidth = token.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -50419,16 +51032,17 @@ var ts; if (token) { if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 213 /* VariableDeclaration */ || - token.parent.kind === 141 /* PropertyDeclaration */ || - token.parent.kind === 138 /* Parameter */) { + if (token.parent.kind === 214 /* VariableDeclaration */ || + token.parent.kind === 142 /* PropertyDeclaration */ || + token.parent.kind === 139 /* Parameter */ || + token.parent.kind === 241 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 183 /* BinaryExpression */ || - token.parent.kind === 181 /* PrefixUnaryExpression */ || - token.parent.kind === 182 /* PostfixUnaryExpression */ || - token.parent.kind === 184 /* ConditionalExpression */) { + if (token.parent.kind === 184 /* BinaryExpression */ || + token.parent.kind === 182 /* PrefixUnaryExpression */ || + token.parent.kind === 183 /* PostfixUnaryExpression */ || + token.parent.kind === 185 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -50437,8 +51051,8 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 162 /* StringLiteralType */) { - return 6 /* stringLiteral */; + else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 163 /* StringLiteralType */) { + return token.parent.kind === 241 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -50448,54 +51062,61 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } + else if (tokenKind === 239 /* JsxText */) { + return 23 /* jsxText */; + } else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 137 /* TypeParameter */: + case 138 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 217 /* InterfaceDeclaration */: + case 218 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 138 /* Parameter */: + case 139 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } return; - case 237 /* JsxOpeningElement */: + case 238 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } return; - case 239 /* JsxClosingElement */: + case 240 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } return; - case 236 /* JsxSelfClosingElement */: + case 237 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } return; + case 241 /* JsxAttribute */: + if (token.parent.name === token) { + return 22 /* jsxAttribute */; + } } } return 2 /* identifier */; @@ -50511,8 +51132,8 @@ var ts; var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; - if (ts.isToken(child)) { - classifyToken(child); + if (ts.isToken(child) || child.kind === 239 /* JsxText */) { + classifyTokenOrJsxText(child); } else { // Recurse into our child nodes. @@ -50638,19 +51259,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 144 /* Constructor */: - case 216 /* ClassDeclaration */: - case 195 /* VariableStatement */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 145 /* Constructor */: + case 217 /* ClassDeclaration */: + case 196 /* VariableStatement */: break findOwner; - case 250 /* SourceFile */: + case 251 /* SourceFile */: return undefined; - case 220 /* ModuleDeclaration */: + case 221 /* 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 === 220 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 221 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -50692,7 +51313,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 195 /* VariableStatement */) { + if (commentOwner.kind === 196 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -50710,17 +51331,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 174 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 175 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return rightHandSide.parameters; - case 188 /* ClassExpression */: + case 189 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 144 /* Constructor */) { + if (member.kind === 145 /* Constructor */) { return member.parameters; } } @@ -50974,7 +51595,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 === 234 /* ExternalModuleReference */ || + node.parent.kind === 235 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -50987,7 +51608,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 169 /* ElementAccessExpression */ && + node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -51246,7 +51867,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 9 /* StringLiteral */ || token === 162 /* StringLiteralType */) { + if (token === 9 /* StringLiteral */ || token === 163 /* StringLiteralType */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -51369,7 +51990,7 @@ var ts; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 135 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -51385,7 +52006,7 @@ var ts; case 8 /* NumericLiteral */: return 4 /* numericLiteral */; case 9 /* StringLiteral */: - case 162 /* StringLiteralType */: + case 163 /* StringLiteralType */: return 6 /* stringLiteral */; case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; @@ -51476,6 +52097,9 @@ var ts; startNode.getStart(sourceFile); return ts.createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } + function textSpanEndingAtNextToken(startNode, previousTokenToFindNextEndToken) { + return textSpan(startNode, ts.findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent)); + } function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { return spanInNode(node); @@ -51493,132 +52117,114 @@ var ts; } function spanInNode(node) { if (node) { - if (ts.isExpression(node)) { - if (node.parent.kind === 199 /* DoStatement */) { - // Set span as if on while keyword - return spanInPreviousNode(node); - } - if (node.parent.kind === 139 /* Decorator */) { - // Set breakpoint on the decorator emit - return spanInNode(node.parent); - } - if (node.parent.kind === 201 /* ForStatement */) { - // For now lets set the span on this expression, fix it later - return textSpan(node); - } - if (node.parent.kind === 183 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { - // if this is comma expression, the breakpoint is possible in this expression - return textSpan(node); - } - if (node.parent.kind === 176 /* ArrowFunction */ && node.parent.body === node) { - // If this is body of arrow function, it is allowed to have the breakpoint - return textSpan(node); - } - } switch (node.kind) { - case 195 /* VariableStatement */: + case 196 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 213 /* VariableDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: + case 214 /* VariableDeclaration */: + case 142 /* PropertyDeclaration */: + case 141 /* PropertySignature */: return spanInVariableDeclaration(node); - case 138 /* Parameter */: + case 139 /* Parameter */: return spanInParameterDeclaration(node); - case 215 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 175 /* FunctionExpression */: - case 176 /* ArrowFunction */: + case 216 /* FunctionDeclaration */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 145 /* Constructor */: + case 176 /* FunctionExpression */: + case 177 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 221 /* ModuleBlock */: + case 222 /* ModuleBlock */: return spanInBlock(node); - case 246 /* CatchClause */: + case 247 /* CatchClause */: return spanInBlock(node.block); - case 197 /* ExpressionStatement */: + case 198 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 206 /* ReturnStatement */: + case 207 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 200 /* WhileStatement */: + case 201 /* WhileStatement */: // Span on while(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 199 /* DoStatement */: + return textSpanEndingAtNextToken(node, node.expression); + case 200 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 212 /* DebuggerStatement */: + case 213 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 198 /* IfStatement */: + case 199 /* IfStatement */: // set on if(..) span - return textSpan(node, ts.findNextToken(node.expression, node)); - case 209 /* LabeledStatement */: + return textSpanEndingAtNextToken(node, node.expression); + case 210 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 205 /* BreakStatement */: - case 204 /* ContinueStatement */: + case 206 /* BreakStatement */: + case 205 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 201 /* ForStatement */: + case 202 /* ForStatement */: return spanInForStatement(node); - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: - // span on for (a in ...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 208 /* SwitchStatement */: + case 203 /* ForInStatement */: + // span of for (a in ...) + return textSpanEndingAtNextToken(node, node.expression); + case 204 /* ForOfStatement */: + // span in initializer + return spanInInitializerOfForLike(node); + case 209 /* SwitchStatement */: // span on switch(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 243 /* CaseClause */: - case 244 /* DefaultClause */: + return textSpanEndingAtNextToken(node, node.expression); + case 244 /* CaseClause */: + case 245 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 211 /* TryStatement */: + case 212 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 210 /* ThrowStatement */: + case 211 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 229 /* ExportAssignment */: + case 230 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 223 /* ImportEqualsDeclaration */: + case 224 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 224 /* ImportDeclaration */: + case 225 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ExportDeclaration */: + case 231 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 216 /* ClassDeclaration */: - case 219 /* EnumDeclaration */: - case 249 /* EnumMember */: - case 170 /* CallExpression */: - case 171 /* NewExpression */: + case 217 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 250 /* EnumMember */: + case 166 /* BindingElement */: // span on complete node return textSpan(node); - case 207 /* WithStatement */: + case 208 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 139 /* Decorator */: + case 140 /* Decorator */: return spanInNodeArray(node.parent.decorators); + case 164 /* ObjectBindingPattern */: + case 165 /* ArrayBindingPattern */: + return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 217 /* InterfaceDeclaration */: - case 218 /* TypeAliasDeclaration */: + case 218 /* InterfaceDeclaration */: + case 219 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -51630,6 +52236,8 @@ var ts; return spanInOpenBraceToken(node); case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); + case 20 /* CloseBracketToken */: + return spanInCloseBracketToken(node); case 17 /* OpenParenToken */: return spanInOpenParenToken(node); case 18 /* CloseParenToken */: @@ -51646,58 +52254,142 @@ var ts; case 72 /* CatchKeyword */: case 85 /* FinallyKeyword */: return spanInNextNode(node); + case 135 /* OfKeyword */: + return spanInOfKeyword(node); default: + // Destructuring pattern in destructuring assignment + // [a, b, c] of + // [a, b, c] = expression + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); + } + // Set breakpoint on identifier element of destructuring pattern + // a or ...c or d: x from + // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern + if ((node.kind === 69 /* Identifier */ || + node.kind == 188 /* SpreadElementExpression */ || + node.kind === 248 /* PropertyAssignment */ || + node.kind === 249 /* ShorthandPropertyAssignment */) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + return textSpan(node); + } + if (node.kind === 184 /* BinaryExpression */) { + var binaryExpression = node; + // Set breakpoint in destructuring pattern if its destructuring assignment + // [a, b, c] or {a, b, c} of + // [a, b, c] = expression or + // {a, b, c} = expression + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); + } + if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { + // Set breakpoint on assignment expression element of destructuring pattern + // a = expression of + // [a = expression, b, c] = someExpression or + // { a = expression, b, c } = someExpression + return textSpan(node); + } + if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) { + return spanInNode(binaryExpression.left); + } + } + if (ts.isExpression(node)) { + switch (node.parent.kind) { + case 200 /* DoStatement */: + // Set span as if on while keyword + return spanInPreviousNode(node); + case 140 /* Decorator */: + // Set breakpoint on the decorator emit + return spanInNode(node.parent); + case 202 /* ForStatement */: + case 204 /* ForOfStatement */: + return textSpan(node); + case 184 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 24 /* CommaToken */) { + // if this is comma expression, the breakpoint is possible in this expression + return textSpan(node); + } + break; + case 177 /* ArrowFunction */: + if (node.parent.body === node) { + // If this is body of arrow function, it is allowed to have the breakpoint + return textSpan(node); + } + break; + } + } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 247 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 248 /* 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 === 173 /* TypeAssertionExpression */ && node.parent.type === node) { - return spanInNode(node.parent.expression); + if (node.parent.kind === 174 /* TypeAssertionExpression */ && node.parent.type === node) { + return spanInNextNode(node.parent.type); } // return type of function go to previous token if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } + // initializer of variable/parameter declaration go to previous node + if ((node.parent.kind === 214 /* VariableDeclaration */ || + node.parent.kind === 139 /* Parameter */)) { + var paramOrVarDecl = node.parent; + if (paramOrVarDecl.initializer === node || + paramOrVarDecl.type === node || + ts.isAssignmentOperator(node.kind)) { + return spanInPreviousNode(node); + } + } + if (node.parent.kind === 184 /* BinaryExpression */) { + var binaryExpression = node.parent; + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && + (binaryExpression.right === node || + binaryExpression.operatorToken === node)) { + // If initializer of destructuring assignment move to previous token + return spanInPreviousNode(node); + } + } // Default go to parent to set the breakpoint return spanInNode(node.parent); } } + function textSpanFromVariableDeclaration(variableDeclaration) { + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] === variableDeclaration) { + // First declaration - include let keyword + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + else { + // Span only on this declaration + return textSpan(variableDeclaration); + } + } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 202 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 203 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 203 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 195 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 201 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); - var declarations = isParentVariableStatement - ? variableDeclaration.parent.parent.declarationList.declarations - : isDeclarationOfForStatement - ? variableDeclaration.parent.parent.initializer.declarations - : undefined; - // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) { - if (declarations && declarations[0] === variableDeclaration) { - if (isParentVariableStatement) { - // First declaration - include let keyword - return textSpan(variableDeclaration.parent, variableDeclaration); - } - else { - ts.Debug.assert(isDeclarationOfForStatement); - // Include let keyword from for statement declarations in the span - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - } - else { - // Span only on this declaration - return textSpan(variableDeclaration); - } + // If this is a destructuring pattern set breakpoint in binding pattern + if (ts.isBindingPattern(variableDeclaration.name)) { + return spanInBindingPattern(variableDeclaration.name); } - else if (declarations && declarations[0] !== variableDeclaration) { + // Breakpoint is possible in variableDeclaration only if there is initialization + // or its declaration from 'for of' + if (variableDeclaration.initializer || + (variableDeclaration.flags & 2 /* Export */) || + variableDeclaration.parent.parent.kind === 204 /* ForOfStatement */) { + return textSpanFromVariableDeclaration(variableDeclaration); + } + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] !== variableDeclaration) { // If we cant set breakpoint on this declaration, set it on previous one - var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); - return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); + // Because the variable declaration may be binding pattern and + // we would like to set breakpoint in last binding element if thats the case, + // use preceding token instead + return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); } } function canHaveSpanInParameterDeclaration(parameter) { @@ -51706,7 +52398,11 @@ var ts; !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); } function spanInParameterDeclaration(parameter) { - if (canHaveSpanInParameterDeclaration(parameter)) { + if (ts.isBindingPattern(parameter.name)) { + // set breakpoint in binding pattern + return spanInBindingPattern(parameter.name); + } + else if (canHaveSpanInParameterDeclaration(parameter)) { return textSpan(parameter); } else { @@ -51724,7 +52420,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 2 /* Export */) || - (functionDeclaration.parent.kind === 216 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); + (functionDeclaration.parent.kind === 217 /* ClassDeclaration */ && functionDeclaration.kind !== 145 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -51747,34 +52443,39 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 220 /* ModuleDeclaration */: + case 221 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 200 /* WhileStatement */: - case 198 /* IfStatement */: - case 202 /* ForInStatement */: - case 203 /* ForOfStatement */: + case 201 /* WhileStatement */: + case 199 /* IfStatement */: + case 203 /* 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 201 /* ForStatement */: + case 202 /* ForStatement */: + case 204 /* 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(forLikeStaement) { + if (forLikeStaement.initializer.kind === 215 /* VariableDeclarationList */) { + // declaration list, set breakpoint in first declaration + var variableDeclarationList = forLikeStaement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } + } + else { + // Expression - set breakpoint in it + return spanInNode(forLikeStaement.initializer); + } + } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 214 /* VariableDeclarationList */) { - var variableDeclarationList = forStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } - } - else { - return spanInNode(forStatement.initializer); - } + return spanInInitializerOfForLike(forStatement); } if (forStatement.condition) { return textSpan(forStatement.condition); @@ -51783,16 +52484,44 @@ var ts; return textSpan(forStatement.incrementor); } } + function spanInBindingPattern(bindingPattern) { + // Set breakpoint in first binding element + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + // Empty binding pattern of binding element, set breakpoint on binding element + if (bindingPattern.parent.kind === 166 /* BindingElement */) { + return textSpan(bindingPattern.parent); + } + // Variable declaration is used as the span + return textSpanFromVariableDeclaration(bindingPattern.parent); + } + function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { + ts.Debug.assert(node.kind !== 165 /* ArrayBindingPattern */ && node.kind !== 164 /* ObjectBindingPattern */); + var elements = node.kind === 167 /* ArrayLiteralExpression */ ? + node.elements : + node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + // Could be ArrayLiteral from destructuring assignment or + // 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 === 184 /* BinaryExpression */ ? node.parent : node); + } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 219 /* EnumDeclaration */: + case 220 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 216 /* ClassDeclaration */: + case 217 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -51800,24 +52529,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 221 /* ModuleBlock */: + case 222 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 219 /* EnumDeclaration */: - case 216 /* ClassDeclaration */: + case 220 /* EnumDeclaration */: + case 217 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 194 /* Block */: + case 195 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 246 /* CatchClause */: + case 247 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 222 /* CaseBlock */: + case 223 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -51825,33 +52554,66 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; + case 164 /* 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); // Default to parent node default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + // Breakpoint in last binding element or binding pattern if it contains no elements + var objectLiteral = node.parent; + return textSpan(ts.lastOrUndefined(objectLiteral.properties) || objectLiteral); + } + return spanInNode(node.parent); + } + } + function spanInCloseBracketToken(node) { + switch (node.parent.kind) { + case 165 /* 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); + default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + // Breakpoint in last binding element or binding pattern if it contains no elements + var arrayLiteral = node.parent; + return textSpan(ts.lastOrUndefined(arrayLiteral.elements) || arrayLiteral); + } + // Default to parent node return spanInNode(node.parent); } } function spanInOpenParenToken(node) { - if (node.parent.kind === 199 /* DoStatement */) { - // Go to while keyword and do action instead + if (node.parent.kind === 200 /* DoStatement */ || + node.parent.kind === 171 /* CallExpression */ || + node.parent.kind === 172 /* NewExpression */) { return spanInPreviousNode(node); } + if (node.parent.kind === 175 /* ParenthesizedExpression */) { + return spanInNextNode(node); + } // Default to parent node return spanInNode(node.parent); } function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 175 /* FunctionExpression */: - case 215 /* FunctionDeclaration */: - case 176 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 200 /* WhileStatement */: - case 199 /* DoStatement */: - case 201 /* ForStatement */: + case 176 /* FunctionExpression */: + case 216 /* FunctionDeclaration */: + case 177 /* ArrowFunction */: + case 144 /* MethodDeclaration */: + case 143 /* MethodSignature */: + case 146 /* GetAccessor */: + case 147 /* SetAccessor */: + case 145 /* Constructor */: + case 201 /* WhileStatement */: + case 200 /* DoStatement */: + case 202 /* ForStatement */: + case 204 /* ForOfStatement */: + case 171 /* CallExpression */: + case 172 /* NewExpression */: + case 175 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -51860,21 +52622,31 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 247 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || + node.parent.kind === 248 /* PropertyAssignment */ || + node.parent.kind === 139 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 173 /* TypeAssertionExpression */) { - return spanInNode(node.parent.expression); + if (node.parent.kind === 174 /* TypeAssertionExpression */) { + return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 199 /* DoStatement */) { + if (node.parent.kind === 200 /* DoStatement */) { // Set span on while expression - return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); + return textSpanEndingAtNextToken(node, node.parent.expression); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInOfKeyword(node) { + if (node.parent.kind === 204 /* ForOfStatement */) { + // set using next token + return spanInNextNode(node); } // Default to parent node return spanInNode(node.parent); diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5014c424162..88a1a62ce4c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -117,6 +117,12 @@ namespace ts { let labelIndexMap: Map; let implicitLabels: number[]; + // state used for emit helpers + let hasClassExtends: boolean; + let hasAsyncFunctions: boolean; + let hasDecorators: boolean; + let hasParameterDecorators: boolean; + // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -151,6 +157,10 @@ namespace ts { labelStack = undefined; labelIndexMap = undefined; implicitLabels = undefined; + hasClassExtends = false; + hasAsyncFunctions = false; + hasDecorators = false; + hasParameterDecorators = false; } return bindSourceFile; @@ -241,6 +251,15 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: return node.flags & NodeFlags.Default ? "default" : undefined; + case SyntaxKind.JSDocFunctionType: + return isJSDocConstructSignature(node) ? "__new" : "__call"; + case SyntaxKind.Parameter: + // Parameters with names are handled at the top of this function. Parameters + // without names can only come from JSDocFunctionTypes. + Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType); + let functionType = node.parent; + let index = indexOf(functionType.parameters, node); + return "p" + index; } } @@ -351,8 +370,8 @@ namespace ts { // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge - // 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 + // 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 (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) { const exportKind = @@ -411,7 +430,6 @@ namespace ts { addToContainerChain(container); } - else if (containerFlags & ContainerFlags.IsBlockScopedContainer) { blockScopeContainer = node; blockScopeContainer.locals = undefined; @@ -429,6 +447,9 @@ namespace ts { // reset all reachability check related flags on node (for incremental scenarios) flags &= ~NodeFlags.ReachabilityCheckFlags; + // reset all emit helper flags on node (for incremental scenarios) + flags &= ~NodeFlags.EmitHelperFlags; + if (kind === SyntaxKind.InterfaceDeclaration) { seenThisKeyword = false; } @@ -446,6 +467,10 @@ namespace ts { labelStack = labelIndexMap = implicitLabels = undefined; } + if (isInJavaScriptFile(node) && node.jsDocComment) { + bind(node.jsDocComment); + } + bindReachableStatement(node); if (currentReachabilityState === Reachability.Reachable && isFunctionLikeKind(kind) && nodeIsPresent((node).body)) { @@ -459,6 +484,21 @@ namespace ts { flags = seenThisKeyword ? flags | NodeFlags.ContainsThis : flags & ~NodeFlags.ContainsThis; } + if (kind === SyntaxKind.SourceFile) { + if (hasClassExtends) { + flags |= NodeFlags.HasClassExtends; + } + if (hasDecorators) { + flags |= NodeFlags.HasDecorators; + } + if (hasParameterDecorators) { + flags |= NodeFlags.HasParamDecorators; + } + if (hasAsyncFunctions) { + flags |= NodeFlags.HasAsyncFunctions; + } + } + node.flags = flags; if (saveState) { @@ -694,8 +734,9 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.TypeLiteral: case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.TypeLiteral: + case SyntaxKind.JSDocRecordType: return ContainerFlags.IsContainer; case SyntaxKind.CallSignature: @@ -781,6 +822,7 @@ namespace ts { case SyntaxKind.TypeLiteral: case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.JSDocRecordType: // 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 @@ -801,6 +843,7 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: + case SyntaxKind.JSDocFunctionType: case SyntaxKind.TypeAliasDeclaration: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, @@ -882,7 +925,7 @@ namespace ts { } } - function bindFunctionOrConstructorType(node: SignatureDeclaration) { + function bindFunctionOrConstructorType(node: SignatureDeclaration): void { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // @@ -957,7 +1000,7 @@ namespace ts { declareModuleMember(node, symbolFlags, symbolExcludes); break; } - // fall through. + // fall through. default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; @@ -1236,12 +1279,14 @@ namespace ts { return bindVariableDeclarationOrBindingElement(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: + case SyntaxKind.JSDocRecordMember: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes); case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); case SyntaxKind.EnumMember: return bindPropertyOrMethodOrAccessor(node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes); + case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: @@ -1255,8 +1300,7 @@ namespace ts { return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); + return bindFunctionDeclaration(node); case SyntaxKind.Constructor: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Constructor, /*symbolExcludes:*/ SymbolFlags.None); case SyntaxKind.GetAccessor: @@ -1265,16 +1309,16 @@ namespace ts { return bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: + case SyntaxKind.JSDocFunctionType: return bindFunctionOrConstructorType(node); case SyntaxKind.TypeLiteral: + case SyntaxKind.JSDocRecordType: return bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type"); case SyntaxKind.ObjectLiteralExpression: return bindObjectLiteralExpression(node); case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - checkStrictModeFunctionName(node); - const bindingName = (node).name ? (node).name.text : "__function"; - return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); + return bindFunctionExpression(node); case SyntaxKind.CallExpression: if (isInJavaScriptFile(node)) { @@ -1424,6 +1468,15 @@ namespace ts { } function bindClassLikeDeclaration(node: ClassLikeDeclaration) { + if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (getClassExtendsHeritageClauseElement(node) !== undefined) { + hasClassExtends = true; + } + if (nodeIsDecorated(node)) { + hasDecorators = true; + } + } + if (node.kind === SyntaxKind.ClassDeclaration) { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } @@ -1493,6 +1546,13 @@ namespace ts { } function bindParameter(node: ParameterDeclaration) { + if (!isDeclarationFile(file) && + !isInAmbientContext(node) && + nodeIsDecorated(node)) { + hasDecorators = true; + hasParameterDecorators = true; + } + if (inStrictMode) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) @@ -1514,7 +1574,39 @@ namespace ts { } } + function bindFunctionDeclaration(node: FunctionDeclaration) { + if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); + } + + function bindFunctionExpression(node: FunctionExpression) { + if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + } + + checkStrictModeFunctionName(node); + const bindingName = (node).name ? (node).name.text : "__function"; + return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); + } + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (isAsyncFunctionLike(node)) { + hasAsyncFunctions = true; + } + if (nodeIsDecorated(node)) { + hasDecorators = true; + } + } + return hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 73b36e07476..0a97e1229ec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -178,11 +178,6 @@ namespace ts { const unionTypes: Map = {}; const intersectionTypes: Map = {}; const stringLiteralTypes: Map = {}; - let emitExtends = false; - let emitDecorate = false; - let emitParam = false; - let emitAwaiter = false; - const emitGenerator = false; const resolutionTargets: TypeSystemEntity[] = []; const resolutionResults: boolean[] = []; @@ -462,7 +457,7 @@ namespace ts { * Get symbols that represent parameter-property-declaration as parameter and as property declaration * @param parameter a parameterDeclaration node * @param parameterName a name of the parameter to get the symbols for. - * @return a tuple of two symbols + * @return a tuple of two symbols */ function getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): [Symbol, Symbol] { const constructoDeclaration = parameter.parent; @@ -566,7 +561,9 @@ namespace ts { // - Type parameters of a function are in scope in the entire function declaration, including the parameter // list and return type. However, local types are only in scope in the function body. // - parameters are only in the scope of function body - if (meaning & result.flags & SymbolFlags.Type) { + // 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 & SymbolFlags.Type && lastLocation.kind !== SyntaxKind.JSDocComment) { useResult = result.flags & SymbolFlags.TypeParameter // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === (location).type || @@ -2588,8 +2585,54 @@ namespace ts { return type; } + function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) { + const jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (jsDocType) { + return getTypeFromTypeNode(jsDocType); + } + } + + function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType { + // First, see if this node has an @type annotation on it directly. + const typeTag = getJSDocTypeTag(declaration); + if (typeTag) { + return typeTag.typeExpression.type; + } + + if (declaration.kind === SyntaxKind.VariableDeclaration && + declaration.parent.kind === SyntaxKind.VariableDeclarationList && + declaration.parent.parent.kind === SyntaxKind.VariableStatement) { + + // @type annotation might have been on the variable statement, try that instead. + const annotation = getJSDocTypeTag(declaration.parent.parent); + if (annotation) { + return annotation.typeExpression.type; + } + } + else if (declaration.kind === SyntaxKind.Parameter) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param + // annotation. + const paramTag = getCorrespondingJSDocParameterTag(declaration); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type; + } + } + + return undefined; + } + // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration): Type { + if (declaration.parserContextFlags & ParserContextFlags.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. + const type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (type && type !== unknownType) { + return type; + } + } + // A variable declared in a for..in statement is always of type string if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) { return stringType; @@ -3926,6 +3969,17 @@ namespace ts { return getIndexTypeOfStructuredType(getApparentType(type), kind); } + function getTypeParametersFromJSDocTemplate(declaration: SignatureDeclaration): TypeParameter[] { + if (declaration.parserContextFlags & ParserContextFlags.JavaScriptFile) { + const templateTag = getJSDocTemplateTag(declaration); + if (templateTag) { + return getTypeParametersFromDeclaration(templateTag.typeParameters); + } + } + + return undefined; + } + // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations: TypeParameterDeclaration[]): TypeParameter[] { @@ -3950,6 +4004,23 @@ namespace ts { } function isOptionalParameter(node: ParameterDeclaration) { + if (node.parserContextFlags & ParserContextFlags.JavaScriptFile) { + if (node.type && node.type.kind === SyntaxKind.JSDocOptionalType) { + return true; + } + + const paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag) { + if (paramTag.isBracketed) { + return true; + } + + if (paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType; + } + } + } + if (hasQuestionToken(node)) { return true; } @@ -3990,12 +4061,20 @@ namespace ts { getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) : undefined; const typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : + getTypeParametersFromJSDocTemplate(declaration); const parameters: Symbol[] = []; let hasStringLiterals = false; let minArgumentCount = -1; - for (let i = 0, n = declaration.parameters.length; i < n; i++) { + const isJSConstructSignature = isJSDocConstructSignature(declaration); + let returnType: Type = undefined; + + // If this is a JSDoc construct signature, then skip the first parameter in the + // parameter list. The first parameter represents the return type of the construct + // signature. + for (let i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { const param = declaration.parameters[i]; + let paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) { @@ -4003,6 +4082,7 @@ namespace ts { paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); + if (param.type && param.type.kind === SyntaxKind.StringLiteralType) { hasStringLiterals = true; } @@ -4022,14 +4102,24 @@ namespace ts { minArgumentCount = declaration.parameters.length; } - let returnType: Type; - if (classType) { + if (isJSConstructSignature) { + minArgumentCount--; + returnType = getTypeFromTypeNode(declaration.parameters[0].type); + } + else if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); } else { + if (declaration.parserContextFlags & ParserContextFlags.JavaScriptFile) { + const type = getReturnTypeFromJSDocComment(declaration); + if (type && type !== unknownType) { + returnType = type; + } + } + // 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 === SyntaxKind.GetAccessor && !hasDynamicName(declaration)) { @@ -4066,6 +4156,7 @@ namespace ts { case SyntaxKind.SetAccessor: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: + case SyntaxKind.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). @@ -4291,7 +4382,7 @@ namespace ts { } // Get type from reference to class or interface - function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type { + function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(symbol); const typeParameters = type.localTypeParameters; if (typeParameters) { @@ -4314,7 +4405,7 @@ namespace ts { // 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: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type { + function getTypeFromTypeAliasReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(symbol); const links = getSymbolLinks(symbol); const typeParameters = links.typeParameters; @@ -4335,7 +4426,7 @@ namespace ts { } // Get type from reference to named type that cannot be generic (enum or type parameter) - function getTypeFromNonGenericTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type { + function getTypeFromNonGenericTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { if (node.typeArguments) { error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); return unknownType; @@ -4343,18 +4434,83 @@ namespace ts { return getDeclaredTypeOfSymbol(symbol); } - function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments): Type { + function getTypeReferenceName(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): LeftHandSideExpression | EntityName { + switch (node.kind) { + case SyntaxKind.TypeReference: + return (node).typeName; + case SyntaxKind.JSDocTypeReference: + return (node).name; + case SyntaxKind.ExpressionWithTypeArguments: + // We only support expressions that are simple qualified names. For other + // expressions this produces undefined. + if (isSupportedExpressionWithTypeArguments(node)) { + return (node).expression; + } + + // fall through; + } + + return undefined; + } + + function resolveTypeReferenceName( + node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, + typeReferenceName: LeftHandSideExpression | EntityName) { + + if (!typeReferenceName) { + return unknownSymbol; + } + + return resolveEntityName(typeReferenceName, SymbolFlags.Type) || unknownSymbol; + } + + function getTypeReferenceType(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol) { + if (symbol === unknownSymbol) { + return unknownType; + } + + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + + if (symbol.flags & SymbolFlags.TypeAlias) { + return getTypeFromTypeAliasReference(node, symbol); + } + + if (symbol.flags & SymbolFlags.Value && node.kind === SyntaxKind.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. + return getTypeOfSymbol(symbol); + } + + return getTypeFromNonGenericTypeReference(node, symbol); + } + + function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type { const links = getNodeLinks(node); if (!links.resolvedType) { - // We only support expressions that are simple qualified names. For other expressions this produces undefined. - const typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : - isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; - const symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; - const type = symbol === unknownSymbol ? unknownType : - symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + let symbol: Symbol; + let type: Type; + if (node.kind === SyntaxKind.JSDocTypeReference) { + const typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(node, typeReferenceName); + type = getTypeReferenceType(node, symbol); + + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + else { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + const typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : + isSupportedExpressionWithTypeArguments(node) ? (node).expression : + undefined; + symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; + type = symbol === unknownSymbol ? unknownType : + symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + } // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -4649,6 +4805,24 @@ namespace ts { return links.resolvedType; } + function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { + const links = getNodeLinks(node); + if (!links.resolvedType) { + const type = getTypeFromTypeNode(node.type); + links.resolvedType = type ? createArrayType(type) : unknownType; + } + return links.resolvedType; + } + + function getTypeFromJSDocTupleType(node: JSDocTupleType): Type { + const links = getNodeLinks(node); + if (!links.resolvedType) { + const types = map(node.types, getTypeFromTypeNode); + links.resolvedType = createTupleType(types); + } + return links.resolvedType; + } + function getThisType(node: TypeNode): Type { const container = getThisContainer(node, /*includeArrowFunctions*/ false); const parent = container && container.parent; @@ -4692,6 +4866,8 @@ namespace ts { function getTypeFromTypeNode(node: TypeNode): Type { switch (node.kind) { case SyntaxKind.AnyKeyword: + case SyntaxKind.JSDocAllType: + case SyntaxKind.JSDocUnknownType: return anyType; case SyntaxKind.StringKeyword: return stringType; @@ -4708,6 +4884,7 @@ namespace ts { case SyntaxKind.StringLiteralType: return getTypeFromStringLiteralTypeNode(node); case SyntaxKind.TypeReference: + case SyntaxKind.JSDocTypeReference: return getTypeFromTypeReference(node); case SyntaxKind.TypePredicate: return getTypeFromPredicateTypeNode(node); @@ -4716,18 +4893,27 @@ namespace ts { case SyntaxKind.TypeQuery: return getTypeFromTypeQueryNode(node); case SyntaxKind.ArrayType: + case SyntaxKind.JSDocArrayType: return getTypeFromArrayTypeNode(node); case SyntaxKind.TupleType: return getTypeFromTupleTypeNode(node); case SyntaxKind.UnionType: + case SyntaxKind.JSDocUnionType: return getTypeFromUnionTypeNode(node); case SyntaxKind.IntersectionType: return getTypeFromIntersectionTypeNode(node); case SyntaxKind.ParenthesizedType: - return getTypeFromTypeNode((node).type); + case SyntaxKind.JSDocNullableType: + case SyntaxKind.JSDocNonNullableType: + case SyntaxKind.JSDocConstructorType: + case SyntaxKind.JSDocThisType: + case SyntaxKind.JSDocOptionalType: + return getTypeFromTypeNode((node).type); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: + case SyntaxKind.JSDocFunctionType: + case SyntaxKind.JSDocRecordType: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode @@ -4735,6 +4921,10 @@ namespace ts { case SyntaxKind.QualifiedName: const symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); + case SyntaxKind.JSDocTupleType: + return getTypeFromJSDocTupleType(node); + case SyntaxKind.JSDocVariadicType: + return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -7120,18 +7310,25 @@ namespace ts { return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; } - // 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 (isInJavaScriptFile(node) && container.kind === SyntaxKind.FunctionExpression) { - if (getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { - // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') - const className = (((container.parent as BinaryExpression) // x.protoype.y = f - .left as PropertyAccessExpression) // x.prototype.y - .expression as PropertyAccessExpression) // x.prototype - .expression; // x - const classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) { - return getInferredClassType(classSymbol); + if (isInJavaScriptFile(node)) { + const type = getTypeForThisExpressionFromJSDoc(container); + if (type && type !== unknownType) { + return type; + } + + // 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 === SyntaxKind.FunctionExpression) { + if (getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { + // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') + const className = (((container.parent as BinaryExpression) // x.protoype.y = f + .left as PropertyAccessExpression) // x.prototype.y + .expression as PropertyAccessExpression) // x.prototype + .expression; // x + const classSymbol = checkExpression(className).symbol; + if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) { + return getInferredClassType(classSymbol); + } } } } @@ -7139,6 +7336,16 @@ namespace ts { return anyType; } + function getTypeForThisExpressionFromJSDoc(node: Node) { + const typeTag = getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) { + const jsDocFunctionType = typeTag.typeExpression.type; + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) { + return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); + } + } + } + function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean { for (let n = node; n && n !== constructorDecl; n = n.parent) { if (n.kind === SyntaxKind.Parameter) { @@ -9948,7 +10155,8 @@ namespace ts { if (declaration && declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && - declaration.kind !== SyntaxKind.ConstructorType) { + declaration.kind !== SyntaxKind.ConstructorType && + !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 @@ -10068,6 +10276,13 @@ namespace ts { } } + function getReturnTypeFromJSDocComment(func: SignatureDeclaration | FunctionDeclaration): Type { + const returnTag = getJSDocReturnTag(func); + if (returnTag) { + return getTypeFromTypeNode(returnTag.typeExpression.type); + } + } + function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument const globalPromiseType = getGlobalPromiseType(); @@ -10278,11 +10493,6 @@ namespace ts { return anyFunctionType; } - const isAsync = isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - const links = getNodeLinks(node); const type = getTypeOfSymbol(node.symbol); const contextSensitive = isContextSensitive(node); @@ -10331,10 +10541,6 @@ namespace ts { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); const isAsync = isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { // return is not necessary in the body of generators @@ -12470,11 +12676,6 @@ namespace ts { } } - emitDecorate = true; - if (node.kind === SyntaxKind.Parameter) { - emitParam = true; - } - forEach(node.decorators, checkDecorator); } @@ -12492,9 +12693,6 @@ namespace ts { checkDecorators(node); checkSignatureDeclaration(node); const isAsync = isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including @@ -13626,7 +13824,6 @@ namespace ts { const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitExtends = emitExtends || !isInAmbientContext(node); const baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { const baseType = baseTypes[0]; @@ -14528,7 +14725,7 @@ namespace ts { // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) const symbol = resolveName(exportedName, exportedName.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); } else { @@ -14806,10 +15003,6 @@ namespace ts { // Grammar checking checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - emitAwaiter = false; potentialThisCollisions.length = 0; deferredNodes = []; @@ -14826,26 +15019,6 @@ namespace ts { potentialThisCollisions.length = 0; } - if (emitExtends) { - links.flags |= NodeCheckFlags.EmitExtends; - } - - if (emitDecorate) { - links.flags |= NodeCheckFlags.EmitDecorate; - } - - if (emitParam) { - links.flags |= NodeCheckFlags.EmitParam; - } - - if (emitAwaiter) { - links.flags |= NodeCheckFlags.EmitAwaiter; - } - - if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) { - links.flags |= NodeCheckFlags.EmitGenerator; - } - links.flags |= NodeCheckFlags.TypeChecked; } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 247a204e9bd..733e3158593 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -493,8 +493,8 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}): ParsedCommandLine { - const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath); + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string): ParsedCommandLine { + const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName); const options = extend(existingOptions, optionsFromJsonConfigFile); return { @@ -523,7 +523,7 @@ namespace ts { for (const extension of supportedExtensions) { const filesInDirWithExtension = host.readDirectory(basePath, extension, exclude); for (const fileName of filesInDirWithExtension) { - // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, + // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, // lets pick them when its turn comes up if (extension === ".ts" && fileExtensionIs(fileName, ".d.ts")) { continue; @@ -547,10 +547,15 @@ namespace ts { } } - export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { options: CompilerOptions, errors: Diagnostic[] } { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } { const options: CompilerOptions = {}; const errors: Diagnostic[] = []; + if (configFileName && getBaseFileName(configFileName) === "jsconfig.json") { + options.module = ModuleKind.CommonJS; + options.allowJs = true; + } + if (!jsonOptions) { return { options, errors }; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 417e245dae5..44cb0ea3ccf 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -319,17 +319,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { };`; const awaiterHelper = ` -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { - return new Promise(function (resolve, reject) { - generator = generator.call(thisArg, _arguments); - function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } - function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } - function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } - function step(verb, value) { - var result = generator[verb](value); - result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); - } - step("next", void 0); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); }); };`; @@ -7354,12 +7349,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) { + if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) { + if (!decorateEmitted && node.flags & NodeFlags.HasDecorators) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); @@ -7367,12 +7362,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitParam) { + if (!paramEmitted && node.flags & NodeFlags.HasParamDecorators) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitAwaiter) { + if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) { writeLines(awaiterHelper); awaiterEmitted = true; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e7aad6d149a..5b4c04ddd02 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -611,44 +611,24 @@ namespace ts { fixupParentReferences(sourceFile); } - // If this is a javascript file, proactively see if we can get JSDoc comments for - // relevant nodes in the file. We'll use these to provide typing informaion if they're - // available. - if (isSourceFileJavaScript(sourceFile)) { - addJSDocComments(); - } - return sourceFile; } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node: Node) { - // Add additional cases as necessary depending on how we see JSDoc comments used - // in the wild. - switch (node.kind) { - case SyntaxKind.VariableStatement: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.Parameter: - addJSDocComment(node); - } - - forEachChild(node, visit); - } - } - - function addJSDocComment(node: Node) { - const comments = getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (const comment of comments) { - const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; + function addJSDocComment(node: T): T { + if (contextFlags & ParserContextFlags.JavaScriptFile) { + const comments = getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (const comment of comments) { + const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } } } } + + return node; } export function fixupParentReferences(sourceFile: Node) { @@ -2067,7 +2047,8 @@ namespace ts { // contexts. In addition, parameter initializers are semantically disallowed in // overload signatures. So parameter initializers are transitively disallowed in // ambient contexts. - return finishNode(node); + + return addJSDocComment(finishNode(node)); } function parseBindingElementInitializer(inParameter: boolean) { @@ -4742,7 +4723,7 @@ namespace ts { setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): FunctionDeclaration { @@ -4756,7 +4737,7 @@ namespace ts { const isAsync = !!(node.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos: number, decorators: NodeArray, modifiers: ModifiersArray): ConstructorDeclaration { @@ -5594,23 +5575,19 @@ namespace ts { export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); - const jsDocTypeExpression = parseJSDocTypeExpression(start, length); + scanner.setText(content, start, length); + token = scanner.scan(); + const jsDocTypeExpression = parseJSDocTypeExpression(); const diagnostics = parseDiagnostics; clearState(); return jsDocTypeExpression ? { jsDocTypeExpression, diagnostics } : undefined; } - // Parses out a JSDoc type expression. The starting position should be right at the open - // curly in the type expression. Returns 'undefined' if it encounters any errors while parsing. + // Parses out a JSDoc type expression. /* @internal */ - export function parseJSDocTypeExpression(start: number, length: number): JSDocTypeExpression { - scanner.setText(sourceText, start, length); - - // Prime the first token for us to start processing. - token = nextToken(); - - const result = createNode(SyntaxKind.JSDocTypeExpression); + export function parseJSDocTypeExpression(): JSDocTypeExpression { + const result = createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos()); parseExpected(SyntaxKind.OpenBraceToken); result.type = parseJSDocTopLevelType(); @@ -5908,7 +5885,8 @@ namespace ts { export function parseIsolatedJSDocComment(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); - const jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); + sourceFile = { languageVariant: LanguageVariant.Standard, text: content }; + const jsDocComment = parseJSDocCommentWorker(start, length); const diagnostics = parseDiagnostics; clearState(); @@ -5916,12 +5894,19 @@ namespace ts { } export function parseJSDocComment(parent: Node, start: number, length: number): JSDocComment { + const saveToken = token; + const saveParseDiagnosticsLength = parseDiagnostics.length; + const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + const comment = parseJSDocCommentWorker(start, length); if (comment) { - fixupParentReferences(comment); comment.parent = parent; } + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; + return comment; } @@ -5936,69 +5921,69 @@ namespace ts { Debug.assert(end <= content.length); let tags: NodeArray; - let pos: number; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The - // scanner would need to know it was in a Doc Comment. Otherwise, it would then - // produce comments *inside* the doc comment. In the end it was just easier to - // write a simple scanner rather than go that route. - if (length >= "/** */".length) { - if (content.charCodeAt(start) === CharacterCodes.slash && - content.charCodeAt(start + 1) === CharacterCodes.asterisk && - content.charCodeAt(start + 2) === CharacterCodes.asterisk && - content.charCodeAt(start + 3) !== CharacterCodes.asterisk) { + let result: JSDocComment; + // Check for /** (JSDoc opening part) + if (content.charCodeAt(start) === CharacterCodes.slash && + content.charCodeAt(start + 1) === CharacterCodes.asterisk && + content.charCodeAt(start + 2) === CharacterCodes.asterisk && + content.charCodeAt(start + 3) !== CharacterCodes.asterisk) { + + + // + 3 for leading /**, - 5 in total for /** */ + scanner.scanRange(start + 3, length - 5, () => { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. let canParseTag = true; let seenAsterisk = true; - for (pos = start + "/**".length; pos < end; ) { - const ch = content.charCodeAt(pos); - pos++; + nextJSDocToken(); + while (token !== SyntaxKind.EndOfFileToken) { + switch (token) { + case SyntaxKind.AtToken: + if (canParseTag) { + parseTag(); + } + // This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop + seenAsterisk = false; + break; - if (ch === CharacterCodes.at && canParseTag) { - parseTag(); + case SyntaxKind.NewLineTrivia: + // After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet + canParseTag = true; + seenAsterisk = false; + break; - // Once we parse out a tag, we cannot keep parsing out tags on this line. - canParseTag = false; - continue; - } + case SyntaxKind.AsteriskToken: + if (seenAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag on this line + canParseTag = false; + } + // Ignore the first asterisk on a line + seenAsterisk = true; + break; - if (isLineBreak(ch)) { - // After a line break, we can parse a tag, and we haven't seen as asterisk - // on the next line yet. - canParseTag = true; - seenAsterisk = false; - continue; - } - - if (isWhiteSpace(ch)) { - // Whitespace doesn't affect any of our parsing. - continue; - } - - // Ignore the first asterisk on a line. - if (ch === CharacterCodes.asterisk) { - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag - // on this line. + case SyntaxKind.Identifier: + // Anything else is doc comment text. We can't do anything with it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. canParseTag = false; - } - seenAsterisk = true; - continue; + break; + + case SyntaxKind.EndOfFileToken: + break; } - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. - canParseTag = false; + nextJSDocToken(); } - } + + result = createJSDocComment(); + + }); } - return createJSDocComment(); + return result; function createJSDocComment(): JSDocComment { if (!tags) { @@ -6011,17 +5996,18 @@ namespace ts { } function skipWhitespace(): void { - while (pos < end && isWhiteSpace(content.charCodeAt(pos))) { - pos++; + while (token === SyntaxKind.WhitespaceTrivia || token === SyntaxKind.NewLineTrivia) { + nextJSDocToken(); } } function parseTag(): void { - Debug.assert(content.charCodeAt(pos - 1) === CharacterCodes.at); - const atToken = createNode(SyntaxKind.AtToken, pos - 1); - atToken.end = pos; + Debug.assert(token === SyntaxKind.AtToken); + const atToken = createNode(SyntaxKind.AtToken, scanner.getTokenPos()); + atToken.end = scanner.getTextPos(); + nextJSDocToken(); - const tagName = scanIdentifier(); + const tagName = parseJSDocIdentifier(); if (!tagName) { return; } @@ -6052,7 +6038,7 @@ namespace ts { const result = createNode(SyntaxKind.JSDocTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; - return finishNode(result, pos); + return finishNode(result); } function addTag(tag: JSDocTag): void { @@ -6068,14 +6054,11 @@ namespace ts { } function tryParseTypeExpression(): JSDocTypeExpression { - skipWhitespace(); - - if (content.charCodeAt(pos) !== CharacterCodes.openBrace) { + if (token !== SyntaxKind.OpenBraceToken) { return undefined; } - const typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; + const typeExpression = parseJSDocTypeExpression(); return typeExpression; } @@ -6085,18 +6068,25 @@ namespace ts { skipWhitespace(); let name: Identifier; let isBracketed: boolean; - if (content.charCodeAt(pos) === CharacterCodes.openBracket) { - pos++; - skipWhitespace(); - name = scanIdentifier(); + // Looking for something like '[foo]' or 'foo' + if (parseOptionalToken(SyntaxKind.OpenBracketToken)) { + name = parseJSDocIdentifier(); isBracketed = true; + + // May have an optional default, e.g. '[foo = 42]' + if (parseOptionalToken(SyntaxKind.EqualsToken)) { + parseExpression(); + } + + parseExpected(SyntaxKind.CloseBracketToken); } - else { - name = scanIdentifier(); + else if (token === SyntaxKind.Identifier) { + name = parseJSDocIdentifier(); } if (!name) { - parseErrorAtPosition(pos, 0, Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected); + return undefined; } let preName: Identifier, postName: Identifier; @@ -6118,95 +6108,90 @@ namespace ts { result.typeExpression = typeExpression; result.postParameterName = postName; result.isBracketed = isBracketed; - return finishNode(result, pos); + return finishNode(result); } function handleReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } const result = createNode(SyntaxKind.JSDocReturnTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } function handleTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } const result = createNode(SyntaxKind.JSDocTypeTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } function handleTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } + // Type parameter list looks like '@template T,U,V' const typeParameters = >[]; - typeParameters.pos = pos; + typeParameters.pos = scanner.getStartPos(); while (true) { - skipWhitespace(); - - const startPos = pos; - const name = scanIdentifier(); + const name = parseJSDocIdentifier(); if (!name) { - parseErrorAtPosition(startPos, 0, Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected); return undefined; } const typeParameter = createNode(SyntaxKind.TypeParameter, name.pos); typeParameter.name = name; - finishNode(typeParameter, pos); + finishNode(typeParameter); typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== CharacterCodes.comma) { + if (token === SyntaxKind.CommaToken) { + nextJSDocToken(); + } + else { break; } - - pos++; } - typeParameters.end = pos; - const result = createNode(SyntaxKind.JSDocTemplateTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; - return finishNode(result, pos); + finishNode(result); + typeParameters.end = result.end; + return result; } - function scanIdentifier(): Identifier { - const startPos = pos; - for (; pos < end; pos++) { - const ch = content.charCodeAt(pos); - if (pos === startPos && isIdentifierStart(ch, ScriptTarget.Latest)) { - continue; - } - else if (pos > startPos && isIdentifierPart(ch, ScriptTarget.Latest)) { - continue; - } + function nextJSDocToken(): SyntaxKind { + return token = scanner.scanJSDocToken(); + } - break; - } - - if (startPos === pos) { + function parseJSDocIdentifier(): Identifier { + if (token !== SyntaxKind.Identifier) { + parseErrorAtCurrentToken(Diagnostics.Identifier_expected); return undefined; } - const result = createNode(SyntaxKind.Identifier, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); + const pos = scanner.getTokenPos(); + const end = scanner.getTextPos(); + const result = createNode(SyntaxKind.Identifier, pos); + result.text = content.substring(pos, end); + finishNode(result, end); + + nextJSDocToken(); + return result; } } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ab1fec2dcd6..4470d7f623c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -29,6 +29,7 @@ namespace ts { scanJsxIdentifier(): SyntaxKind; reScanJsxToken(): SyntaxKind; scanJsxToken(): SyntaxKind; + scanJSDocToken(): SyntaxKind; scan(): SyntaxKind; // Sets the text for the scanner to scan. An optional subrange starting point and length // can be provided to have the scanner only scan a portion of the text. @@ -42,6 +43,10 @@ namespace ts { // is returned from this function. lookAhead(callback: () => T): T; + // Invokes the callback with the scanner set to scan the specified range. When the callback + // returns, the scanner is restored to the state it was in before scanRange was called. + scanRange(start: number, length: number, callback: () => T): T; + // Invokes the provided callback. If the callback returns something falsy, then it restores // the scanner to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the scanner state is not rolled back. The result @@ -751,6 +756,7 @@ namespace ts { scanJsxIdentifier, reScanJsxToken, scanJsxToken, + scanJSDocToken, scan, setText, setScriptTarget, @@ -759,6 +765,7 @@ namespace ts { setTextPos, tryScan, lookAhead, + scanRange, }; function error(message: DiagnosticMessage, length?: number): void { @@ -1666,6 +1673,60 @@ namespace ts { return token; } + function scanJSDocToken(): SyntaxKind { + if (pos >= end) { + return token = SyntaxKind.EndOfFileToken; + } + + startPos = pos; + + // Eat leading whitespace + let ch = text.charCodeAt(pos); + while (pos < end) { + ch = text.charCodeAt(pos); + if (isWhiteSpace(ch)) { + pos++; + } + else { + break; + } + } + tokenPos = pos; + + switch (ch) { + case CharacterCodes.at: + return pos += 1, token = SyntaxKind.AtToken; + case CharacterCodes.lineFeed: + case CharacterCodes.carriageReturn: + return pos += 1, token = SyntaxKind.NewLineTrivia; + case CharacterCodes.asterisk: + return pos += 1, token = SyntaxKind.AsteriskToken; + case CharacterCodes.openBrace: + return pos += 1, token = SyntaxKind.OpenBraceToken; + case CharacterCodes.closeBrace: + return pos += 1, token = SyntaxKind.CloseBraceToken; + case CharacterCodes.openBracket: + return pos += 1, token = SyntaxKind.OpenBracketToken; + case CharacterCodes.closeBracket: + return pos += 1, token = SyntaxKind.CloseBracketToken; + case CharacterCodes.equals: + return pos += 1, token = SyntaxKind.EqualsToken; + case CharacterCodes.comma: + return pos += 1, token = SyntaxKind.CommaToken; + } + + if (isIdentifierStart(ch, ScriptTarget.Latest)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), ScriptTarget.Latest) && pos < end) { + pos++; + } + return token = SyntaxKind.Identifier; + } + else { + return pos += 1, token = SyntaxKind.Unknown; + } + } + function speculationHelper(callback: () => T, isLookahead: boolean): T { const savePos = pos; const saveStartPos = startPos; @@ -1688,6 +1749,33 @@ namespace ts { return result; } + function scanRange(start: number, length: number, callback: () => T): T { + const saveEnd = end; + const savePos = pos; + const saveStartPos = startPos; + const saveTokenPos = tokenPos; + const saveToken = token; + const savePrecedingLineBreak = precedingLineBreak; + const saveTokenValue = tokenValue; + const saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + const saveTokenIsUnterminated = tokenIsUnterminated; + + setText(text, start, length); + const result = callback(); + + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + + return result; + } + function lookAhead(callback: () => T): T { return speculationHelper(callback, /*isLookahead*/ true); } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 808ee6da804..9b2457d0916 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -340,7 +340,7 @@ namespace ts { if (sys.watchDirectory && configFileName) { const directory = ts.getDirectoryPath(configFileName); directoryWatcher = sys.watchDirectory( - // When the configFileName is just "tsconfig.json", the watched directory should be + // When the configFileName is just "tsconfig.json", the watched directory should be // the current direcotry; if there is a given "project" parameter, then the configFileName // is an absolute file name. directory == "" ? "." : directory, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9e41f725af2..61de5f49fcc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -313,11 +313,11 @@ namespace ts { // Top-level nodes SourceFile, - // JSDoc nodes. + // JSDoc nodes JSDocTypeExpression, - // The * type. + // The * type JSDocAllType, - // The ? type. + // The ? type JSDocUnknownType, JSDocArrayType, JSDocUnionType, @@ -393,10 +393,17 @@ namespace ts { HasImplicitReturn = 1 << 20, // If function implicitly returns on one of codepaths (initialized by binding) HasExplicitReturn = 1 << 21, // If function has explicit reachable return on one of codepaths (initialized by binding) GlobalAugmentation = 1 << 22, // Set if module declaration is an augmentation for the global scope - Modifier = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Default | Async, + HasClassExtends = 1 << 23, // If the file has a non-ambient class with an extends clause in ES5 or lower (initialized by binding) + HasDecorators = 1 << 24, // If the file has decorators (initialized by binding) + HasParamDecorators = 1 << 25, // If the file has parameter decorators (initialized by binding) + HasAsyncFunctions = 1 << 26, // If the file has async functions (initialized by binding) + + Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const, - ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn + + ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn, + EmitHelperFlags = HasClassExtends | HasDecorators | HasParamDecorators | HasAsyncFunctions, } /* @internal */ @@ -999,7 +1006,7 @@ namespace ts { } // @kind(SyntaxKind.CallExpression) - export interface CallExpression extends LeftHandSideExpression { + export interface CallExpression extends LeftHandSideExpression, Declaration { expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; @@ -1478,6 +1485,8 @@ namespace ts { type: JSDocType; } + export type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + // @kind(SyntaxKind.JSDocRecordMember) export interface JSDocRecordMember extends PropertySignature { name: Identifier | LiteralExpression; @@ -2048,11 +2057,6 @@ namespace ts { TypeChecked = 0x00000001, // Node has been type checked LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body - EmitExtends = 0x00000008, // Emit __extends - EmitDecorate = 0x00000010, // Emit __decorate - EmitParam = 0x00000020, // Emit __param helper for decorators - EmitAwaiter = 0x00000040, // Emit __awaiter - EmitGenerator = 0x00000080, // Emit __generator SuperInstance = 0x00000100, // Instance 'super' reference SuperStatic = 0x00000200, // Static 'super' reference ContextChecked = 0x00000400, // Contextual types have been assigned diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 07c335c25c4..9b1ad62cbf2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -802,8 +802,8 @@ namespace ts { } /** - * Given an super call\property node returns a closest node where either - * - super call\property is legal in the node and not legal in the parent node the node. + * Given an super call\property node returns a closest node where either + * - super call\property is legal in the node and not legal in the parent node the node. * i.e. super call is legal in constructor but not legal in the class body. * - node is arrow function (so caller might need to call getSuperContainer in case it needs to climb higher) * - super call\property is definitely illegal in the node (but might be legal in some subnode) @@ -885,54 +885,28 @@ namespace ts { // property declarations are valid if their parent is a class declaration. return node.parent.kind === SyntaxKind.ClassDeclaration; - case SyntaxKind.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 && node.parent.parent.kind === SyntaxKind.ClassDeclaration; - case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.MethodDeclaration: // if this method has a body and its parent is a class declaration, this is a valid target. - return (node).body && node.parent.kind === SyntaxKind.ClassDeclaration; + return (node).body !== undefined + && node.parent.kind === SyntaxKind.ClassDeclaration; + + case SyntaxKind.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 === SyntaxKind.Constructor + || node.parent.kind === SyntaxKind.MethodDeclaration + || node.parent.kind === SyntaxKind.SetAccessor) + && node.parent.parent.kind === SyntaxKind.ClassDeclaration; } return false; } export function nodeIsDecorated(node: Node): boolean { - switch (node.kind) { - case SyntaxKind.ClassDeclaration: - if (node.decorators) { - return true; - } - - return false; - - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.Parameter: - if (node.decorators) { - return true; - } - - return false; - - case SyntaxKind.GetAccessor: - if ((node).body && node.decorators) { - return true; - } - - return false; - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.SetAccessor: - if ((node).body && node.decorators) { - return true; - } - - return false; - } - - return false; + return node.decorators !== undefined + && nodeCanBeDecorated(node); } export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { @@ -1080,7 +1054,7 @@ namespace ts { /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one string literal argument. + * exactly one argument. * This function does not test if the node is in a JavaScript file or not. */ export function isRequireCall(expression: Node): expression is CallExpression { @@ -1088,8 +1062,7 @@ namespace ts { return expression.kind === SyntaxKind.CallExpression && (expression).expression.kind === SyntaxKind.Identifier && ((expression).expression).text === "require" && - (expression).arguments.length === 1 && - (expression).arguments[0].kind === SyntaxKind.StringLiteral; + (expression).arguments.length === 1; } /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property @@ -1169,26 +1142,56 @@ namespace ts { (node).parameters[0].type.kind === SyntaxKind.JSDocConstructorType; } - function getJSDocTag(node: Node, kind: SyntaxKind): JSDocTag { - if (node && node.jsDocComment) { - for (const tag of node.jsDocComment.tags) { - if (tag.kind === kind) { - return tag; - } + function getJSDocTag(node: Node, kind: SyntaxKind, checkParentVariableStatement: boolean): JSDocTag { + if (!node) { + return undefined; + } + + const jsDocComment = getJSDocComment(node, checkParentVariableStatement); + if (!jsDocComment) { + return undefined; + } + + for (const tag of jsDocComment.tags) { + if (tag.kind === kind) { + return tag; } } } + function getJSDocComment(node: Node, checkParentVariableStatement: boolean): JSDocComment { + if (node.jsDocComment) { + return node.jsDocComment; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + if (checkParentVariableStatement) { + const isInitializerOfVariableDeclarationInStatement = + node.parent.kind === SyntaxKind.VariableDeclaration && + (node.parent).initializer === node && + node.parent.parent.parent.kind === SyntaxKind.VariableStatement; + + const variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + return variableStatementNode && variableStatementNode.jsDocComment; + } + + return undefined; + } + export function getJSDocTypeTag(node: Node): JSDocTypeTag { - return getJSDocTag(node, SyntaxKind.JSDocTypeTag); + return getJSDocTag(node, SyntaxKind.JSDocTypeTag, /*checkParentVariableStatement*/ false); } export function getJSDocReturnTag(node: Node): JSDocReturnTag { - return getJSDocTag(node, SyntaxKind.JSDocReturnTag); + return getJSDocTag(node, SyntaxKind.JSDocReturnTag, /*checkParentVariableStatement*/ true); } export function getJSDocTemplateTag(node: Node): JSDocTemplateTag { - return getJSDocTag(node, SyntaxKind.JSDocTemplateTag); + return getJSDocTag(node, SyntaxKind.JSDocTemplateTag, /*checkParentVariableStatement*/ false); } export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag { @@ -1197,19 +1200,21 @@ namespace ts { // annotation. const parameterName = (parameter.name).text; - const docComment = parameter.parent.jsDocComment; - if (docComment) { - return forEach(docComment.tags, t => { - if (t.kind === SyntaxKind.JSDocParameterTag) { - const parameterTag = t; + const jsDocComment = getJSDocComment(parameter.parent, /*checkParentVariableStatement*/ true); + if (jsDocComment) { + for (const tag of jsDocComment.tags) { + if (tag.kind === SyntaxKind.JSDocParameterTag) { + const parameterTag = tag; const name = parameterTag.preParameterName || parameterTag.postParameterName; if (name.text === parameterName) { - return t; + return parameterTag; } } - }); + } } } + + return undefined; } export function hasRestParameter(s: SignatureDeclaration): boolean { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 29a3383631d..ee1bf4846df 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -572,6 +572,31 @@ namespace FourSlash { } } + public verifyCompletionListStartsWithItemsInOrder(items: string[]): void { + if (items.length === 0) { + return; + } + + const entries = this.getCompletionListAtCaret().entries; + assert.isTrue(items.length <= entries.length, `Amount of expected items in completion list [ ${items.length} ] is greater than actual number of items in list [ ${entries.length} ]`); + for (let i = 0; i < items.length; i++) { + assert.equal(entries[i].name, items[i], `Unexpected item in completion list`); + } + } + + public noItemsWithSameNameButDifferentKind(): void { + const completions = this.getCompletionListAtCaret(); + const uniqueItems: ts.Map = {}; + for (const item of completions.entries) { + if (!ts.hasProperty(uniqueItems, item.name)) { + uniqueItems[item.name] = item.kind; + } + else { + assert.equal(item.kind, uniqueItems[item.name], `Items should have the same kind, got ${item.kind} and ${uniqueItems[item.name]}`); + } + } + } + public verifyMemberListIsEmpty(negative: boolean) { const members = this.getMemberListAtCaret(); if ((!members || members.entries.length === 0) && negative) { diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 0144d752b99..9970749e5a8 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1255,7 +1255,7 @@ interface Console { select(element: Element): void; time(timerName?: string): void; timeEnd(timerName?: string): void; - trace(): void; + trace(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; } @@ -1514,9 +1514,9 @@ interface DataTransferItemList { length: number; add(data: File): DataTransferItem; clear(): void; - item(index: number): File; + item(index: number): DataTransferItem; remove(index: number): void; - [index: number]: File; + [index: number]: DataTransferItem; } declare var DataTransferItemList: { @@ -2569,6 +2569,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param content The text and HTML tags to write. */ writeln(...content: string[]): void; + createElement(tagName: "picture"): HTMLPictureElement; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -2981,6 +2983,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitRequestFullscreen(): void; getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; + getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3770,6 +3773,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. */ toDataURL(type?: string, ...args: any[]): string; + toBlob(): Blob; } declare var HTMLCanvasElement: { @@ -6924,7 +6928,7 @@ interface IDBDatabase extends EventTarget { objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; - version: string; + version: number; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; @@ -7640,7 +7644,7 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: number; + readyState: string; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; endOfStream(error?: number): void; @@ -10369,17 +10373,16 @@ declare var Storage: { } interface StorageEvent extends Event { - key: string; - newValue: any; - oldValue: any; - storageArea: Storage; url: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; } declare var StorageEvent: { prototype: StorageEvent; - new(): StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; } interface StyleMedia { @@ -11977,7 +11980,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window msMatchMedia(mediaQuery: string): MediaQueryList; msRequestAnimationFrame(callback: FrameRequestCallback): number; msWriteProfilerMark(profilerMarkName: string): void; - open(url?: string, target?: string, features?: string, replace?: boolean): any; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; postMessage(message: any, targetOrigin: string, ports?: any): void; print(): void; prompt(message?: string, _default?: string): string; @@ -12579,6 +12582,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + interface IDBObjectStoreParameters { keyPath?: string | string[]; autoIncrement?: boolean; @@ -12633,6 +12644,14 @@ declare var HTMLTemplateElement: { new(): HTMLTemplateElement; } +interface HTMLPictureElement extends HTMLElement { +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -12829,7 +12848,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void; declare function msMatchMedia(mediaQuery: string): MediaQueryList; declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): any; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; declare function postMessage(message: any, targetOrigin: string, ports?: any): void; declare function print(): void; declare function prompt(message?: string, _default?: string): string; diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 44e5e49f984..f5d6b06bc47 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -819,7 +819,6 @@ interface MapConstructor { declare var Map: MapConstructor; interface WeakMap { - clear(): void; delete(key: K): boolean; get(key: K): V; has(key: K): boolean; @@ -859,7 +858,6 @@ declare var Set: SetConstructor; interface WeakSet { add(value: T): WeakSet; - clear(): void; delete(value: T): boolean; has(value: T): boolean; [Symbol.toStringTag]: "WeakSet"; diff --git a/src/lib/es7.d.ts b/src/lib/es7.d.ts new file mode 100644 index 00000000000..17b3eaac1d3 --- /dev/null +++ b/src/lib/es7.d.ts @@ -0,0 +1,89 @@ +interface Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: T, fromIndex?: number): boolean; +} + +interface Int8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8ClampedArray { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float64Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} \ No newline at end of file diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index a1d87f79787..d2008542cc6 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -69,7 +69,7 @@ interface Console { select(element: any): void; time(timerName?: string): void; timeEnd(timerName?: string): void; - trace(): void; + trace(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; } @@ -309,7 +309,7 @@ interface IDBDatabase extends EventTarget { objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; - version: string; + version: number; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 7cc3a6c96a6..e2ec5cc159f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -120,7 +120,7 @@ namespace ts.server { if (!resolution) { const existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); if (moduleResolutionIsValid(existingResolution)) { - // ok, it is safe to use existing module resolution results + // ok, it is safe to use existing module resolution results resolution = existingResolution; } else { @@ -145,8 +145,8 @@ namespace ts.server { } if (resolution.resolvedModule) { - // TODO: consider checking failedLookupLocations - // TODO: use lastCheckTime to track expiration for module name resolution + // TODO: consider checking failedLookupLocations + // TODO: use lastCheckTime to track expiration for module name resolution return true; } @@ -483,7 +483,7 @@ namespace ts.server { openFileRootsConfigured: ScriptInfo[] = []; // a path to directory watcher map that detects added tsconfig files directoryWatchersForTsconfig: ts.Map = {}; - // count of how many projects are using the directory watcher. If the + // count of how many projects are using the directory watcher. If the // number becomes 0 for a watcher, then we should close it. directoryWatchersRefCount: ts.Map = {}; hostConfiguration: HostConfiguration; @@ -564,11 +564,11 @@ namespace ts.server { // We check if the project file list has changed. If so, we update the project. if (!arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) { // For configured projects, the change is made outside the tsconfig file, and - // it is not likely to affect the project for other files opened by the client. We can + // it is not likely to affect the project for other files opened by the client. We can // just update the current project. this.updateConfiguredProject(project); - // Call updateProjectStructure to clean up inferred projects we may have + // Call updateProjectStructure to clean up inferred projects we may have // created for the new files this.updateProjectStructure(); } @@ -792,8 +792,8 @@ namespace ts.server { * @param info The file that has been closed or newly configured */ closeOpenFile(info: ScriptInfo) { - // Closing file should trigger re-reading the file content from disk. This is - // because the user may chose to discard the buffer content before saving + // Closing file should trigger re-reading the file content from disk. This is + // because the user may chose to discard the buffer content before saving // to the disk, and the server's version of the file can be out of sync. info.svc.reloadFromFile(info.fileName); @@ -891,8 +891,8 @@ namespace ts.server { } /** - * This function is to update the project structure for every projects. - * It is called on the premise that all the configured projects are + * This function is to update the project structure for every projects. + * It is called on the premise that all the configured projects are * up to date. */ updateProjectStructure() { @@ -946,7 +946,7 @@ namespace ts.server { if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) { // If the root file has already been added into a configured project, - // meaning the original inferred project is gone already. + // meaning the original inferred project is gone already. if (!rootedProject.isConfiguredProject()) { this.removeProject(rootedProject); } @@ -1026,10 +1026,16 @@ namespace ts.server { // the newly opened file. findConfigFile(searchPath: string): string { while (true) { - const fileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (this.host.fileExists(fileName)) { - return fileName; + const tsconfigFileName = ts.combinePaths(searchPath, "tsconfig.json"); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; } + + const jsconfigFileName = ts.combinePaths(searchPath, "jsconfig.json"); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + const parentPath = ts.getDirectoryPath(searchPath); if (parentPath === searchPath) { break; @@ -1053,9 +1059,9 @@ namespace ts.server { } /** - * This function tries to search for a tsconfig.json for the given file. If we found it, + * This function tries to search for a tsconfig.json for the given file. If we found it, * we first detect if there is already a configured project created for it: if so, we re-read - * the tsconfig file content and update the project; otherwise we create a new one. + * the tsconfig file content and update the project; otherwise we create a new one. */ openOrUpdateConfiguredProjectForFile(fileName: string) { const searchPath = ts.normalizePath(getDirectoryPath(fileName)); @@ -1180,7 +1186,7 @@ namespace ts.server { return { succeeded: false, error: rawConfig.error }; } else { - const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, /*existingOptions*/ {}, configFilename); Debug.assert(!!parsedCommandLine.fileNames); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { @@ -1259,7 +1265,7 @@ namespace ts.server { info = this.openFile(fileName, /*openedByClient*/ false); } else { - // if the root file was opened by client, it would belong to either + // if the root file was opened by client, it would belong to either // openFileRoots or openFileReferenced. if (info.isOpen) { if (this.openFileRoots.indexOf(info) >= 0) { diff --git a/src/server/session.ts b/src/server/session.ts index 9b9bf35a4a5..c1bafdf5ba8 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -792,7 +792,9 @@ namespace ts.server { } private closeClientFile(fileName: string) { - if (!fileName) { return; } + if (!fileName) { + return; + } const file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); } diff --git a/src/services/shims.ts b/src/services/shims.ts index 3dc28763b17..9ca3f19244d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -946,7 +946,8 @@ namespace ts { }; } - const configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName))); + const normalizedFileName = normalizeSlashes(fileName); + const configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); return { options: configFile.options, diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js index 7007c66ae28..450ded9d4f5 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js @@ -40,17 +40,12 @@ module M { } //// [asyncAwaitIsolatedModules_es6.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { - return new Promise(function (resolve, reject) { - generator = generator.call(thisArg, _arguments); - function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } - function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } - function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } - function step(verb, value) { - var result = generator[verb](value); - result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); - } - step("next", void 0); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); }); }; function f0() { diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js index 155a44d339d..61ed71198c8 100644 --- a/tests/baselines/reference/asyncAwait_es6.js +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -40,17 +40,12 @@ module M { } //// [asyncAwait_es6.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { - return new Promise(function (resolve, reject) { - generator = generator.call(thisArg, _arguments); - function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } - function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } - function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } - function step(verb, value) { - var result = generator[verb](value); - result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); - } - step("next", void 0); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); }); }; function f0() { diff --git a/tests/baselines/reference/asyncFunctionsAcrossFiles.js b/tests/baselines/reference/asyncFunctionsAcrossFiles.js new file mode 100644 index 00000000000..05b8ca56421 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionsAcrossFiles.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/asyncFunctionsAcrossFiles.ts] //// + +//// [a.ts] +import { b } from './b'; +export const a = { + f: async () => { + await b.f(); + } +}; +//// [b.ts] +import { a } from './a'; +export const b = { + f: async () => { + await a.f(); + } +}; + +//// [b.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); + }); +}; +import { a } from './a'; +export const b = { + f: () => __awaiter(this, void 0, Promise, function* () { + yield a.f(); + }) +}; +//// [a.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); + }); +}; +import { b } from './b'; +export const a = { + f: () => __awaiter(this, void 0, Promise, function* () { + yield b.f(); + }) +}; diff --git a/tests/baselines/reference/asyncFunctionsAcrossFiles.symbols b/tests/baselines/reference/asyncFunctionsAcrossFiles.symbols new file mode 100644 index 00000000000..2e9c52d5d91 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionsAcrossFiles.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/a.ts === +import { b } from './b'; +>b : Symbol(b, Decl(a.ts, 0, 8)) + +export const a = { +>a : Symbol(a, Decl(a.ts, 1, 12)) + + f: async () => { +>f : Symbol(f, Decl(a.ts, 1, 18)) + + await b.f(); +>b.f : Symbol(f, Decl(b.ts, 1, 18)) +>b : Symbol(b, Decl(a.ts, 0, 8)) +>f : Symbol(f, Decl(b.ts, 1, 18)) + } +}; +=== tests/cases/compiler/b.ts === +import { a } from './a'; +>a : Symbol(a, Decl(b.ts, 0, 8)) + +export const b = { +>b : Symbol(b, Decl(b.ts, 1, 12)) + + f: async () => { +>f : Symbol(f, Decl(b.ts, 1, 18)) + + await a.f(); +>a.f : Symbol(f, Decl(a.ts, 1, 18)) +>a : Symbol(a, Decl(b.ts, 0, 8)) +>f : Symbol(f, Decl(a.ts, 1, 18)) + } +}; diff --git a/tests/baselines/reference/asyncFunctionsAcrossFiles.types b/tests/baselines/reference/asyncFunctionsAcrossFiles.types new file mode 100644 index 00000000000..0b946141541 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionsAcrossFiles.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/a.ts === +import { b } from './b'; +>b : { f: () => Promise; } + +export const a = { +>a : { f: () => Promise; } +>{ f: async () => { await b.f(); }} : { f: () => Promise; } + + f: async () => { +>f : () => Promise +>async () => { await b.f(); } : () => Promise + + await b.f(); +>await b.f() : void +>b.f() : Promise +>b.f : () => Promise +>b : { f: () => Promise; } +>f : () => Promise + } +}; +=== tests/cases/compiler/b.ts === +import { a } from './a'; +>a : { f: () => Promise; } + +export const b = { +>b : { f: () => Promise; } +>{ f: async () => { await a.f(); }} : { f: () => Promise; } + + f: async () => { +>f : () => Promise +>async () => { await a.f(); } : () => Promise + + await a.f(); +>await a.f() : void +>a.f() : Promise +>a.f : () => Promise +>a : { f: () => Promise; } +>f : () => Promise + } +}; diff --git a/tests/baselines/reference/asyncImportedPromise_es6.js b/tests/baselines/reference/asyncImportedPromise_es6.js index a9c7540d88f..d861012488c 100644 --- a/tests/baselines/reference/asyncImportedPromise_es6.js +++ b/tests/baselines/reference/asyncImportedPromise_es6.js @@ -16,17 +16,12 @@ class Task extends Promise { exports.Task = Task; //// [test.js] "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { - return new Promise(function (resolve, reject) { - generator = generator.call(thisArg, _arguments); - function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } - function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } - function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } - function step(verb, value) { - var result = generator[verb](value); - result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); - } - step("next", void 0); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); }); }; var task_1 = require("./task"); diff --git a/tests/baselines/reference/asyncMultiFile.js b/tests/baselines/reference/asyncMultiFile.js index e93dc586255..95cf264f170 100644 --- a/tests/baselines/reference/asyncMultiFile.js +++ b/tests/baselines/reference/asyncMultiFile.js @@ -6,17 +6,12 @@ async function f() {} function g() { } //// [a.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { - return new Promise(function (resolve, reject) { - generator = generator.call(thisArg, _arguments); - function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } - function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } - function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } - function step(verb, value) { - var result = generator[verb](value); - result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); - } - step("next", void 0); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); }); }; function f() { diff --git a/tests/baselines/reference/classExtendsAcrossFiles.js b/tests/baselines/reference/classExtendsAcrossFiles.js new file mode 100644 index 00000000000..b533b880036 --- /dev/null +++ b/tests/baselines/reference/classExtendsAcrossFiles.js @@ -0,0 +1,71 @@ +//// [tests/cases/compiler/classExtendsAcrossFiles.ts] //// + +//// [a.ts] +import { b } from './b'; +export const a = { + f: () => { + class A { } + class B extends A { } + b.f(); + } +}; +//// [b.ts] +import { a } from './a'; +export const b = { + f: () => { + class A { } + class B extends A { } + a.f(); + } +}; + +//// [b.js] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var a_1 = require('./a'); +exports.b = { + f: function () { + var A = (function () { + function A() { + } + return A; + }()); + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + }(A)); + a_1.a.f(); + } +}; +//// [a.js] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var b_1 = require('./b'); +exports.a = { + f: function () { + var A = (function () { + function A() { + } + return A; + }()); + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + }(A)); + b_1.b.f(); + } +}; diff --git a/tests/baselines/reference/classExtendsAcrossFiles.symbols b/tests/baselines/reference/classExtendsAcrossFiles.symbols new file mode 100644 index 00000000000..cf81c923912 --- /dev/null +++ b/tests/baselines/reference/classExtendsAcrossFiles.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/a.ts === +import { b } from './b'; +>b : Symbol(b, Decl(a.ts, 0, 8)) + +export const a = { +>a : Symbol(a, Decl(a.ts, 1, 12)) + + f: () => { +>f : Symbol(f, Decl(a.ts, 1, 18)) + + class A { } +>A : Symbol(A, Decl(a.ts, 2, 14)) + + class B extends A { } +>B : Symbol(B, Decl(a.ts, 3, 19)) +>A : Symbol(A, Decl(a.ts, 2, 14)) + + b.f(); +>b.f : Symbol(f, Decl(b.ts, 1, 18)) +>b : Symbol(b, Decl(a.ts, 0, 8)) +>f : Symbol(f, Decl(b.ts, 1, 18)) + } +}; +=== tests/cases/compiler/b.ts === +import { a } from './a'; +>a : Symbol(a, Decl(b.ts, 0, 8)) + +export const b = { +>b : Symbol(b, Decl(b.ts, 1, 12)) + + f: () => { +>f : Symbol(f, Decl(b.ts, 1, 18)) + + class A { } +>A : Symbol(A, Decl(b.ts, 2, 14)) + + class B extends A { } +>B : Symbol(B, Decl(b.ts, 3, 19)) +>A : Symbol(A, Decl(b.ts, 2, 14)) + + a.f(); +>a.f : Symbol(f, Decl(a.ts, 1, 18)) +>a : Symbol(a, Decl(b.ts, 0, 8)) +>f : Symbol(f, Decl(a.ts, 1, 18)) + } +}; diff --git a/tests/baselines/reference/classExtendsAcrossFiles.types b/tests/baselines/reference/classExtendsAcrossFiles.types new file mode 100644 index 00000000000..fe3427ba043 --- /dev/null +++ b/tests/baselines/reference/classExtendsAcrossFiles.types @@ -0,0 +1,52 @@ +=== tests/cases/compiler/a.ts === +import { b } from './b'; +>b : { f: () => void; } + +export const a = { +>a : { f: () => void; } +>{ f: () => { class A { } class B extends A { } b.f(); }} : { f: () => void; } + + f: () => { +>f : () => void +>() => { class A { } class B extends A { } b.f(); } : () => void + + class A { } +>A : A + + class B extends A { } +>B : B +>A : A + + b.f(); +>b.f() : void +>b.f : () => void +>b : { f: () => void; } +>f : () => void + } +}; +=== tests/cases/compiler/b.ts === +import { a } from './a'; +>a : { f: () => void; } + +export const b = { +>b : { f: () => void; } +>{ f: () => { class A { } class B extends A { } a.f(); }} : { f: () => void; } + + f: () => { +>f : () => void +>() => { class A { } class B extends A { } a.f(); } : () => void + + class A { } +>A : A + + class B extends A { } +>B : B +>A : A + + a.f(); +>a.f() : void +>a.f : () => void +>a : { f: () => void; } +>f : () => void + } +}; diff --git a/tests/baselines/reference/jsFileCompilationSyntaxError.errors.txt b/tests/baselines/reference/jsFileCompilationSyntaxError.errors.txt index 6e55ff30f04..d98a1e7e7bb 100644 --- a/tests/baselines/reference/jsFileCompilationSyntaxError.errors.txt +++ b/tests/baselines/reference/jsFileCompilationSyntaxError.errors.txt @@ -1,14 +1,11 @@ error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -tests/cases/compiler/a.js(3,6): error TS1223: 'type' tag already specified. !!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -==== tests/cases/compiler/a.js (1 errors) ==== +==== tests/cases/compiler/a.js (0 errors) ==== /** * @type {number} * @type {string} - ~~~~ -!!! error TS1223: 'type' tag already specified. */ var v; \ No newline at end of file diff --git a/tests/baselines/reference/reExportUndefined1.errors.txt b/tests/baselines/reference/reExportUndefined1.errors.txt new file mode 100644 index 00000000000..ff3259ae37e --- /dev/null +++ b/tests/baselines/reference/reExportUndefined1.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/a.ts(2,10): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/a.ts (1 errors) ==== + + export { undefined }; + ~~~~~~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. \ No newline at end of file diff --git a/tests/baselines/reference/reExportUndefined1.js b/tests/baselines/reference/reExportUndefined1.js new file mode 100644 index 00000000000..94729e4f544 --- /dev/null +++ b/tests/baselines/reference/reExportUndefined1.js @@ -0,0 +1,6 @@ +//// [a.ts] + +export { undefined }; + +//// [a.js] +"use strict"; diff --git a/tests/baselines/reference/reExportUndefined2.js b/tests/baselines/reference/reExportUndefined2.js new file mode 100644 index 00000000000..53b78599cbe --- /dev/null +++ b/tests/baselines/reference/reExportUndefined2.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/reExportUndefined2.ts] //// + +//// [a.ts] + +var undefined; +export { undefined }; + +//// [b.ts] +import { undefined } from "./a"; +declare function use(a: number); +use(undefined); + +//// [a.js] +"use strict"; +var undefined; +exports.undefined = undefined; +//// [b.js] +"use strict"; +var a_1 = require("./a"); +use(a_1.undefined); diff --git a/tests/baselines/reference/reExportUndefined2.symbols b/tests/baselines/reference/reExportUndefined2.symbols new file mode 100644 index 00000000000..c4f532ed6dc --- /dev/null +++ b/tests/baselines/reference/reExportUndefined2.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.ts === + +var undefined; +>undefined : Symbol(undefined, Decl(a.ts, 1, 3)) + +export { undefined }; +>undefined : Symbol(undefined, Decl(a.ts, 2, 8)) + +=== tests/cases/compiler/b.ts === +import { undefined } from "./a"; +>undefined : Symbol(undefined, Decl(b.ts, 0, 8)) + +declare function use(a: number); +>use : Symbol(use, Decl(b.ts, 0, 32)) +>a : Symbol(a, Decl(b.ts, 1, 21)) + +use(undefined); +>use : Symbol(use, Decl(b.ts, 0, 32)) +>undefined : Symbol(undefined, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/reExportUndefined2.types b/tests/baselines/reference/reExportUndefined2.types new file mode 100644 index 00000000000..d3f3dc9d726 --- /dev/null +++ b/tests/baselines/reference/reExportUndefined2.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/a.ts === + +var undefined; +>undefined : any + +export { undefined }; +>undefined : any + +=== tests/cases/compiler/b.ts === +import { undefined } from "./a"; +>undefined : any + +declare function use(a: number); +>use : (a: number) => any +>a : number + +use(undefined); +>use(undefined) : any +>use : (a: number) => any +>undefined : any + diff --git a/tests/baselines/reference/reachabilityChecks7.js b/tests/baselines/reference/reachabilityChecks7.js index c78f99953e9..39b7b0149a5 100644 --- a/tests/baselines/reference/reachabilityChecks7.js +++ b/tests/baselines/reference/reachabilityChecks7.js @@ -31,17 +31,12 @@ declare function use(s: string): void; let x1 = () => { use("Test"); } //// [reachabilityChecks7.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { - return new Promise(function (resolve, reject) { - generator = generator.call(thisArg, _arguments); - function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } - function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } - function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } - function step(verb, value) { - var result = generator[verb](value); - result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); - } - step("next", void 0); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new P(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.call(thisArg, _arguments)).next()); }); }; // async function without return type annotation - error diff --git a/tests/cases/compiler/asyncFunctionsAcrossFiles.ts b/tests/cases/compiler/asyncFunctionsAcrossFiles.ts new file mode 100644 index 00000000000..c5f6a220fd8 --- /dev/null +++ b/tests/cases/compiler/asyncFunctionsAcrossFiles.ts @@ -0,0 +1,15 @@ +// @target: es6 +// @filename: a.ts +import { b } from './b'; +export const a = { + f: async () => { + await b.f(); + } +}; +// @filename: b.ts +import { a } from './a'; +export const b = { + f: async () => { + await a.f(); + } +}; \ No newline at end of file diff --git a/tests/cases/compiler/classExtendsAcrossFiles.ts b/tests/cases/compiler/classExtendsAcrossFiles.ts new file mode 100644 index 00000000000..14e227647e7 --- /dev/null +++ b/tests/cases/compiler/classExtendsAcrossFiles.ts @@ -0,0 +1,20 @@ +// @target: es5 +// @module: commonjs +// @filename: a.ts +import { b } from './b'; +export const a = { + f: () => { + class A { } + class B extends A { } + b.f(); + } +}; +// @filename: b.ts +import { a } from './a'; +export const b = { + f: () => { + class A { } + class B extends A { } + a.f(); + } +}; \ No newline at end of file diff --git a/tests/cases/compiler/reExportUndefined1.ts b/tests/cases/compiler/reExportUndefined1.ts new file mode 100644 index 00000000000..7d949ca1c28 --- /dev/null +++ b/tests/cases/compiler/reExportUndefined1.ts @@ -0,0 +1,4 @@ +// @module: commonjs + +// @filename: a.ts +export { undefined }; \ No newline at end of file diff --git a/tests/cases/compiler/reExportUndefined2.ts b/tests/cases/compiler/reExportUndefined2.ts new file mode 100644 index 00000000000..0d3e381fcfa --- /dev/null +++ b/tests/cases/compiler/reExportUndefined2.ts @@ -0,0 +1,10 @@ +// @module: commonjs + +// @filename: a.ts +var undefined; +export { undefined }; + +// @filename: b.ts +import { undefined } from "./a"; +declare function use(a: number); +use(undefined); \ No newline at end of file diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index 80516303856..e5cc7a3d2b6 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -23,11 +23,8 @@ ////// @pa/*7*/ ////var v7; //// -/////** @param { n/*8*/ } */ +/////** @return { n/*8*/ } */ ////var v8; -//// -/////** @return { n/*9*/ } */ -////var v9; goTo.marker('1'); verify.completionListContains("constructor"); @@ -57,6 +54,3 @@ verify.completionListIsEmpty(); goTo.marker('8'); verify.completionListContains('number'); -goTo.marker('9'); -verify.completionListContains('number'); - diff --git a/tests/cases/fourslash/getJavaScriptCompletions1.ts b/tests/cases/fourslash/getJavaScriptCompletions1.ts new file mode 100644 index 00000000000..6d8f36aac1b --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions1.ts @@ -0,0 +1,10 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @type {number} */ +////var v; +////v./**/ + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/getJavaScriptCompletions10.ts b/tests/cases/fourslash/getJavaScriptCompletions10.ts new file mode 100644 index 00000000000..5fbd91e8988 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions10.ts @@ -0,0 +1,11 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** +//// * @type {function(this:number)} +//// */ +////function f() { this./**/ } + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions11.ts b/tests/cases/fourslash/getJavaScriptCompletions11.ts new file mode 100644 index 00000000000..f12f53fa960 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions11.ts @@ -0,0 +1,11 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @type {number|string} */ +////var v; +////v./**/ + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completionListContains("charCodeAt", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions12.ts b/tests/cases/fourslash/getJavaScriptCompletions12.ts new file mode 100644 index 00000000000..99b14828854 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions12.ts @@ -0,0 +1,36 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** +//// * @param {number} input +//// * @param {string} currency +//// * @returns {number} +//// */ +////var convert = function(input, currency) { +//// switch(currency./*1*/) { +//// case "USD": +//// input./*2*/; +//// case "EUR": +//// return "" + rateToUsd.EUR; +//// case "CNY": +//// return {} + rateToUsd.CNY; +//// } +////} +////convert(1, "")./*3*/ +/////** +//// * @param {number} x +//// */ +////var test1 = function(x) { return x./*4*/ }, test2 = function(a) { return a./*5*/ }; + + +goTo.marker("1"); +verify.completionListContains("charCodeAt", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +goTo.marker("2"); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +goTo.marker("3"); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +goTo.marker("4"); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +goTo.marker("5"); +verify.completionListContains("test1", /*displayText:*/ undefined, /*documentation*/ undefined, "warning"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions13.ts b/tests/cases/fourslash/getJavaScriptCompletions13.ts new file mode 100644 index 00000000000..438c73e304c --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions13.ts @@ -0,0 +1,26 @@ +/// +// @allowNonTsExtensions: true + +// @Filename: file1.js + +////var file1Identifier = 1; +////interface Foo { FooProp: number }; + +// @Filename: file2.js + +////var file2Identifier1 = 2; +////var file2Identifier2 = 2; +/////*1*/ +////file2Identifier2./*2*/ + +goTo.marker("1"); +verify.completionListContains("file2Identifier1"); +verify.completionListContains("file2Identifier2"); +verify.completionListContains("file1Identifier"); +verify.not.completionListContains("FooProp"); + +goTo.marker("2"); +verify.completionListContains("file2Identifier1"); +verify.completionListContains("file2Identifier2"); +verify.not.completionListContains("file1Identifier") +verify.not.completionListContains("FooProp"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions14.ts b/tests/cases/fourslash/getJavaScriptCompletions14.ts new file mode 100644 index 00000000000..52a23065a5e --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions14.ts @@ -0,0 +1,13 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file1.js +/////// +////interface Number { +//// toExponential(fractionDigits?: number): string; +////} +////var x = 1; +////x./*1*/ + +goTo.marker("1"); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/getJavaScriptCompletions15.ts b/tests/cases/fourslash/getJavaScriptCompletions15.ts new file mode 100644 index 00000000000..fbcbc2d4692 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions15.ts @@ -0,0 +1,29 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: refFile1.ts +//// export var V = 1; + +// @Filename: refFile2.ts +//// export var V = "123" + +// @Filename: refFile3.ts +//// export var V = "123" + +// @Filename: main.js +//// import ref1 = require("refFile1"); +//// var ref2 = require("refFile2"); +//// ref1.V./*1*/; +//// ref2.V./*2*/; +//// var v = { x: require("refFile3") }; +//// v.x./*3*/; +//// v.x.V./*4*/; + +goTo.marker("1"); +verify.completionListContains("toExponential"); +goTo.marker("2"); +verify.completionListContains("toLowerCase"); +goTo.marker("3"); +verify.completionListContains("V"); +goTo.marker("4"); +verify.completionListContains("toLowerCase"); diff --git a/tests/cases/fourslash/getJavaScriptCompletions2.ts b/tests/cases/fourslash/getJavaScriptCompletions2.ts new file mode 100644 index 00000000000..0cb2de046a6 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions2.ts @@ -0,0 +1,10 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @type {(number|string)} */ +////var v; +////v./**/ + +goTo.marker(); +verify.completionListContains("valueOf", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions3.ts b/tests/cases/fourslash/getJavaScriptCompletions3.ts new file mode 100644 index 00000000000..13a6f1673e6 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions3.ts @@ -0,0 +1,10 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @type {Array.} */ +////var v; +////v./**/ + +goTo.marker(); +verify.completionListContains("concat", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions4.ts b/tests/cases/fourslash/getJavaScriptCompletions4.ts new file mode 100644 index 00000000000..3719b8e1258 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions4.ts @@ -0,0 +1,10 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @return {number} */ +////function foo(a,b) { } +////foo(1,2)./**/ + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions5.ts b/tests/cases/fourslash/getJavaScriptCompletions5.ts new file mode 100644 index 00000000000..348feef94c3 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions5.ts @@ -0,0 +1,15 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// /** +//// * @template T +//// * @param {T} a +//// * @return {T} */ +//// function foo(a) { } +//// let x = /*1*/foo; +//// foo(1)./**/ + +goTo.marker('1'); +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/getJavaScriptCompletions6.ts b/tests/cases/fourslash/getJavaScriptCompletions6.ts new file mode 100644 index 00000000000..9f9a42b5762 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions6.ts @@ -0,0 +1,13 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** +//// * @param {...number} a +//// */ +////function foo(a) { +//// a./**/ +////} + +goTo.marker(); +verify.completionListContains("concat", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions7.ts b/tests/cases/fourslash/getJavaScriptCompletions7.ts new file mode 100644 index 00000000000..d8b01cfb757 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions7.ts @@ -0,0 +1,13 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** +//// * @param {...number} a +//// */ +////function foo(a) { +//// a[0]./**/ +////} + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions8.ts b/tests/cases/fourslash/getJavaScriptCompletions8.ts new file mode 100644 index 00000000000..418aae676be --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions8.ts @@ -0,0 +1,12 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** +//// * @type {function(): number} +//// */ +////var v; +////v()./**/ + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions9.ts b/tests/cases/fourslash/getJavaScriptCompletions9.ts new file mode 100644 index 00000000000..1619a2ca9fc --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions9.ts @@ -0,0 +1,12 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** +//// * @type {function(new:number)} +//// */ +////var v; +////new v()./**/ + +goTo.marker(); +verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo1.ts b/tests/cases/fourslash/getJavaScriptQuickInfo1.ts new file mode 100644 index 00000000000..71072f1699a --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo1.ts @@ -0,0 +1,9 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @type {function(new:string,number)} */ +////var /**/v; + +goTo.marker(); +verify.quickInfoIs('var v: new (p1: number) => string'); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo2.ts b/tests/cases/fourslash/getJavaScriptQuickInfo2.ts new file mode 100644 index 00000000000..ce347a62b27 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo2.ts @@ -0,0 +1,9 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @param {number} [a] */ +////function /**/f(a) { } + +goTo.marker(); +verify.quickInfoIs('function f(a?: number): void'); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo3.ts b/tests/cases/fourslash/getJavaScriptQuickInfo3.ts new file mode 100644 index 00000000000..2e094bd21f6 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo3.ts @@ -0,0 +1,9 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @param {number[]} [a] */ +////function /**/f(a) { } + +goTo.marker(); +verify.quickInfoIs('function f(a?: number[]): void'); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo4.ts b/tests/cases/fourslash/getJavaScriptQuickInfo4.ts new file mode 100644 index 00000000000..34ee10d97b7 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo4.ts @@ -0,0 +1,9 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @param {[number,string]} [a] */ +////function /**/f(a) { } + +goTo.marker(); +verify.quickInfoIs('function f(a?: [number, string]): void'); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo5.ts b/tests/cases/fourslash/getJavaScriptQuickInfo5.ts new file mode 100644 index 00000000000..004af0811b7 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo5.ts @@ -0,0 +1,9 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @param {{b:number}} [a] */ +////function /**/f(a) { } + +goTo.marker(); +verify.quickInfoIs('function f(a?: {\n b: number;\n}): void'); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo6.ts b/tests/cases/fourslash/getJavaScriptQuickInfo6.ts new file mode 100644 index 00000000000..3aebd19deda --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo6.ts @@ -0,0 +1,9 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @type {function(this:number)} */ +////function f() { /**/this } + +goTo.marker(); +verify.quickInfoIs('number'); \ No newline at end of file diff --git a/tests/cases/fourslash/javaScriptModulesError1.ts b/tests/cases/fourslash/javaScriptModulesError1.ts new file mode 100644 index 00000000000..f13b25a182e --- /dev/null +++ b/tests/cases/fourslash/javaScriptModulesError1.ts @@ -0,0 +1,12 @@ +/// + +// Error: Having more function parameters than entries in the dependency array + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// define('mod1', ['a'], /**/function(a, b) { +//// +//// }); + +// TODO: what should happen? +goTo.marker(); \ No newline at end of file diff --git a/tests/cases/unittests/jsDocParsing.ts b/tests/cases/unittests/jsDocParsing.ts index ebba6e8a1a6..9988383b467 100644 --- a/tests/cases/unittests/jsDocParsing.ts +++ b/tests/cases/unittests/jsDocParsing.ts @@ -1,4 +1,5 @@ /// +/// /// /// @@ -985,15 +986,29 @@ module ts { describe("DocComments", () => { function parsesCorrectly(content: string, expected: string) { let comment = parseIsolatedJSDocComment(content); - Debug.assert(comment && comment.diagnostics.length === 0); + if (!comment) { + Debug.fail('Comment failed to parse entirely'); + } + if (comment.diagnostics.length > 0) { + Debug.fail('Comment has at least one diagnostic: ' + comment.diagnostics[0].messageText); + } let result = JSON.stringify(comment.jsDocComment, (k, v) => { return v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v; - }, " "); + }, 4); - assert.equal(result, expected); + if (result !== expected) { + // Turn on a human-readable diff + if (typeof require !== 'undefined') { + require('chai').config.showDiff = true; + chai.expect(JSON.parse(result)).equal(JSON.parse(expected)); + } + else { + assert.equal(result, expected); + } + } } function parsesIncorrectly(content: string) { @@ -1577,7 +1592,7 @@ module ts { "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 30, + "end": 31, "atToken": { "kind": "AtToken", "pos": 8, @@ -1609,7 +1624,7 @@ module ts { }, "length": 1, "pos": 8, - "end": 30 + "end": 31 } }`); }); @@ -1627,7 +1642,7 @@ module ts { "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 31, + "end": 36, "atToken": { "kind": "AtToken", "pos": 8, @@ -1659,7 +1674,7 @@ module ts { }, "length": 1, "pos": 8, - "end": 31 + "end": 36 } }`); }); @@ -2113,7 +2128,7 @@ module ts { "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 24, + "end": 23, "atToken": { "kind": "AtToken", "pos": 8, @@ -2150,12 +2165,12 @@ module ts { }, "length": 2, "pos": 17, - "end": 24 + "end": 23 } }, "length": 1, "pos": 8, - "end": 24 + "end": 23 } }`); });