diff --git a/.gitignore b/.gitignore index 658c4d0d8ea..f487ea6dd29 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ scripts/*.js.map coverage/ internal/ **/.DS_Store +.settings/ diff --git a/.npmignore b/.npmignore index 98c50479c69..2b75d37f70a 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,5 @@ scripts src tests Jakefile -.travis.yml \ No newline at end of file +.travis.yml +.settings/ \ No newline at end of file diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index 3344cf3197d..902962cae51 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -1237,11 +1237,41 @@ interface SymbolConstructor { isConcatSpreadable: symbol; /** - * A method that returns the default iterator for an object.Called by the semantics of the + * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ iterator: symbol; + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + split: symbol; + /** * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive * abstract operation. @@ -4728,6 +4758,16 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; +} + /** * Represents the completion of an asynchronous operation */ @@ -4738,14 +4778,16 @@ interface Promise { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; /** * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of the callback. */ - catch(onrejected?: (reason: any) => T | Promise): Promise; + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + + [Symbol.toStringTag]: string; } interface PromiseConstructor { @@ -4756,13 +4798,11 @@ interface PromiseConstructor { /** * Creates a new Promise. - * @param init A callback used to initialize the promise. This callback is passed two arguments: + * @param executor A callback used to initialize the promise. This callback is passed two arguments: * a resolve callback used resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ - new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; - - (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -4770,15 +4810,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: (T | Promise)[]): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of values. - * @returns A new Promise. - */ - all(values: Promise[]): Promise; + all(values: Iterable>): Promise; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved @@ -4786,7 +4818,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: (T | Promise)[]): Promise; + race(values: Iterable>): Promise; /** * Creates a new rejected promise for the provided reason. @@ -4807,13 +4839,15 @@ interface PromiseConstructor { * @param value A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | Promise): Promise; + resolve(value: T | PromiseLike): Promise; /** * Creates a new resolved promise . * @returns A resolved promise. */ resolve(): Promise; + + [Symbol.species]: Function; } declare var Promise: PromiseConstructor; diff --git a/bin/lib.d.ts b/bin/lib.d.ts index 17e87597583..e583f1ac783 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -1231,6 +1231,139 @@ interface ArrayBufferView { byteOffset: number; } +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. @@ -7222,6 +7355,8 @@ interface HTMLCanvasElement extends HTMLElement { * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext; /** * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. @@ -15703,6 +15838,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { overrideMimeType(mime: string): void; send(data?: Document): void; send(data?: string): void; + send(data?: any): void; setRequestHeader(header: string, value: string): void; DONE: number; HEADERS_RECEIVED: number; @@ -15857,11 +15993,13 @@ interface DocumentEvent { createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface: "CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; createEvent(eventInterface:"ErrorEvent"): ErrorEvent; createEvent(eventInterface:"Event"): Event; + createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; @@ -15876,8 +16014,12 @@ interface DocumentEvent { createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; + createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; createEvent(eventInterface:"NavigationEvent"): NavigationEvent; createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; @@ -15888,6 +16030,7 @@ interface DocumentEvent { createEvent(eventInterface:"PopStateEvent"): PopStateEvent; createEvent(eventInterface:"ProgressEvent"): ProgressEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; @@ -15895,6 +16038,7 @@ interface DocumentEvent { createEvent(eventInterface:"TrackEvent"): TrackEvent; createEvent(eventInterface:"TransitionEvent"): TransitionEvent; createEvent(eventInterface:"UIEvent"): UIEvent; + createEvent(eventInterface:"UIEvents"): UIEvent; createEvent(eventInterface:"UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; createEvent(eventInterface:"WebGLContextEvent"): WebGLContextEvent; createEvent(eventInterface:"WheelEvent"): WheelEvent; diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index 2c970a1cf52..142486a1662 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -61,6 +61,139 @@ interface ArrayBufferView { byteOffset: number; } +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. @@ -6052,6 +6185,8 @@ interface HTMLCanvasElement extends HTMLElement { * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext; /** * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. @@ -14533,6 +14668,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { overrideMimeType(mime: string): void; send(data?: Document): void; send(data?: string): void; + send(data?: any): void; setRequestHeader(header: string, value: string): void; DONE: number; HEADERS_RECEIVED: number; @@ -14687,11 +14823,13 @@ interface DocumentEvent { createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface: "CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; createEvent(eventInterface:"ErrorEvent"): ErrorEvent; createEvent(eventInterface:"Event"): Event; + createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; @@ -14706,8 +14844,12 @@ interface DocumentEvent { createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; + createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; createEvent(eventInterface:"NavigationEvent"): NavigationEvent; createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; @@ -14718,6 +14860,7 @@ interface DocumentEvent { createEvent(eventInterface:"PopStateEvent"): PopStateEvent; createEvent(eventInterface:"ProgressEvent"): ProgressEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; @@ -14725,6 +14868,7 @@ interface DocumentEvent { createEvent(eventInterface:"TrackEvent"): TrackEvent; createEvent(eventInterface:"TransitionEvent"): TransitionEvent; createEvent(eventInterface:"UIEvent"): UIEvent; + createEvent(eventInterface:"UIEvents"): UIEvent; createEvent(eventInterface:"UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; createEvent(eventInterface:"WebGLContextEvent"): WebGLContextEvent; createEvent(eventInterface:"WheelEvent"): WheelEvent; diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index c2361d833d1..f839a3e3a0b 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -1237,11 +1237,41 @@ interface SymbolConstructor { isConcatSpreadable: symbol; /** - * A method that returns the default iterator for an object.Called by the semantics of the + * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ iterator: symbol; + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + split: symbol; + /** * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive * abstract operation. @@ -4728,6 +4758,16 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; +} + /** * Represents the completion of an asynchronous operation */ @@ -4738,14 +4778,16 @@ interface Promise { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; /** * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of the callback. */ - catch(onrejected?: (reason: any) => T | Promise): Promise; + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + + [Symbol.toStringTag]: string; } interface PromiseConstructor { @@ -4756,13 +4798,11 @@ interface PromiseConstructor { /** * Creates a new Promise. - * @param init A callback used to initialize the promise. This callback is passed two arguments: + * @param executor A callback used to initialize the promise. This callback is passed two arguments: * a resolve callback used resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ - new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; - - (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -4770,15 +4810,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: (T | Promise)[]): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of values. - * @returns A new Promise. - */ - all(values: Promise[]): Promise; + all(values: Iterable>): Promise; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved @@ -4786,7 +4818,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: (T | Promise)[]): Promise; + race(values: Iterable>): Promise; /** * Creates a new rejected promise for the provided reason. @@ -4807,13 +4839,15 @@ interface PromiseConstructor { * @param value A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | Promise): Promise; + resolve(value: T | PromiseLike): Promise; /** * Creates a new resolved promise . * @returns A resolved promise. */ resolve(): Promise; + + [Symbol.species]: Function; } declare var Promise: PromiseConstructor; @@ -8700,6 +8734,8 @@ interface HTMLCanvasElement extends HTMLElement { * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext; /** * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. @@ -17181,6 +17217,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { overrideMimeType(mime: string): void; send(data?: Document): void; send(data?: string): void; + send(data?: any): void; setRequestHeader(header: string, value: string): void; DONE: number; HEADERS_RECEIVED: number; @@ -17335,11 +17372,13 @@ interface DocumentEvent { createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface: "CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; createEvent(eventInterface:"ErrorEvent"): ErrorEvent; createEvent(eventInterface:"Event"): Event; + createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; @@ -17354,8 +17393,12 @@ interface DocumentEvent { createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; + createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; createEvent(eventInterface:"NavigationEvent"): NavigationEvent; createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; @@ -17366,6 +17409,7 @@ interface DocumentEvent { createEvent(eventInterface:"PopStateEvent"): PopStateEvent; createEvent(eventInterface:"ProgressEvent"): ProgressEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; @@ -17373,6 +17417,7 @@ interface DocumentEvent { createEvent(eventInterface:"TrackEvent"): TrackEvent; createEvent(eventInterface:"TransitionEvent"): TransitionEvent; createEvent(eventInterface:"UIEvent"): UIEvent; + createEvent(eventInterface:"UIEvents"): UIEvent; createEvent(eventInterface:"UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; createEvent(eventInterface:"WebGLContextEvent"): WebGLContextEvent; createEvent(eventInterface:"WheelEvent"): WheelEvent; diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts index 740ebe94fa6..1704e07f75a 100644 --- a/bin/lib.webworker.d.ts +++ b/bin/lib.webworker.d.ts @@ -61,6 +61,139 @@ interface ArrayBufferView { byteOffset: number; } +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. diff --git a/bin/tsc.js b/bin/tsc.js index 49db1f2cb85..2bde9314b4d 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -444,7 +444,7 @@ var ts; for (var _i = 0; _i < parts.length; _i++) { var part = parts[_i]; if (part !== ".") { - if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); } else { @@ -536,7 +536,7 @@ var ts; function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { directoryComponents.length--; } for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { @@ -960,7 +960,7 @@ var ts; A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, @@ -1021,8 +1021,8 @@ var ts; or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, @@ -1064,9 +1064,9 @@ var ts; The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, @@ -1075,28 +1075,27 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, + Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, @@ -1119,7 +1118,7 @@ var ts; Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, @@ -1211,15 +1210,15 @@ var ts; Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, @@ -1273,11 +1272,13 @@ var ts; Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "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}'." }, 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}'." }, @@ -1353,6 +1354,7 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, @@ -1366,6 +1368,10 @@ var ts; Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, + Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1377,7 +1383,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1398,7 +1404,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -1412,6 +1418,9 @@ var ts; Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1424,7 +1433,6 @@ var ts; 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." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, @@ -1480,7 +1488,7 @@ var ts; "false": 80, "finally": 81, "for": 82, - "from": 124, + "from": 125, "function": 83, "get": 116, "if": 84, @@ -1491,33 +1499,34 @@ var ts; "interface": 103, "let": 104, "module": 117, + "namespace": 118, "new": 88, "null": 89, - "number": 119, + "number": 120, "package": 105, "private": 106, "protected": 107, "public": 108, - "require": 118, + "require": 119, "return": 90, - "set": 120, + "set": 121, "static": 109, - "string": 121, + "string": 122, "super": 91, "switch": 92, - "symbol": 122, + "symbol": 123, "this": 93, "throw": 94, "true": 95, "try": 96, - "type": 123, + "type": 124, "typeof": 97, "var": 98, "void": 99, "while": 100, "with": 101, "yield": 110, - "of": 125, + "of": 126, "{": 14, "}": 15, "(": 16, @@ -1839,7 +1848,7 @@ var ts; } collecting = true; if (result && result.length) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } continue; case 9: @@ -1885,7 +1894,7 @@ var ts; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { if (result && result.length && isLineBreak(ch)) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } pos++; continue; @@ -2703,16 +2712,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 202 || node.kind === 203) { + if (node.kind === 203 || node.kind === 204) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 209 || node.kind === 208) && !(node.flags & 1)) { + else if ((node.kind === 210 || node.kind === 209) && !(node.flags & 1)) { return 0; } - else if (node.kind === 206) { + else if (node.kind === 207) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2728,7 +2737,7 @@ var ts; }); return state; } - else if (node.kind === 205) { + else if (node.kind === 206) { return getModuleInstanceState(node.body); } else { @@ -2781,10 +2790,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 205 && node.name.kind === 8) { + if (node.kind === 206 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 127) { + if (node.name.kind === 128) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -2792,22 +2801,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 143: - case 135: + case 144: + case 136: return "__constructor"; - case 142: - case 138: - return "__call"; + case 143: case 139: - return "__new"; + return "__call"; case 140: + return "__new"; + case 141: return "__index"; - case 215: + case 216: return "__export"; - case 214: + case 215: return node.isExportEquals ? "export=" : "default"; - case 200: case 201: + case 202: return node.flags & 256 ? "default" : undefined; } } @@ -2839,7 +2848,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if ((node.kind === 201 || node.kind === 174) && symbol.exports) { + if ((node.kind === 202 || node.kind === 175) && symbol.exports) { var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { @@ -2855,7 +2864,7 @@ var ts; function declareModuleMember(node, symbolKind, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolKind & 8388608) { - if (node.kind === 217 || (node.kind === 208 && hasExportModifier)) { + if (node.kind === 218 || (node.kind === 209 && hasExportModifier)) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); } else { @@ -2863,7 +2872,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 32768) { + if (hasExportModifier || container.flags & 65536) { var exportKind = (symbolKind & 107455 ? 1048576 : 0) | (symbolKind & 793056 ? 2097152 : 0) | (symbolKind & 1536 ? 4194304 : 0); @@ -2889,7 +2898,7 @@ var ts; addToContainerChain(container); } if (isBlockScopeContainer) { - setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 227); + setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 228); } ts.forEachChild(node, bind); container = saveContainer; @@ -2904,41 +2913,41 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 205: + case 206: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227: + case 228: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 142: case 143: - case 138: + case 144: case 139: case 140: - case 134: - case 133: + case 141: case 135: + case 134: case 136: case 137: - case 200: - case 162: + case 138: + case 201: case 163: + case 164: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 174: - case 201: + case 175: + case 202: if (node.flags & 128) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 145: - case 154: - case 202: + case 146: + case 155: + case 203: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 204: + case 205: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -2953,11 +2962,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 227 ? node : node.body; - if (body.kind === 227 || body.kind === 206) { + var body = node.kind === 228 ? node : node.body; + if (body.kind === 228 || body.kind === 207) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 215 || stat.kind === 214) { + if (stat.kind === 216 || stat.kind === 215) { return true; } } @@ -2966,10 +2975,10 @@ var ts; } function setExportContextFlag(node) { if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 32768; + node.flags |= 65536; } else { - node.flags &= ~32768; + node.flags &= ~65536; } } function bindModuleDeclaration(node) { @@ -3007,7 +3016,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 142 ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 143 ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -3019,10 +3028,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolKind, symbolExcludes) { switch (blockScopeContainer.kind) { - case 205: + case 206: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227: + case 228: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; @@ -3045,14 +3054,14 @@ var ts; function bind(node) { node.parent = parent; switch (node.kind) { - case 128: + case 129: bindDeclaration(node, 262144, 530912, false); break; - case 129: + case 130: bindParameter(node); break; - case 198: - case 152: + case 199: + case 153: if (ts.isBindingPattern(node.name)) { bindChildren(node, 0, false); } @@ -3063,68 +3072,68 @@ var ts; bindDeclaration(node, 1, 107454, false); } break; + case 133: case 132: - case 131: bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); break; - case 224: case 225: + case 226: bindPropertyOrMethodOrAccessor(node, 4, 107455, false); break; - case 226: + case 227: bindPropertyOrMethodOrAccessor(node, 8, 107455, false); break; - case 138: case 139: case 140: + case 141: bindDeclaration(node, 131072, 0, false); break; + case 135: case 134: - case 133: bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); break; - case 200: + case 201: bindDeclaration(node, 16, 106927, true); break; - case 135: + case 136: bindDeclaration(node, 16384, 0, true); break; - case 136: + case 137: bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); break; - case 137: + case 138: bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); break; - case 142: case 143: + case 144: bindFunctionOrConstructorType(node); break; - case 145: + case 146: bindAnonymousDeclaration(node, 2048, "__type", false); break; - case 154: + case 155: bindAnonymousDeclaration(node, 4096, "__object", false); break; - case 162: case 163: + case 164: bindAnonymousDeclaration(node, 16, "__function", true); break; - case 174: + case 175: bindAnonymousDeclaration(node, 32, "__class", false); break; - case 223: + case 224: bindCatchVariableDeclaration(node); break; - case 201: + case 202: bindBlockScopedDeclaration(node, 32, 899583); break; - case 202: + case 203: bindDeclaration(node, 64, 792992, false); break; - case 203: + case 204: bindDeclaration(node, 524288, 793056, false); break; - case 204: + case 205: if (ts.isConst(node)) { bindDeclaration(node, 128, 899967, false); } @@ -3132,16 +3141,16 @@ var ts; bindDeclaration(node, 256, 899327, false); } break; - case 205: + case 206: bindModuleDeclaration(node); break; - case 208: - case 211: - case 213: - case 217: + case 209: + case 212: + case 214: + case 218: bindDeclaration(node, 8388608, 8388608, false); break; - case 210: + case 211: if (node.name) { bindDeclaration(node, 8388608, 8388608, false); } @@ -3149,13 +3158,13 @@ var ts; bindChildren(node, 0, false); } break; - case 215: + case 216: if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } bindChildren(node, 0, false); break; - case 214: + case 215: if (node.expression.kind === 65) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } @@ -3164,20 +3173,20 @@ var ts; } bindChildren(node, 0, false); break; - case 227: + case 228: setExportContextFlag(node); if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); break; } - case 179: + case 180: bindChildren(node, 0, !ts.isFunctionLike(node.parent)); break; - case 223: - case 186: + case 224: case 187: case 188: - case 207: + case 189: + case 208: bindChildren(node, 0, true); break; default: @@ -3195,8 +3204,8 @@ var ts; bindDeclaration(node, 1, 107455, false); } if (node.flags & 112 && - node.parent.kind === 135 && - (node.parent.parent.kind === 201 || node.parent.parent.kind === 174)) { + node.parent.kind === 136 && + (node.parent.parent.kind === 202 || node.parent.parent.kind === 175)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -3274,7 +3283,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 227) { + while (node && node.kind !== 228) { node = node.parent; } return node; @@ -3363,15 +3372,15 @@ var ts; return current; } switch (current.kind) { - case 227: - case 207: - case 223: - case 205: - case 186: + case 228: + case 208: + case 224: + case 206: case 187: case 188: + case 189: return current; - case 179: + case 180: if (!isFunctionLike(current.parent)) { return current; } @@ -3382,9 +3391,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 198 && + declaration.kind === 199 && declaration.parent && - declaration.parent.kind === 223; + declaration.parent.kind === 224; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3420,22 +3429,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 227: + case 228: 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 198: - case 152: - case 201: - case 174: + case 199: + case 153: case 202: + case 175: + case 203: + case 206: case 205: - case 204: - case 226: - case 200: - case 162: + case 227: + case 201: + case 163: errorNode = node.name; break; } @@ -3457,11 +3466,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 204 && isConst(node); + return node.kind === 205 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 152 || isBindingPattern(node))) { + while (node && (node.kind === 153 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3469,14 +3478,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 198) { + if (node.kind === 199) { node = node.parent; } - if (node && node.kind === 199) { + if (node && node.kind === 200) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 180) { + if (node && node.kind === 181) { flags |= node.flags; } return flags; @@ -3491,11 +3500,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 182 && node.expression.kind === 8; + return node.kind === 183 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 129 || node.kind === 128) { + if (node.kind === 130 || node.kind === 129) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3517,23 +3526,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191: + case 192: return visitor(node); - case 207: - case 179: - case 183: + case 208: + case 180: case 184: case 185: case 186: case 187: case 188: - case 192: + case 189: case 193: - case 220: - case 221: case 194: - case 196: - case 223: + case 221: + case 222: + case 195: + case 197: + case 224: return ts.forEachChild(node, traverse); } } @@ -3542,14 +3551,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 152: - case 226: - case 129: - case 224: - case 132: - case 131: + case 153: + case 227: + case 130: case 225: - case 198: + case 133: + case 132: + case 226: + case 199: return true; } } @@ -3559,8 +3568,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 136: case 137: + case 138: return true; } } @@ -3570,22 +3579,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 135: - case 162: - case 200: - case 163: - case 134: - case 133: case 136: + case 163: + case 201: + case 164: + case 135: + case 134: case 137: case 138: case 139: case 140: - case 142: + case 141: case 143: - case 162: + case 144: case 163: - case 200: + case 164: + case 201: return true; } } @@ -3593,11 +3602,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 179 && isFunctionLike(node.parent); + return node && node.kind === 180 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 134 && node.parent.kind === 154; + return node && node.kind === 135 && node.parent.kind === 155; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3616,36 +3625,36 @@ var ts; return undefined; } switch (node.kind) { - case 127: - if (node.parent.parent.kind === 201) { + case 128: + if (node.parent.parent.kind === 202) { return node; } node = node.parent; break; - case 130: - if (node.parent.kind === 129 && isClassElement(node.parent.parent)) { + case 131: + if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 163: + case 164: if (!includeArrowFunctions) { continue; } - case 200: - case 162: - case 205: - case 132: - case 131: - case 134: + case 201: + case 163: + case 206: case 133: + case 132: case 135: + case 134: case 136: case 137: - case 204: - case 227: + case 138: + case 205: + case 228: return node; } } @@ -3657,40 +3666,40 @@ var ts; if (!node) return node; switch (node.kind) { - case 127: - if (node.parent.parent.kind === 201) { + case 128: + if (node.parent.parent.kind === 202) { return node; } node = node.parent; break; - case 130: - if (node.parent.kind === 129 && isClassElement(node.parent.parent)) { + case 131: + if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 200: - case 162: + case 201: case 163: + case 164: if (!includeFunctions) { continue; } - case 132: - case 131: - case 134: case 133: + case 132: case 135: + case 134: case 136: case 137: + case 138: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 159) { + if (node.kind === 160) { return node.tag; } return node.expression; @@ -3698,40 +3707,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 201: + case 202: return true; - case 132: - return node.parent.kind === 201; - case 129: - return node.parent.body && node.parent.parent.kind === 201; - case 136: + case 133: + return node.parent.kind === 202; + case 130: + return node.parent.body && node.parent.parent.kind === 202; case 137: - case 134: - return node.body && node.parent.kind === 201; + case 138: + case 135: + return node.body && node.parent.kind === 202; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 201: + case 202: if (node.decorators) { return true; } return false; - case 132: - case 129: + case 133: + case 130: if (node.decorators) { return true; } return false; - case 136: + case 137: if (node.body && node.decorators) { return true; } return false; - case 134: - case 137: + case 135: + case 138: if (node.body && node.decorators) { return true; } @@ -3742,10 +3751,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 201: + case 202: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 134: - case 137: + case 135: + case 138: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3763,7 +3772,6 @@ var ts; case 95: case 80: case 9: - case 153: case 154: case 155: case 156: @@ -3773,69 +3781,70 @@ var ts; case 160: case 161: case 162: - case 174: case 163: - case 166: + case 175: case 164: - case 165: case 167: + case 165: + case 166: case 168: case 169: case 170: - case 173: case 171: + case 174: + case 172: case 10: - case 175: + case 176: return true; - case 126: - while (node.parent.kind === 126) { + case 127: + while (node.parent.kind === 127) { node = node.parent; } - return node.parent.kind === 144; + return node.parent.kind === 145; case 65: - if (node.parent.kind === 144) { + if (node.parent.kind === 145) { return true; } case 7: case 8: var parent_1 = node.parent; switch (parent_1.kind) { - case 198: - case 129: + case 199: + case 130: + case 133: case 132: - case 131: - case 226: - case 224: - case 152: + case 227: + case 225: + case 153: return parent_1.initializer === node; - case 182: case 183: case 184: case 185: - case 191: + case 186: case 192: case 193: - case 220: - case 195: - case 193: + case 194: + case 221: + case 196: + case 194: return parent_1.expression === node; - case 186: + case 187: var forStatement = parent_1; - return (forStatement.initializer === node && forStatement.initializer.kind !== 199) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 200) || forStatement.condition === node || forStatement.incrementor === node; - case 187: case 188: + case 189: var forInStatement = parent_1; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 199) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200) || forInStatement.expression === node; - case 160: + case 161: return node === parent_1.expression; - case 176: + case 178: return node === parent_1.expression; - case 127: + case 128: return node === parent_1.expression; - case 130: + case 131: return true; default: if (isExpression(parent_1)) { @@ -3853,7 +3862,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 && node.moduleReference.kind === 219; + return node.kind === 209 && node.moduleReference.kind === 220; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3862,40 +3871,40 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 && node.moduleReference.kind !== 219; + return node.kind === 209 && node.moduleReference.kind !== 220; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 209) { + if (node.kind === 210) { return node.moduleSpecifier; } - if (node.kind === 208) { + if (node.kind === 209) { var reference = node.moduleReference; - if (reference.kind === 219) { + if (reference.kind === 220) { return reference.expression; } } - if (node.kind === 215) { + if (node.kind === 216) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 129 && node.dotDotDotToken !== undefined; + return node && node.kind === 130 && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 129: + case 130: return node.questionToken !== undefined; + case 135: case 134: - case 133: return node.questionToken !== undefined; + case 226: case 225: - case 224: + case 133: case 132: - case 131: return node.questionToken !== undefined; } } @@ -3903,7 +3912,7 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; + return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { @@ -3919,7 +3928,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 151 || node.kind === 150); + return !!node && (node.kind === 152 || node.kind === 151); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -3934,33 +3943,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 163: - case 152: - case 201: - case 135: - case 204: - case 226: - case 217: - case 200: - case 162: - case 136: - case 210: - case 208: - case 213: + case 164: + case 153: case 202: - case 134: - case 133: + case 136: case 205: - case 211: - case 129: - case 224: - case 132: - case 131: + case 227: + case 218: + case 201: + case 163: case 137: - case 225: + case 211: + case 209: + case 214: case 203: - case 128: - case 198: + case 135: + case 134: + case 206: + case 212: + case 130: + case 225: + case 133: + case 132: + case 138: + case 226: + case 204: + case 129: + case 199: return true; } return false; @@ -3968,25 +3977,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 190: - case 189: - case 197: - case 184: - case 182: - case 181: - case 187: - case 188: - case 186: - case 183: - case 194: case 191: - case 193: - case 94: - case 196: - case 180: + case 190: + case 198: case 185: + case 183: + case 182: + case 188: + case 189: + case 187: + case 184: + case 195: case 192: - case 214: + case 194: + case 94: + case 197: + case 181: + case 186: + case 193: + case 215: return true; default: return false; @@ -3995,13 +4004,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 135: - case 132: - case 134: case 136: - case 137: case 133: - case 140: + case 135: + case 137: + case 138: + case 134: + case 141: return true; default: return false; @@ -4013,7 +4022,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 213 || parent.kind === 217) { + if (parent.kind === 214 || parent.kind === 218) { if (parent.propertyName) { return true; } @@ -4025,12 +4034,12 @@ var ts; } ts.isDeclarationName = isDeclarationName; function isAliasSymbolDeclaration(node) { - return node.kind === 208 || - node.kind === 210 && !!node.name || - node.kind === 211 || - node.kind === 213 || - node.kind === 217 || - node.kind === 214 && node.expression.kind === 65; + return node.kind === 209 || + node.kind === 211 && !!node.name || + node.kind === 212 || + node.kind === 214 || + node.kind === 218 || + node.kind === 215 && node.expression.kind === 65; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4113,7 +4122,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 125; + return 66 <= token && token <= 126; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4122,19 +4131,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 127 && + declaration.name.kind === 128 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 155 && isESSymbolIdentifier(node.expression); + return node.kind === 156 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 127) { + if (name.kind === 128) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4168,7 +4177,7 @@ var ts; } ts.isModifier = isModifier; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 205 || n.kind === 227; + return isFunctionLike(n) || n.kind === 206 || n.kind === 228; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4331,7 +4340,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); } } } @@ -4392,7 +4401,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 135 && nodeIsPresent(member.body)) { + if (member.kind === 136 && nodeIsPresent(member.body)) { return member; } }); @@ -4400,8 +4409,8 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; + if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -4415,10 +4424,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 136) { + if (accessor.kind === 137) { getAccessor = accessor; } - else if (accessor.kind === 137) { + else if (accessor.kind === 138) { setAccessor = accessor; } else { @@ -4427,7 +4436,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 136 || member.kind === 137) + if ((member.kind === 137 || member.kind === 138) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4438,10 +4447,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 136 && !getAccessor) { + if (member.kind === 137 && !getAccessor) { getAccessor = member; } - if (member.kind === 137 && !setAccessor) { + if (member.kind === 138 && !setAccessor) { setAccessor = member; } } @@ -4562,22 +4571,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 155: case 156: - case 158: case 157: case 159: - case 153: - case 161: + case 158: + case 160: case 154: - case 174: case 162: + case 155: + case 175: + case 163: case 65: case 9: case 7: case 8: case 10: - case 171: + case 172: case 80: case 89: case 93: @@ -4593,30 +4602,84 @@ var ts; return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; - function isSupportedHeritageClauseElement(node) { - return isSupportedHeritageClauseElementExpression(node.expression); + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } - ts.isSupportedHeritageClauseElement = isSupportedHeritageClauseElement; - function isSupportedHeritageClauseElementExpression(node) { + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { if (node.kind === 65) { return true; } - else if (node.kind === 155) { - return isSupportedHeritageClauseElementExpression(node.expression); + else if (node.kind === 156) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { return false; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 126 && node.parent.right === node) || - (node.parent.kind === 155 && node.parent.name === node); + return (node.parent.kind === 127 && node.parent.right === node) || + (node.parent.kind === 156 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + var leadSurrogate = undefined; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; })(ts || (ts = {})); var ts; (function (ts) { @@ -4738,7 +4801,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(229); + var nodeConstructors = new Array(230); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4776,20 +4839,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 126: + case 127: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 128: + case 129: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 129: + case 130: + case 133: case 132: - case 131: - case 224: case 225: - case 198: - case 152: + case 226: + case 199: + case 153: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -4798,24 +4861,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 142: case 143: - case 138: + case 144: case 139: case 140: + case 141: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 134: - case 133: case 135: + case 134: case 136: case 137: - case 162: - case 200: + case 138: case 163: + case 201: + case 164: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -4826,151 +4889,144 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 141: + case 142: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 144: - return visitNode(cbNode, node.exprName); case 145: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 146: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 147: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 148: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 149: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 150: + return visitNode(cbNode, node.type); case 151: - return visitNodes(cbNodes, node.elements); - case 153: + case 152: return visitNodes(cbNodes, node.elements); case 154: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 155: + return visitNodes(cbNodes, node.properties); + case 156: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 156: + case 157: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 157: case 158: + case 159: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 159: + case 160: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 160: + case 161: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 161: - return visitNode(cbNode, node.expression); - case 164: + case 162: return visitNode(cbNode, node.expression); case 165: return visitNode(cbNode, node.expression); case 166: return visitNode(cbNode, node.expression); case 167: - return visitNode(cbNode, node.operand); - case 172: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression); case 168: return visitNode(cbNode, node.operand); + case 173: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); case 169: + return visitNode(cbNode, node.operand); + case 170: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 170: + case 171: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 173: + case 174: return visitNode(cbNode, node.expression); - case 179: - case 206: + case 180: + case 207: return visitNodes(cbNodes, node.statements); - case 227: + case 228: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 180: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 199: + case 200: return visitNodes(cbNodes, node.declarations); - case 182: - return visitNode(cbNode, node.expression); case 183: + return visitNode(cbNode, node.expression); + case 184: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 184: + case 185: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 186: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 187: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 188: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 189: - case 190: - return visitNode(cbNode, node.label); - case 191: - return visitNode(cbNode, node.expression); - case 192: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 190: + case 191: + return visitNode(cbNode, node.label); + case 192: + return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 207: + case 208: return visitNodes(cbNodes, node.clauses); - case 220: + case 221: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 221: + case 222: return visitNodes(cbNodes, node.statements); - case 194: + case 195: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 195: - return visitNode(cbNode, node.expression); case 196: + return visitNode(cbNode, node.expression); + case 197: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 223: + case 224: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 130: + case 131: return visitNode(cbNode, node.expression); - case 201: - case 174: - 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 202: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -4981,65 +5037,72 @@ var ts; return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 204: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 226: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNode(cbNode, node.type); case 205: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 227: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 208: + case 209: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 209: + case 210: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 210: + case 211: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 211: - return visitNode(cbNode, node.name); case 212: - case 216: + return visitNode(cbNode, node.name); + case 213: + case 217: return visitNodes(cbNodes, node.elements); - case 215: + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 213: - case 217: + case 214: + case 218: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 214: + case 215: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 171: + case 172: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 176: + case 178: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 127: + case 128: return visitNode(cbNode, node.expression); - case 222: + case 223: return visitNodes(cbNodes, node.types); case 177: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 219: + case 220: return visitNode(cbNode, node.expression); - case 218: + case 219: return visitNodes(cbNodes, node.decorators); } } @@ -5125,7 +5188,7 @@ var ts; } } function createSourceFile(fileName, languageVersion) { - sourceFile = createNode(227, 0); + sourceFile = createNode(228, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5418,7 +5481,7 @@ var ts; return parseIdentifierName(); } function parseComputedPropertyName() { - var node = createNode(127); + var node = createNode(128); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5712,14 +5775,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { + case 210: case 209: - case 208: + case 216: case 215: - case 214: - case 201: case 202: + case 203: + case 206: case 205: - case 204: return true; } return isReusableStatement(node); @@ -5729,13 +5792,13 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 135: - case 140: - case 134: case 136: + case 141: + case 135: case 137: - case 132: - case 178: + case 138: + case 133: + case 179: return true; } } @@ -5744,8 +5807,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 220: case 221: + case 222: return true; } } @@ -5754,56 +5817,56 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 200: + case 201: + case 181: case 180: - case 179: + case 184: case 183: - case 182: - case 195: + case 196: + case 192: + case 194: case 191: - case 193: case 190: + case 188: case 189: case 187: - case 188: case 186: - case 185: - case 192: - case 181: - case 196: - case 194: - case 184: + case 193: + case 182: case 197: + case 195: + case 185: + case 198: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 226; + return node.kind === 227; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 139: - case 133: case 140: - case 131: - case 138: + case 134: + case 141: + case 132: + case 139: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 198) { + if (node.kind !== 199) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 129) { + if (node.kind !== 130) { return false; } var parameter = node; @@ -5898,7 +5961,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(126, entity.pos); + var node = createNode(127, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -5915,20 +5978,20 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(171); + var template = createNode(172); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(176); + var span = createNode(178); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -5962,7 +6025,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(141); + var node = createNode(142); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24) { node.typeArguments = parseBracketedList(17, parseType, 24, 25); @@ -5970,13 +6033,13 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(144); + var node = createNode(145); parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(128); + var node = createNode(129); node.name = parseIdentifier(); if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6011,7 +6074,7 @@ var ts; } } function parseParameter() { - var node = createNode(129); + var node = createNode(130); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); @@ -6063,7 +6126,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 139) { + if (kind === 140) { parseExpected(88); } fillSignature(51, false, false, node); @@ -6103,7 +6166,7 @@ var ts; return token === 51 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(140, fullStart); + var node = createNode(141, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15, parseParameter, 18, 19); @@ -6116,7 +6179,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(133, fullStart); + var method = createNode(134, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -6124,7 +6187,7 @@ var ts; return finishNode(method); } else { - var property = createNode(131, fullStart); + var property = createNode(132, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6166,14 +6229,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(138); + return parseSignatureMember(139); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(139); + return parseSignatureMember(140); } case 8: case 7: @@ -6203,7 +6266,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(145); + var node = createNode(146); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -6219,12 +6282,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(147); + var node = createNode(148); node.elementTypes = parseBracketedList(18, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(149); + var node = createNode(150); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6232,7 +6295,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 143) { + if (kind === 144) { parseExpected(88); } fillSignature(32, false, false, node); @@ -6245,10 +6308,10 @@ var ts; function parseNonArrayType() { switch (token) { case 112: - case 121: - case 119: - case 113: case 122: + case 120: + case 113: + case 123: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 99: @@ -6268,10 +6331,10 @@ var ts; function isStartOfType() { switch (token) { case 112: - case 121: - case 119: - case 113: case 122: + case 120: + case 113: + case 123: case 99: case 97: case 14: @@ -6293,7 +6356,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(146, type.pos); + var node = createNode(147, type.pos); node.elementType = type; type = finishNode(node); } @@ -6308,7 +6371,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(148, type.pos); + var node = createNode(149, type.pos); node.types = types; type = finishNode(node); } @@ -6353,10 +6416,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(142); + return parseFunctionOrConstructorType(143); } if (token === 88) { - return parseFunctionOrConstructorType(143); + return parseFunctionOrConstructorType(144); } return parseUnionTypeOrHigher(); } @@ -6494,7 +6557,7 @@ var ts; (isIdentifier() || token === 14 || token === 18); } function parseYieldExpression() { - var node = createNode(172); + var node = createNode(173); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6508,8 +6571,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(163, identifier.pos); - var parameter = createNode(129, identifier.pos); + var node = createNode(164, identifier.pos); + var parameter = createNode(130, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -6587,7 +6650,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(163); + var node = createNode(164); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6614,7 +6677,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(170, leftOperand.pos); + var node = createNode(171, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -6627,7 +6690,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 125; + return t === 86 || t === 126; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6688,37 +6751,37 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(169, left.pos); + var node = createNode(170, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(167); + var node = createNode(168); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(164); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(165); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(166); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(167); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function parseUnaryExpressionOrHigher() { switch (token) { case 33: @@ -6744,7 +6807,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(168, expression.pos); + var node = createNode(169, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -6767,14 +6830,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(155, expression.pos); + var node = createNode(156, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(160); + var node = createNode(161); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -6785,7 +6848,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(155, expression.pos); + var propertyAccess = createNode(156, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -6793,7 +6856,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(156, expression.pos); + var indexedAccess = createNode(157, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -6807,7 +6870,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(159, expression.pos); + var tagExpression = createNode(160, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -6826,7 +6889,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(157, expression.pos); + var callExpr = createNode(158, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -6834,7 +6897,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(157, expression.pos); + var callExpr = createNode(158, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -6924,28 +6987,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(161); + var node = createNode(162); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(173); + var node = createNode(174); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(175) : + token === 23 ? createNode(176) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(153); + var node = createNode(154); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; @@ -6955,11 +7018,11 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116)) { - return parseAccessorDeclaration(136, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(120)) { return parseAccessorDeclaration(137, fullStart, decorators, modifiers); } + else if (parseContextualModifier(121)) { + return parseAccessorDeclaration(138, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -6979,13 +7042,13 @@ var ts; return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(225, fullStart); + var shorthandDeclaration = createNode(226, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(224, fullStart); + var propertyAssignment = createNode(225, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -6994,7 +7057,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(154); + var node = createNode(155); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; @@ -7008,7 +7071,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(162); + var node = createNode(163); parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -7023,7 +7086,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(158); + var node = createNode(159); parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -7033,7 +7096,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(179); + var node = createNode(180); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2, checkForStrictMode, parseStatement); parseExpected(15); @@ -7058,12 +7121,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(181); + var node = createNode(182); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(183); + var node = createNode(184); parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7073,7 +7136,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(184); + var node = createNode(185); parseExpected(75); node.statement = parseStatement(); parseExpected(100); @@ -7084,7 +7147,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(185); + var node = createNode(186); parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7107,21 +7170,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86)) { - var forInStatement = createNode(187, pos); + var forInStatement = createNode(188, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(125)) { - var forOfStatement = createNode(188, pos); + else if (parseOptional(126)) { + var forOfStatement = createNode(189, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(186, pos); + var forStatement = createNode(187, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7139,7 +7202,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 190 ? 66 : 71); + parseExpected(kind === 191 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7147,7 +7210,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(191); + var node = createNode(192); parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -7156,7 +7219,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(192); + var node = createNode(193); parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7165,7 +7228,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(220); + var node = createNode(221); parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); @@ -7173,7 +7236,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(221); + var node = createNode(222); parseExpected(73); parseExpected(51); node.statements = parseList(4, false, parseStatement); @@ -7183,12 +7246,12 @@ var ts; return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(193); + var node = createNode(194); parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(207, scanner.getStartPos()); + var caseBlock = createNode(208, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); parseExpected(15); @@ -7198,14 +7261,14 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(195); + var node = createNode(196); parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(196); + var node = createNode(197); parseExpected(96); node.tryBlock = parseBlock(false, false); node.catchClause = token === 68 ? parseCatchClause() : undefined; @@ -7216,7 +7279,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(223); + var result = createNode(224); parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); @@ -7226,7 +7289,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(197); + var node = createNode(198); parseExpected(72); parseSemicolon(); return finishNode(node); @@ -7235,13 +7298,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(194, fullStart); + var labeledStatement = createNode(195, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(182, fullStart); + var expressionStatement = createNode(183, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -7282,8 +7345,9 @@ var ts; return !isConstEnum; case 103: case 117: + case 118: case 77: - case 123: + case 124: if (isDeclarationStart()) { return false; } @@ -7328,9 +7392,9 @@ var ts; case 82: return parseForOrForInOrForOfStatement(); case 71: - return parseBreakOrContinueStatement(189); - case 66: return parseBreakOrContinueStatement(190); + case 66: + return parseBreakOrContinueStatement(191); case 90: return parseReturnStatement(); case 101: @@ -7393,16 +7457,16 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(175); + return createNode(176); } - var node = createNode(152); + var node = createNode(153); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(152); + var node = createNode(153); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 51) { @@ -7417,14 +7481,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(150); + var node = createNode(151); parseExpected(14); node.elements = parseDelimitedList(10, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(151); + var node = createNode(152); parseExpected(18); node.elements = parseDelimitedList(11, parseArrayBindingElement); parseExpected(19); @@ -7443,7 +7507,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(198); + var node = createNode(199); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7452,7 +7516,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(199); + var node = createNode(200); switch (token) { case 98: break; @@ -7466,7 +7530,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 125 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 126 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -7481,7 +7545,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(180, fullStart); + var node = createNode(181, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7489,7 +7553,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83); @@ -7500,7 +7564,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(135, pos); + var node = createNode(136, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114); @@ -7509,7 +7573,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(134, fullStart); + var method = createNode(135, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -7520,7 +7584,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(132, fullStart); + var property = createNode(133, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -7587,7 +7651,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 120 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 121 || idToken === 116) { return true; } switch (token) { @@ -7614,7 +7678,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(130, decoratorStart); + var decorator = createNode(131, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -7647,7 +7711,7 @@ var ts; } function parseClassElement() { if (token === 22) { - var result = createNode(178); + var result = createNode(179); nextToken(); return finishNode(result); } @@ -7678,10 +7742,10 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 174); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 175); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 201); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var savedStrictModeContext = inStrictModeContext(); @@ -7722,15 +7786,15 @@ var ts; } function parseHeritageClause() { if (token === 79 || token === 102) { - var node = createNode(222); + var node = createNode(223); node.token = token; nextToken(); - node.types = parseDelimitedList(8, parseHeritageClauseElement); + node.types = parseDelimitedList(8, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } - function parseHeritageClauseElement() { + function parseExpressionWithTypeArguments() { var node = createNode(177); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { @@ -7745,7 +7809,7 @@ var ts; return parseList(6, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(202, fullStart); + var node = createNode(203, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103); @@ -7756,10 +7820,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(204, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(123); + parseExpected(124); node.name = parseIdentifier(); parseExpected(53); node.type = parseType(); @@ -7767,13 +7831,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(226, scanner.getStartPos()); + var node = createNode(227, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77); @@ -7788,7 +7852,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(206, scanner.getStartPos()); + var node = createNode(207, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, false, parseModuleElement); parseExpected(15); @@ -7798,19 +7862,19 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { - var node = createNode(205, fullStart); + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20) - ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -7818,13 +7882,20 @@ var ts; return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { - parseExpected(117); - return token === 8 - ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) - : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(118)) { + flags |= 32768; + } + else { + parseExpected(117); + if (token === 8) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 118 && + return token === 119 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -7833,7 +7904,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 124; + token === 125; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85); @@ -7841,8 +7912,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 124) { - var importEqualsDeclaration = createNode(208, fullStart); + if (token !== 23 && token !== 125) { + var importEqualsDeclaration = createNode(209, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -7852,14 +7923,14 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(209, fullStart); + var importDeclaration = createNode(210, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(124); + parseExpected(125); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -7872,13 +7943,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(210, fullStart); + var importClause = createNode(211, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(212); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(213); } return finishNode(importClause); } @@ -7888,8 +7959,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(219); - parseExpected(118); + var node = createNode(220); + parseExpected(119); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -7903,7 +7974,7 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(211); + var namespaceImport = createNode(212); parseExpected(35); parseExpected(111); namespaceImport.name = parseIdentifier(); @@ -7911,14 +7982,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 212 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(20, kind === 213 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(217); + return parseImportOrExportSpecifier(218); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(213); + return parseImportOrExportSpecifier(214); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -7937,22 +8008,22 @@ var ts; else { node.name = identifierName; } - if (kind === 213 && checkIdentifierIsKeyword) { + if (kind === 214 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(124); + parseExpected(125); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(216); - if (parseOptional(124)) { + node.exportClause = parseNamedImportsOrExports(217); + if (parseOptional(125)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -7960,7 +8031,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53)) { @@ -7987,11 +8058,12 @@ var ts; case 69: case 103: case 77: - case 123: + case 124: return lookAhead(nextTokenIsIdentifierOrKeyword); case 85: return lookAhead(nextTokenCanFollowImportKeyword); case 117: + case 118: return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); case 78: return lookAhead(nextTokenCanFollowExportKeyword); @@ -8057,17 +8129,18 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 123: + case 124: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77: return parseEnumDeclaration(fullStart, decorators, modifiers); case 117: + case 118: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: if (decorators) { - var node = createMissingNode(218, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(219, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8147,10 +8220,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 208 && node.moduleReference.kind === 219 - || node.kind === 209 - || node.kind === 214 + || node.kind === 209 && node.moduleReference.kind === 220 + || node.kind === 210 || node.kind === 215 + || node.kind === 216 ? node : undefined; }); @@ -8511,7 +8584,6 @@ var ts; var undefinedType = createIntrinsicType(32 | 262144, "undefined"); var nullType = createIntrinsicType(64 | 262144, "null"); var unknownType = createIntrinsicType(1, "unknown"); - var resolvingType = createIntrinsicType(1, "__resolving__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -8541,6 +8613,8 @@ var ts; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var resolutionTargets = []; + var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -8703,10 +8777,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 227); + return ts.getAncestor(node, 228); } function isGlobalSourceFile(node) { - return node.kind === 227 && !ts.isExternalModule(node); + return node.kind === 228 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -8748,34 +8822,34 @@ var ts; } } switch (location.kind) { - case 227: + case 228: if (!ts.isExternalModule(location)) break; - case 205: + case 206: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 217)) { + if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 218)) { break loop; } result = undefined; } - else if (location.kind === 227 || - (location.kind === 205 && location.name.kind === 8)) { - result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & 8914931); + else if (location.kind === 228 || + (location.kind === 206 && location.name.kind === 8)) { + result = getSymbolOfNode(location).exports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) { + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } break; - case 204: + case 205: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 133: case 132: - case 131: - if (location.parent.kind === 201 && !(location.flags & 128)) { + if (location.parent.kind === 202 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -8784,8 +8858,8 @@ var ts; } } break; - case 201: case 202: + case 203: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -8794,28 +8868,28 @@ var ts; break loop; } break; - case 127: + case 128: grandparent = location.parent.parent; - if (grandparent.kind === 201 || grandparent.kind === 202) { + if (grandparent.kind === 202 || grandparent.kind === 203) { 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 134: - case 133: case 135: + case 134: case 136: case 137: - case 200: - case 163: + case 138: + case 201: + case 164: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 162: + case 163: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -8826,15 +8900,15 @@ var ts; break loop; } break; - case 174: + case 175: var className = location.name; if (className && name === className.text) { result = location.symbol; break loop; } break; - case 130: - if (location.parent && location.parent.kind === 129) { + case 131: + if (location.parent && location.parent.kind === 130) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -8872,14 +8946,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 198); + var variableDeclaration = ts.getAncestor(declaration, 199); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 180 || - variableDeclaration.parent.parent.kind === 186) { + if (variableDeclaration.parent.parent.kind === 181 || + variableDeclaration.parent.parent.kind === 187) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 188 || - variableDeclaration.parent.parent.kind === 187) { + else if (variableDeclaration.parent.parent.kind === 189 || + variableDeclaration.parent.parent.kind === 188) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -8901,10 +8975,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 208) { + if (node.kind === 209) { return node; } - while (node && node.kind !== 209) { + while (node && node.kind !== 210) { node = node.parent; } return node; @@ -8914,7 +8988,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 219) { + if (node.moduleReference.kind === 220) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -8924,7 +8998,7 @@ var ts; if (moduleSymbol) { var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } return exportDefaultSymbol; } @@ -9003,17 +9077,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 208: + case 209: return getTargetOfImportEqualsDeclaration(node); - case 210: - return getTargetOfImportClause(node); case 211: + return getTargetOfImportClause(node); + case 212: return getTargetOfNamespaceImport(node); - case 213: - return getTargetOfImportSpecifier(node); - case 217: - return getTargetOfExportSpecifier(node); case 214: + return getTargetOfImportSpecifier(node); + case 218: + return getTargetOfExportSpecifier(node); + case 215: return getTargetOfExportAssignment(node); } } @@ -9055,10 +9129,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 214) { + if (node.kind === 215) { checkExpressionCached(node.expression); } - else if (node.kind === 217) { + else if (node.kind === 218) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -9068,17 +9142,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 208); + importDeclaration = ts.getAncestor(entityName, 209); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 126) { + if (entityName.kind === 65 || entityName.parent.kind === 127) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 208); + ts.Debug.assert(entityName.parent.kind === 209); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -9091,14 +9165,15 @@ var ts; } var symbol; if (name.kind === 65) { - symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); + var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, message, name); if (!symbol) { return undefined; } } - else if (name.kind === 126 || name.kind === 155) { - var left = name.kind === 126 ? name.left : name.expression; - var right = name.kind === 126 ? name.right : name.name; + else if (name.kind === 127 || name.kind === 156) { + var left = name.kind === 127 ? name.left : name.expression; + var right = name.kind === 127 ? name.right : name.name; var namespace = resolveEntityName(left, 1536); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -9151,10 +9226,10 @@ var ts; if (sourceFile.symbol) { return sourceFile.symbol; } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.fileName); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); return; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); } function resolveExternalModuleSymbol(moduleSymbol) { return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; @@ -9162,7 +9237,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); if (symbol && !(symbol.flags & (1536 | 3))) { - error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } return symbol; @@ -9242,7 +9317,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 135 && ts.nodeIsPresent(member.body)) { + if (member.kind === 136 && ts.nodeIsPresent(member.body)) { return member; } } @@ -9307,17 +9382,17 @@ var ts; } } switch (location_1.kind) { - case 227: + case 228: if (!ts.isExternalModule(location_1)) { break; } - case 205: + case 206: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 201: case 202: + case 203: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -9432,8 +9507,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 205 && declaration.name.kind === 8) || - (declaration.kind === 227 && ts.isExternalModule(declaration)); + return (declaration.kind === 206 && declaration.name.kind === 8) || + (declaration.kind === 228 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -9465,11 +9540,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 144) { + if (entityName.parent.kind === 145) { meaning = 107455 | 1048576; } - else if (entityName.kind === 126 || entityName.kind === 155 || - entityName.parent.kind === 208) { + else if (entityName.kind === 127 || entityName.kind === 156 || + entityName.parent.kind === 209) { meaning = 1536; } else { @@ -9513,10 +9588,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 149) { + while (node.kind === 150) { node = node.parent; } - if (node.kind === 203) { + if (node.kind === 204) { return getSymbolOfNode(node); } } @@ -9688,7 +9763,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 227 || declaration.parent.kind === 206; + return declaration.parent.kind === 228 || declaration.parent.kind === 207; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -9763,7 +9838,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9776,7 +9851,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 119); + writeKeyword(writer, 120); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -9920,12 +9995,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 205) { + if (node.kind === 206) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 227) { + else if (node.kind === 228) { return ts.isExternalModule(node) ? node : undefined; } } @@ -9968,59 +10043,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 152: + case 153: return isDeclarationVisible(node.parent.parent); - case 198: + case 199: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 205: - case 201: + case 206: case 202: case 203: - case 200: case 204: - case 208: + case 201: + case 205: + case 209: var parent_2 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 208 && parent_2.kind !== 227 && ts.isInAmbientContext(parent_2))) { + !(node.kind !== 209 && parent_2.kind !== 228 && ts.isInAmbientContext(parent_2))) { return isGlobalSourceFile(parent_2); } return isDeclarationVisible(parent_2); - case 132: - case 131: - case 136: - case 137: - case 134: case 133: + case 132: + case 137: + case 138: + case 135: + case 134: if (node.flags & (32 | 64)) { return false; } - case 135: - case 139: - case 138: + case 136: case 140: - case 129: - case 206: - case 142: - case 143: - case 145: + case 139: case 141: + case 130: + case 207: + case 143: + case 144: case 146: + case 142: case 147: case 148: case 149: + case 150: return isDeclarationVisible(node.parent); - case 210: case 211: - case 213: - return false; - case 128: - case 227: - return true; + case 212: case 214: return false; + case 129: + case 228: + return true; + case 215: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -10035,10 +10110,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 214) { + if (node.parent && node.parent.kind === 215) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -10062,15 +10137,35 @@ var ts; }); } } + function pushTypeResolution(target) { + var i = 0; + var count = resolutionTargets.length; + while (i < count && resolutionTargets[i] !== target) { + i++; + } + if (i < count) { + do { + resolutionResults[i++] = false; + } while (i < count); + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + return true; + } + function popTypeResolution() { + resolutionTargets.pop(); + return resolutionResults.pop(); + } function getRootDeclaration(node) { - while (node.kind === 152) { + while (node.kind === 153) { node = node.parent.parent; } return node; } function getDeclarationContainer(node) { node = getRootDeclaration(node); - return node.kind === 198 ? node.parent.parent.parent : node.parent; + return node.kind === 199 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -10093,7 +10188,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 150) { + if (pattern.kind === 151) { var name_5 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_5.text) || isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || @@ -10130,10 +10225,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 187) { + if (declaration.parent.parent.kind === 188) { return anyType; } - if (declaration.parent.parent.kind === 188) { + if (declaration.parent.parent.kind === 189) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -10142,10 +10237,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129) { + if (declaration.kind === 130) { var func = declaration.parent; - if (func.kind === 137 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136); + if (func.kind === 138 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10158,7 +10253,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 225) { + if (declaration.kind === 226) { return checkIdentifier(declaration.name); } return undefined; @@ -10187,7 +10282,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 175 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 176 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -10202,7 +10297,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 150 + return pattern.kind === 151 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -10212,7 +10307,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 224 ? getWidenedType(type) : type; + return declaration.kind !== 225 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -10220,7 +10315,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 129 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 130 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -10233,26 +10328,29 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 223) { + if (declaration.parent.kind === 224) { return links.type = anyType; } - if (declaration.kind === 214) { + if (declaration.kind === 215) { return links.type = checkExpression(declaration.expression); } - links.type = resolvingType; + if (!pushTypeResolution(symbol)) { + return unknownType; + } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var diagnostic = symbol.valueDeclaration.type ? - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation : - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer; - error(symbol.valueDeclaration, diagnostic, symbolToString(symbol)); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } } + links.type = type; } return links.type; } @@ -10261,7 +10359,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 136) { + if (accessor.kind === 137) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -10273,15 +10371,12 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - checkAndStoreTypeOfAccessors(symbol, links); - return links.type; - } - function checkAndStoreTypeOfAccessors(symbol, links) { - links = links || getSymbolLinks(symbol); if (!links.type) { - links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 136); - var setter = ts.getDeclarationOfKind(symbol, 137); + if (!pushTypeResolution(symbol)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 137); + var setter = ts.getDeclarationOfKind(symbol, 138); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -10304,17 +10399,16 @@ var ts; } } } - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 136); - error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 137); + 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)); + } } + links.type = type; } + return links.type; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -10378,7 +10472,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 202 || node.kind === 201) { + if (node.kind === 203 || node.kind === 202) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -10412,10 +10506,10 @@ var ts; } function resolveBaseTypesOfClass(type) { type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 201); + var declaration = ts.getDeclarationOfKind(type.symbol, 202); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); if (baseTypeNode) { - var baseType = getTypeFromHeritageClauseElement(baseTypeNode); + var baseType = getTypeFromTypeNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -10435,10 +10529,10 @@ var ts; type.baseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 202 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 203 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; - var baseType = getTypeFromHeritageClauseElement(node); + var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 | 2048)) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -10476,17 +10570,16 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 203); - var type = getTypeFromTypeNode(declaration.type); - if (links.declaredType === resolvingType) { - links.declaredType = type; + if (!pushTypeResolution(links)) { + return unknownType; } - } - else if (links.declaredType === resolvingType) { - links.declaredType = unknownType; - var declaration = ts.getDeclarationOfKind(symbol, 203); - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 204); + var type = getTypeFromTypeNode(declaration.type); + if (!popTypeResolution()) { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; } return links.declaredType; } @@ -10504,7 +10597,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 128).constraint) { + if (!ts.getDeclarationOfKind(symbol, 129).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -10951,7 +11044,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 136 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -10980,8 +11073,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 136 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 137); + if (declaration.kind === 137 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 138); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -10999,19 +11092,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 142: case 143: - case 200: - case 134: - case 133: + case 144: + case 201: case 135: - case 138: + case 134: + case 136: case 139: case 140: - case 136: + case 141: case 137: - case 162: + case 138: case 163: + case 164: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11025,7 +11118,9 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - signature.resolvedReturnType = resolvingType; + if (!pushTypeResolution(signature)) { + return unknownType; + } var type; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); @@ -11036,27 +11131,25 @@ var ts; else { type = getReturnTypeFromBody(signature.declaration); } - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = type; - } - } - else if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + } } } + signature.resolvedReturnType = type; } return signature.resolvedReturnType; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); if (type.flags & 4096 && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -11081,7 +11174,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 135 || signature.declaration.kind === 139; + var isConstructor = signature.declaration.kind === 136 || signature.declaration.kind === 140; var type = createObjectType(32768 | 65536); type.members = emptySymbols; type.properties = emptyArray; @@ -11095,7 +11188,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 119 : 121; + var syntaxKind = kind === 1 ? 120 : 122; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -11125,7 +11218,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11175,13 +11268,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 141 && n.typeName.kind === 65) { + if (n.kind === 142 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -11200,18 +11293,12 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReference(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromHeritageClauseElement(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromTypeReferenceOrHeritageClauseElement(node) { + function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var type; - if (node.kind !== 177 || ts.isSupportedHeritageClauseElement(node)) { - var typeNameOrExpression = node.kind === 141 + if (node.kind !== 177 || ts.isSupportedExpressionWithTypeArguments(node)) { + var typeNameOrExpression = node.kind === 142 ? node.typeName : node.expression; var symbol = resolveEntityName(typeNameOrExpression, 793056); @@ -11257,9 +11344,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 201: case 202: - case 204: + case 203: + case 205: return declaration; } } @@ -11448,38 +11535,38 @@ var ts; switch (node.kind) { case 112: return anyType; - case 121: + case 122: return stringType; - case 119: + case 120: return numberType; case 113: return booleanType; - case 122: + case 123: return esSymbolType; case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 141: - return getTypeFromTypeReference(node); - case 177: - return getTypeFromHeritageClauseElement(node); - case 144: - return getTypeFromTypeQueryNode(node); - case 146: - return getTypeFromArrayTypeNode(node); - case 147: - return getTypeFromTupleTypeNode(node); - case 148: - return getTypeFromUnionTypeNode(node); - case 149: - return getTypeFromTypeNode(node.type); case 142: - case 143: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + case 177: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); case 145: + return getTypeFromTypeQueryNode(node); + case 147: + return getTypeFromArrayTypeNode(node); + case 148: + return getTypeFromTupleTypeNode(node); + case 149: + return getTypeFromUnionTypeNode(node); + case 150: + return getTypeFromTypeNode(node.type); + case 143: + case 144: + case 146: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 65: - case 126: + case 127: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -11630,27 +11717,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 162: case 163: + case 164: return isContextSensitiveFunctionLikeDeclaration(node); - case 154: + case 155: return ts.forEach(node.properties, isContextSensitive); - case 153: + case 154: return ts.forEach(node.elements, isContextSensitive); - case 170: + case 171: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 169: + case 170: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 224: + case 225: return isContextSensitive(node.initializer); + case 135: case 134: - case 133: return isContextSensitiveFunctionLikeDeclaration(node); - case 161: + case 162: return isContextSensitive(node.expression); } return false; @@ -12424,22 +12511,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 133: case 132: - case 131: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 129: + case 130: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 200: + case 201: + case 135: case 134: - case 133: - case 136: case 137: - case 162: + case 138: case 163: + case 164: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -12682,10 +12769,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 144: + case 145: return true; case 65: - case 126: + case 127: node = node.parent; continue; default: @@ -12727,7 +12814,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 161) { + while (n.kind === 162) { n = n.expression; } if (n.kind === 65 && getResolvedSymbol(n) === symbol) { @@ -12744,46 +12831,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 169: + case 170: return isAssignedInBinaryExpression(node); - case 198: - case 152: - return isAssignedInVariableDeclaration(node); - case 150: - case 151: + case 199: case 153: + return isAssignedInVariableDeclaration(node); + case 151: + case 152: case 154: case 155: case 156: case 157: case 158: - case 160: + case 159: case 161: - case 167: - case 164: + case 162: + case 168: case 165: case 166: - case 168: - case 170: - case 173: - case 179: + case 167: + case 169: + case 171: + case 174: case 180: - case 182: + case 181: case 183: case 184: case 185: case 186: case 187: case 188: - case 191: + case 189: case 192: case 193: - case 220: - case 221: case 194: + case 221: + case 222: case 195: case 196: - case 223: + case 197: + case 224: return ts.forEachChild(node, isAssignedIn); } return false; @@ -12819,17 +12906,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 183: + case 184: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 170: + case 171: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 169: + case 170: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -12839,14 +12926,14 @@ var ts; } } break; - case 227: - case 205: - case 200: - case 134: - case 133: - case 136: - case 137: + case 228: + case 206: + case 201: case 135: + case 134: + case 137: + case 138: + case 136: break loop; } if (narrowedType !== type) { @@ -12859,7 +12946,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 165 || expr.right.kind !== 8) { + if (expr.left.kind !== 166 || expr.right.kind !== 8) { return type; } var left = expr.left; @@ -12918,23 +13005,38 @@ var ts; return type; } var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (!prototypeProperty) { - return type; + if (prototypeProperty) { + var targetType = getTypeOfSymbol(prototypeProperty); + if (targetType !== anyType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + } + } } - var targetType = getTypeOfSymbol(prototypeProperty); - if (isTypeSubtypeOf(targetType, type)) { - return targetType; + var constructSignatures; + if (rightType.flags & 2048) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + else if (rightType.flags & 32768) { + constructSignatures = getSignaturesOfType(rightType, 1); + } + if (constructSignatures && constructSignatures.length !== 0) { + var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + } + return instanceType; } return type; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 161: + case 162: return narrowType(type, expr.expression, assumeTrue); - case 169: + case 170: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -12949,7 +13051,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 167: + case 168: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -12960,7 +13062,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163 && languageVersion < 2) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 && 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); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -12984,15 +13086,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 223) { + symbol.valueDeclaration.parent.kind === 224) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 199) { + while (container.kind !== 200) { container = container.parent; } container = container.parent; - if (container.kind === 180) { + if (container.kind === 181) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -13009,9 +13111,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 201 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 132 || container.kind === 135) { + if (container.kind === 133 || container.kind === 136) { getNodeLinks(classNode).flags |= 4; } else { @@ -13021,36 +13123,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 163) { + if (container.kind === 164) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 205: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); + case 206: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 204: + case 205: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 135: + case 136: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 133: case 132: - case 131: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 127: + case 128: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 201 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13059,15 +13161,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 129) { + if (n.kind === 130) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 157 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 201); + var isCallExpression = node.parent.kind === 158 && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 202); var baseClass; if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -13083,31 +13185,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 135; + canUseSuperExpression = container.kind === 136; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 163) { + while (container && container.kind === 164) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } - if (container && container.parent && container.parent.kind === 201) { + if (container && container.parent && container.parent.kind === 202) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 134 || - container.kind === 133 || - container.kind === 136 || - container.kind === 137; + container.kind === 135 || + container.kind === 134 || + container.kind === 137 || + container.kind === 138; } else { canUseSuperExpression = - container.kind === 134 || - container.kind === 133 || - container.kind === 136 || + container.kind === 135 || + container.kind === 134 || container.kind === 137 || + container.kind === 138 || + container.kind === 133 || container.kind === 132 || - container.kind === 131 || - container.kind === 135; + container.kind === 136; } } } @@ -13121,7 +13223,7 @@ var ts; getNodeLinks(node).flags |= 16; returnType = baseClass; } - if (container.kind === 135 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 136 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -13131,7 +13233,7 @@ var ts; return returnType; } } - if (container && container.kind === 127) { + if (container && container.kind === 128) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -13156,7 +13258,7 @@ var ts; } if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); } } } @@ -13169,7 +13271,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129) { + if (declaration.kind === 130) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -13184,7 +13286,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 135 || func.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137))) { + if (func.type || func.kind === 136 || func.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 138))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignatureForFunctionLikeDeclaration(func); @@ -13204,7 +13306,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 159) { + if (template.parent.kind === 160) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -13312,32 +13414,32 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 198: - case 129: + case 199: + case 130: + case 133: case 132: - case 131: - case 152: - return getContextualTypeForInitializerExpression(node); - case 163: - case 191: - return getContextualTypeForReturnExpression(node); - case 157: - case 158: - return getContextualTypeForArgument(parent, node); - case 160: - return getTypeFromTypeNode(parent.type); - case 169: - return getContextualTypeForBinaryOperand(node); - case 224: - return getContextualTypeForObjectLiteralElement(parent); case 153: - return getContextualTypeForElementExpression(node); - case 170: - return getContextualTypeForConditionalOperand(node); - case 176: - ts.Debug.assert(parent.parent.kind === 171); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 164: + case 192: + return getContextualTypeForReturnExpression(node); + case 158: + case 159: + return getContextualTypeForArgument(parent, node); case 161: + return getTypeFromTypeNode(parent.type); + case 170: + return getContextualTypeForBinaryOperand(node); + case 225: + return getContextualTypeForObjectLiteralElement(parent); + case 154: + return getContextualTypeForElementExpression(node); + case 171: + return getContextualTypeForConditionalOperand(node); + case 178: + ts.Debug.assert(parent.parent.kind === 172); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 162: return getContextualType(parent); } return undefined; @@ -13352,13 +13454,13 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 162 || node.kind === 163; + return node.kind === 163 || node.kind === 164; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -13402,13 +13504,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 169 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 170 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (parent.kind === 224) { + if (parent.kind === 225) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 153) { + if (parent.kind === 154) { return isAssignmentTarget(parent); } return false; @@ -13427,7 +13529,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 173) { + if (inDestructuringPattern && e.kind === 174) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? checkIteratedType(restArrayType, undefined) : undefined); @@ -13439,7 +13541,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 173; + hasSpreadElement = hasSpreadElement || e.kind === 174; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -13450,7 +13552,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 127 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 128 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return allConstituentTypesHaveKind(checkComputedPropertyName(name), 1 | 132); @@ -13480,18 +13582,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 224 || - memberDecl.kind === 225 || + if (memberDecl.kind === 225 || + memberDecl.kind === 226 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 224) { + if (memberDecl.kind === 225) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 134) { + else if (memberDecl.kind === 135) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 225); + ts.Debug.assert(memberDecl.kind === 226); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -13506,7 +13608,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 136 || memberDecl.kind === 137); + ts.Debug.assert(memberDecl.kind === 137 || memberDecl.kind === 138); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -13539,7 +13641,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 132; + return s.valueDeclaration ? s.valueDeclaration.kind : 133; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -13549,7 +13651,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 201); + var enclosingClassDeclaration = ts.getAncestor(node, 202); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -13596,7 +13698,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -13608,14 +13710,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 155 + var left = node.kind === 156 ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { return false; } else { @@ -13630,7 +13732,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 158 && node.parent.expression === node) { + if (node.parent.kind === 159 && 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); @@ -13726,7 +13828,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 159) { + if (node.kind === 160) { checkExpression(node.template); } else { @@ -13779,7 +13881,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 173) { + if (args[i].kind === 174) { return i; } } @@ -13789,11 +13891,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 159) { + if (node.kind === 160) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 171) { + if (tagExpression.template.kind === 172) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -13808,7 +13910,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 158); + ts.Debug.assert(callExpression.kind === 159); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -13860,10 +13962,10 @@ var ts; } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175) { + if (arg.kind !== 176) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 159) { + if (i === 0 && args[i].parent.kind === 160) { argType = globalTemplateStringsArrayType; } else { @@ -13903,9 +14005,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175) { + if (arg.kind !== 176) { var paramType = getTypeAtPosition(signature, i); - var argType = i === 0 && node.kind === 159 + var argType = i === 0 && node.kind === 160 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) @@ -13919,10 +14021,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 159) { + if (node.kind === 160) { var template = node.template; args = [template]; - if (template.kind === 171) { + if (template.kind === 172) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -13935,7 +14037,7 @@ var ts; } function getEffectiveTypeArguments(callExpression) { if (callExpression.expression.kind === 91) { - var containingClass = ts.getAncestor(callExpression, 201); + var containingClass = ts.getAncestor(callExpression, 202); var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -13944,7 +14046,7 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 159; + var isTaggedTemplate = node.kind === 160; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); @@ -14154,13 +14256,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 157) { + if (node.kind === 158) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 158) { + else if (node.kind === 159) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 159) { + else if (node.kind === 160) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -14175,12 +14277,12 @@ var ts; if (node.expression.kind === 91) { return voidType; } - if (node.kind === 158) { + if (node.kind === 159) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 135 && - declaration.kind !== 139 && - declaration.kind !== 143) { + declaration.kind !== 136 && + declaration.kind !== 140 && + declaration.kind !== 144) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -14216,9 +14318,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var parameter = signature.parameters[signature.parameters.length - 1]; + var parameter = ts.lastOrUndefined(signature.parameters); var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -14227,7 +14329,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 179) { + if (func.body.kind !== 180) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -14265,7 +14367,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 195); + return (body.statements.length === 1) && (body.statements[0].kind === 196); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -14274,7 +14376,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 179) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 180) { return; } var bodyBlock = func.body; @@ -14287,9 +14389,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 162) { + if (!hasGrammarError && node.kind === 163) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -14306,10 +14408,9 @@ var ts; if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type) { - signature.resolvedReturnType = resolvingType; + if (!node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); - if (signature.resolvedReturnType === resolvingType) { + if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } @@ -14317,19 +14418,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 134 && node.kind !== 133) { + if (produceDiagnostics && node.kind !== 135 && node.kind !== 134) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 179) { + if (node.body.kind === 180) { checkSourceElement(node.body); } else { @@ -14359,13 +14460,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 155: { + case 156: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 156: + case 157: return true; - case 161: + case 162: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14374,11 +14475,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65: - case 155: { + case 156: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 156: { + case 157: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { @@ -14388,7 +14489,7 @@ var ts; } return false; } - case 161: + case 162: return isConstVariableReference(n.expression); default: return false; @@ -14513,7 +14614,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 224 || p.kind === 225) { + if (p.kind === 225 || p.kind === 226) { var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : getTypeOfPropertyOfType(sourceType, name_8.text) || @@ -14537,8 +14638,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175) { - if (e.kind !== 173) { + if (e.kind !== 176) { + if (e.kind !== 174) { var propName = "" + i; var type = sourceType.flags & 1 ? sourceType : isTupleLikeType(sourceType) @@ -14562,7 +14663,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 169 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 170 && restExpression.operatorToken.kind === 53) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -14575,14 +14676,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 169 && target.operatorToken.kind === 53) { + if (target.kind === 170 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 154) { + if (target.kind === 155) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 153) { + if (target.kind === 154) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -14599,7 +14700,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 154 || node.left.kind === 153)) { + if (operator === 53 && (node.left.kind === 155 || node.left.kind === 154)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -14773,14 +14874,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 127) { + if (node.name.kind === 128) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 127) { + if (node.name.kind === 128) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -14807,7 +14908,7 @@ var ts; } function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 126) { + if (node.kind == 127) { type = checkQualifiedName(node); } else { @@ -14815,9 +14916,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 155 && node.parent.expression === node) || - (node.parent.kind === 156 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 126) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 156 && node.parent.expression === node) || + (node.parent.kind === 157 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 127) && 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); } @@ -14843,54 +14944,54 @@ var ts; return booleanType; case 7: return checkNumericLiteral(node); - case 171: + case 172: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 153: - return checkArrayLiteral(node, contextualMapper); case 154: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 155: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 156: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 157: + return checkIndexedAccess(node); case 158: - return checkCallExpression(node); case 159: - return checkTaggedTemplateExpression(node); + return checkCallExpression(node); case 160: - return checkTypeAssertion(node); + return checkTaggedTemplateExpression(node); case 161: - return checkExpression(node.expression, contextualMapper); - case 174: - return checkClassExpression(node); + return checkTypeAssertion(node); case 162: - case 163: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 165: - return checkTypeOfExpression(node); - case 164: - return checkDeleteExpression(node); - case 166: - return checkVoidExpression(node); - case 167: - return checkPrefixUnaryExpression(node); - case 168: - return checkPostfixUnaryExpression(node); - case 169: - return checkBinaryExpression(node, contextualMapper); - case 170: - return checkConditionalExpression(node, contextualMapper); - case 173: - return checkSpreadElementExpression(node, contextualMapper); + return checkExpression(node.expression, contextualMapper); case 175: + return checkClassExpression(node); + case 163: + case 164: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 166: + return checkTypeOfExpression(node); + case 165: + return checkDeleteExpression(node); + case 167: + return checkVoidExpression(node); + case 168: + return checkPrefixUnaryExpression(node); + case 169: + return checkPostfixUnaryExpression(node); + case 170: + return checkBinaryExpression(node, contextualMapper); + case 171: + return checkConditionalExpression(node, contextualMapper); + case 174: + return checkSpreadElementExpression(node, contextualMapper); + case 176: return undefinedType; - case 172: + case 173: checkYieldExpression(node); return unknownType; } @@ -14919,7 +15020,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 135 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 136 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -14931,12 +15032,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 140) { + if (node.kind === 141) { checkGrammarIndexSignature(node); } - else if (node.kind === 142 || node.kind === 200 || node.kind === 143 || - node.kind === 138 || node.kind === 135 || - node.kind === 139) { + else if (node.kind === 143 || node.kind === 201 || node.kind === 144 || + node.kind === 139 || node.kind === 136 || + node.kind === 140) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -14948,10 +15049,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 139: + case 140: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 138: + case 139: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14960,7 +15061,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 202) { + if (node.kind === 203) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14975,7 +15076,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 121: + case 122: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14983,7 +15084,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 119: + case 120: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -15020,17 +15121,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 157 && n.expression.kind === 91; + return n.kind === 158 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 162: - case 200: case 163: - case 154: return false; + case 201: + case 164: + case 155: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -15038,12 +15139,12 @@ var ts; if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 162 && n.kind !== 200) { + else if (n.kind !== 163 && n.kind !== 201) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 132 && + return n.kind === 133 && !(n.flags & 128) && !!n.initializer; } @@ -15053,7 +15154,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 182 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 183 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -15069,13 +15170,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 136) { + if (node.kind === 137) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 136 ? 137 : 136; + var otherKind = node.kind === 137 ? 138 : 137; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -15090,7 +15191,7 @@ var ts; } } } - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + getTypeOfAccessors(getSymbolOfNode(node)); } checkFunctionLikeDeclaration(node); } @@ -15099,15 +15200,15 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrHeritageClauseElement(node); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkHeritageClauseElement(node) { - checkGrammarHeritageClauseElementInStrictMode(node.expression); - return checkTypeReferenceOrHeritageClauseElement(node); + function checkExpressionWithTypeArguments(node) { + checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkTypeReferenceOrHeritageClauseElement(node) { + function checkTypeReferenceOrExpressionWithTypeArguments(node) { checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrHeritageClauseElement(node); + var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); if (type !== unknownType && node.typeArguments) { var len = node.typeArguments.length; for (var i = 0; i < len; i++) { @@ -15160,9 +15261,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 202) { - ts.Debug.assert(signatureDeclarationNode.kind === 138 || signatureDeclarationNode.kind === 139); - var signatureKind = signatureDeclarationNode.kind === 138 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203) { + ts.Debug.assert(signatureDeclarationNode.kind === 139 || signatureDeclarationNode.kind === 140); + var signatureKind = signatureDeclarationNode.kind === 139 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -15180,7 +15281,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 202 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 203 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -15253,7 +15354,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) { - ts.Debug.assert(node.kind === 134 || node.kind === 133); + ts.Debug.assert(node.kind === 135 || node.kind === 134); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -15280,11 +15381,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 202 || node.parent.kind === 145 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 203 || node.parent.kind === 146 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 200 || node.kind === 134 || node.kind === 133 || node.kind === 135) { + if (node.kind === 201 || node.kind === 135 || node.kind === 134 || node.kind === 136) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -15381,16 +15482,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 202: + case 203: return 2097152; - case 205: + case 206: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 201: - case 204: + case 202: + case 205: return 2097152 | 1048576; - case 208: + case 209: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -15404,29 +15505,29 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 201: + case 202: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 132: + case 133: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 134: - case 136: + case 135: case 137: + case 138: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 129: + case 130: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 141) { + if (node && node.kind === 142) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 | 132 | 258))) { @@ -15439,19 +15540,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 132: + case 133: checkTypeNodeAsExpression(node.type); break; - case 129: + case 130: checkTypeNodeAsExpression(node.type); break; - case 134: - checkTypeNodeAsExpression(node.type); - break; - case 136: + case 135: checkTypeNodeAsExpression(node.type); break; case 137: + checkTypeNodeAsExpression(node.type); + break; + case 138: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -15471,24 +15572,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 201: + case 202: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 134: + case 135: checkParameterTypeAnnotationsAsExpressions(node); + case 138: case 137: - case 136: - case 132: - case 129: + case 133: + case 130: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 129) { + if (node.kind === 130) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -15508,7 +15609,7 @@ var ts; checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 127) { + if (node.name && node.name.kind === 128) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -15533,11 +15634,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 179) { + if (node.kind === 180) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 206) { + if (ts.isFunctionBlock(node) || node.kind === 207) { checkFunctionExpressionBodies(node); } } @@ -15555,19 +15656,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 132 || - node.kind === 131 || + if (node.kind === 133 || + node.kind === 132 || + node.kind === 135 || node.kind === 134 || - node.kind === 133 || - node.kind === 136 || - node.kind === 137) { + node.kind === 137 || + node.kind === 138) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = getRootDeclaration(node); - if (root.kind === 129 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 130 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -15597,7 +15698,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 201); + var enclosingClass = ts.getAncestor(node, 202); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } @@ -15615,12 +15716,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 205 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 206 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 227 && ts.isExternalModule(parent)) { - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + if (parent.kind === 228 && ts.isExternalModule(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)); } } function checkVarDeclaredNamesNotShadowed(node) { @@ -15630,7 +15731,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || isParameterDeclaration(node)) { return; } - if (node.kind === 198 && !node.initializer) { + if (node.kind === 199 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -15640,15 +15741,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 199); - var container = varDeclList.parent.kind === 180 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200); + var container = varDeclList.parent.kind === 181 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 179 && ts.isFunctionLike(container.parent) || + (container.kind === 180 && ts.isFunctionLike(container.parent) || + container.kind === 207 || container.kind === 206 || - container.kind === 205 || - container.kind === 227); + container.kind === 228); if (!namesShareScope) { var name_9 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_9, name_9); @@ -15658,13 +15759,13 @@ var ts; } } function isParameterDeclaration(node) { - while (node.kind === 152) { + while (node.kind === 153) { node = node.parent.parent; } - return node.kind === 129; + return node.kind === 130; } function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 129) { + if (getRootDeclaration(node).kind !== 130) { return; } var func = ts.getContainingFunction(node); @@ -15673,7 +15774,7 @@ var ts; if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 129) { + if (referencedSymbol.valueDeclaration.kind === 130) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -15694,7 +15795,7 @@ var ts; checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 127) { + if (node.name.kind === 128) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -15703,7 +15804,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && getRootDeclaration(node).kind === 129 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 130 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -15731,9 +15832,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 133 && node.kind !== 132) { checkExportsOnMergedDeclarations(node); - if (node.kind === 198 || node.kind === 152) { + if (node.kind === 199 || node.kind === 153) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -15762,7 +15863,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 179 || node.kind === 154) { + if (node.kind === 180 || node.kind === 155) { return true; } node = node.parent; @@ -15790,12 +15891,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 199) { + if (node.initializer && node.initializer.kind == 200) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -15810,13 +15911,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 153 || varExpr.kind === 154) { + if (varExpr.kind === 154 || varExpr.kind === 155) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -15831,7 +15932,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { 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); @@ -15841,7 +15942,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 153 || varExpr.kind === 154) { + if (varExpr.kind === 154 || varExpr.kind === 155) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 | 258)) { @@ -16002,7 +16103,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137))); + return !!(node.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -16016,11 +16117,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 137) { + if (func.kind === 138) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 135) { + if (func.kind === 136) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -16047,7 +16148,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 221 && !hasDuplicateDefaultClause) { + if (clause.kind === 222 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -16059,7 +16160,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 220) { + if (produceDiagnostics && clause.kind === 221) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -16076,7 +16177,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 194 && current.label.text === node.label.text) { + if (current.kind === 195 && 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; @@ -16140,7 +16241,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 201) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 202) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -16171,7 +16272,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 128 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -16222,7 +16323,7 @@ var ts; } function checkClassDeclaration(node) { checkGrammarDeclarationNameInStrictMode(node); - if (node.parent.kind !== 206 && node.parent.kind !== 227) { + if (node.parent.kind !== 207 && node.parent.kind !== 228) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); } if (!node.name && !(node.flags & 256)) { @@ -16242,11 +16343,11 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedHeritageClauseElement(baseTypeNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkHeritageClauseElement(baseTypeNode); + checkExpressionWithTypeArguments(baseTypeNode); } var baseTypes = getBaseTypes(type); if (baseTypes.length) { @@ -16267,12 +16368,12 @@ var ts; var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { - if (!ts.isSupportedHeritageClauseElement(typeRefNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(typeRefNode); + checkExpressionWithTypeArguments(typeRefNode); if (produceDiagnostics) { - var t = getTypeFromHeritageClauseElement(typeRefNode); + var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { @@ -16352,7 +16453,7 @@ var ts; } } function isAccessor(kind) { - return kind === 136 || kind === 137; + return kind === 137 || kind === 138; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -16418,7 +16519,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 202); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203); 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); @@ -16435,10 +16536,10 @@ var ts; } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedHeritageClauseElement(heritageElement)) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(heritageElement); + checkExpressionWithTypeArguments(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -16459,7 +16560,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 127 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 128 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -16495,7 +16596,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 167: + case 168: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -16506,7 +16607,7 @@ var ts; case 47: return ~value; } return undefined; - case 169: + case 170: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -16531,11 +16632,11 @@ var ts; return undefined; case 7: return +e.text; - case 161: + case 162: return evalConstant(e.expression); case 65: + case 157: case 156: - case 155: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -16546,7 +16647,7 @@ var ts; } else { var expression; - if (e.kind === 156) { + if (e.kind === 157) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -16563,7 +16664,7 @@ var ts; if (current.kind === 65) { break; } - else if (current.kind === 155) { + else if (current.kind === 156) { current = current.expression; } else { @@ -16620,7 +16721,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 204) { + if (declaration.kind !== 205) { return false; } var enumDeclaration = declaration; @@ -16643,8 +16744,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 201 || - (declaration.kind === 200 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 202 || + (declaration.kind === 201 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -16682,13 +16783,13 @@ var ts; var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); } else if (node.pos < firstNonAmbientClassOrFunc.pos) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); + 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, 201); + var mergedClass = ts.getDeclarationOfKind(symbol, 202); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048; @@ -16696,10 +16797,10 @@ var ts; } if (node.name.kind === 8) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } if (isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name); + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } } @@ -16707,10 +16808,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 126) { + if (node.kind === 127) { node = node.left; } - else if (node.kind === 155) { + else if (node.kind === 156) { node = node.expression; } else { @@ -16726,15 +16827,15 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 206 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 227 && !inAmbientExternalModule) { - error(moduleName, node.kind === 215 ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : - ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 228 && !inAmbientExternalModule) { + error(moduleName, node.kind === 216 ? + 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 && isExternalModuleNameRelative(moduleName.text)) { - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } return true; @@ -16747,7 +16848,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 217 ? + var message = node.kind === 218 ? 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)); @@ -16770,7 +16871,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211) { + if (importClause.namedBindings.kind === 212) { checkImportBinding(importClause.namedBindings); } else { @@ -16815,15 +16916,15 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 206 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 227 && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 228 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } @@ -16835,9 +16936,9 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 227 ? node.parent : node.parent.parent; - if (container.kind === 205 && container.name.kind === 65) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); + var container = node.parent.kind === 228 ? node.parent : node.parent.parent; + if (container.kind === 206 && container.name.kind === 65) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { @@ -16850,15 +16951,20 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if (node.isExportEquals && languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } + else if (compilerOptions.module === 4) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } } } function getModuleStatements(node) { - if (node.kind === 227) { + if (node.kind === 228) { return node.statements; } - if (node.kind === 205 && node.body.kind === 206) { + if (node.kind === 206 && node.body.kind === 207) { return node.body.statements; } return emptyArray; @@ -16887,163 +16993,162 @@ var ts; if (!node) return; switch (node.kind) { - case 128: - return checkTypeParameter(node); case 129: + return checkTypeParameter(node); + case 130: return checkParameter(node); + case 133: case 132: - case 131: return checkPropertyDeclaration(node); - case 142: case 143: - case 138: + case 144: case 139: - return checkSignatureDeclaration(node); case 140: return checkSignatureDeclaration(node); - case 134: - case 133: - return checkMethodDeclaration(node); - case 135: - return checkConstructorDeclaration(node); - case 136: - case 137: - return checkAccessorDeclaration(node); case 141: + return checkSignatureDeclaration(node); + case 135: + case 134: + return checkMethodDeclaration(node); + case 136: + return checkConstructorDeclaration(node); + case 137: + case 138: + return checkAccessorDeclaration(node); + case 142: return checkTypeReferenceNode(node); - case 144: - return checkTypeQuery(node); case 145: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 146: - return checkArrayType(node); + return checkTypeLiteral(node); case 147: - return checkTupleType(node); + return checkArrayType(node); case 148: - return checkUnionType(node); + return checkTupleType(node); case 149: + return checkUnionType(node); + case 150: return checkSourceElement(node.type); - case 200: - return checkFunctionDeclaration(node); - case 179: - case 206: - return checkBlock(node); - case 180: - return checkVariableStatement(node); - case 182: - return checkExpressionStatement(node); - case 183: - return checkIfStatement(node); - case 184: - return checkDoStatement(node); - case 185: - return checkWhileStatement(node); - case 186: - return checkForStatement(node); - case 187: - return checkForInStatement(node); - case 188: - return checkForOfStatement(node); - case 189: - case 190: - return checkBreakOrContinueStatement(node); - case 191: - return checkReturnStatement(node); - case 192: - return checkWithStatement(node); - case 193: - return checkSwitchStatement(node); - case 194: - return checkLabeledStatement(node); - case 195: - return checkThrowStatement(node); - case 196: - return checkTryStatement(node); - case 198: - return checkVariableDeclaration(node); - case 152: - return checkBindingElement(node); case 201: - return checkClassDeclaration(node); - case 202: - return checkInterfaceDeclaration(node); - case 203: - return checkTypeAliasDeclaration(node); - case 204: - return checkEnumDeclaration(node); - case 205: - return checkModuleDeclaration(node); - case 209: - return checkImportDeclaration(node); - case 208: - return checkImportEqualsDeclaration(node); - case 215: - return checkExportDeclaration(node); - case 214: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 180: + case 207: + return checkBlock(node); case 181: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 183: + return checkExpressionStatement(node); + case 184: + return checkIfStatement(node); + case 185: + return checkDoStatement(node); + case 186: + return checkWhileStatement(node); + case 187: + return checkForStatement(node); + case 188: + return checkForInStatement(node); + case 189: + return checkForOfStatement(node); + case 190: + case 191: + return checkBreakOrContinueStatement(node); + case 192: + return checkReturnStatement(node); + case 193: + return checkWithStatement(node); + case 194: + return checkSwitchStatement(node); + case 195: + return checkLabeledStatement(node); + case 196: + return checkThrowStatement(node); case 197: + return checkTryStatement(node); + case 199: + return checkVariableDeclaration(node); + case 153: + return checkBindingElement(node); + case 202: + return checkClassDeclaration(node); + case 203: + return checkInterfaceDeclaration(node); + case 204: + return checkTypeAliasDeclaration(node); + case 205: + return checkEnumDeclaration(node); + case 206: + return checkModuleDeclaration(node); + case 210: + return checkImportDeclaration(node); + case 209: + return checkImportEqualsDeclaration(node); + case 216: + return checkExportDeclaration(node); + case 215: + return checkExportAssignment(node); + case 182: checkGrammarStatementInAmbientContext(node); return; - case 218: + case 198: + checkGrammarStatementInAmbientContext(node); + return; + case 219: return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 162: case 163: + case 164: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case 135: case 134: - case 133: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 135: case 136: case 137: - case 200: + case 138: + case 201: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 192: + case 193: checkFunctionExpressionBodies(node.expression); break; - case 129: + case 130: + case 133: case 132: - case 131: - case 150: case 151: case 152: case 153: case 154: - case 224: case 155: + case 225: case 156: case 157: case 158: case 159: - case 171: - case 176: case 160: + case 172: + case 178: case 161: - case 165: + case 162: case 166: - case 164: case 167: + case 165: case 168: case 169: case 170: - case 173: - case 179: - case 206: + case 171: + case 174: case 180: - case 182: + case 207: + case 181: case 183: case 184: case 185: @@ -17053,21 +17158,22 @@ var ts; case 189: case 190: case 191: - case 193: - case 207: - case 220: - case 221: + case 192: case 194: + case 208: + case 221: + case 222: case 195: case 196: - case 223: - case 198: + case 197: + case 224: case 199: - case 201: - case 204: - case 226: - case 214: + case 200: + case 202: + case 205: case 227: + case 215: + case 228: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -17127,7 +17233,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 192 && node.parent.statement === node) { + if (node.parent.kind === 193 && node.parent.statement === node) { return true; } node = node.parent; @@ -17149,23 +17255,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227: + case 228: if (!ts.isExternalModule(location)) { break; } - case 205: + case 206: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 204: + case 205: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 201: case 202: + case 203: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 162: + case 163: if (location.name) { copySymbol(location.symbol, meaning); } @@ -17201,22 +17307,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227: + case 228: if (!ts.isExternalModule(location)) break; - case 205: + case 206: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 204: + case 205: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 201: case 202: + case 203: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 162: + case 163: if (location.name) { copySymbol(location.symbol, meaning); } @@ -17235,104 +17341,104 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 128: - case 201: + case 129: case 202: case 203: case 204: + case 205: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 126) { + while (node.parent && node.parent.kind === 127) { node = node.parent; } - return node.parent && node.parent.kind === 141; + return node.parent && node.parent.kind === 142; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 155) { + while (node.parent && node.parent.kind === 156) { node = node.parent; } return node.parent && node.parent.kind === 177; } function isTypeNode(node) { - if (141 <= node.kind && node.kind <= 149) { + if (142 <= node.kind && node.kind <= 150) { return true; } switch (node.kind) { case 112: - case 119: - case 121: - case 113: + case 120: case 122: + case 113: + case 123: return true; case 99: - return node.parent.kind !== 166; + return node.parent.kind !== 167; case 8: - return node.parent.kind === 129; + return node.parent.kind === 130; case 177: return true; case 65: - if (node.parent.kind === 126 && node.parent.right === node) { + if (node.parent.kind === 127 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 155 && node.parent.name === node) { + else if (node.parent.kind === 156 && node.parent.name === node) { node = node.parent; } - case 126: - case 155: - ts.Debug.assert(node.kind === 65 || node.kind === 126 || node.kind === 155, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 127: + case 156: + ts.Debug.assert(node.kind === 65 || node.kind === 127 || node.kind === 156, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_5 = node.parent; - if (parent_5.kind === 144) { + if (parent_5.kind === 145) { return false; } - if (141 <= parent_5.kind && parent_5.kind <= 149) { + if (142 <= parent_5.kind && parent_5.kind <= 150) { return true; } switch (parent_5.kind) { case 177: return true; - case 128: - return node === parent_5.constraint; - case 132: - case 131: case 129: - case 198: + return node === parent_5.constraint; + case 133: + case 132: + case 130: + case 199: return node === parent_5.type; - case 200: - case 162: + case 201: case 163: + case 164: + case 136: case 135: case 134: - case 133: - case 136: case 137: - return node === parent_5.type; case 138: + return node === parent_5.type; case 139: case 140: + case 141: return node === parent_5.type; - case 160: + case 161: return node === parent_5.type; - case 157: case 158: - return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; case 159: + return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; + case 160: return false; } } return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 126) { + while (nodeOnRightSide.parent.kind === 127) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 208) { + if (nodeOnRightSide.parent.kind === 209) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 214) { + if (nodeOnRightSide.parent.kind === 215) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -17344,10 +17450,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 214) { + if (entityName.parent.kind === 215) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 155) { + if (entityName.kind !== 156) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -17368,14 +17474,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 155) { + else if (entityName.kind === 156) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 126) { + else if (entityName.kind === 127) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -17384,7 +17490,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 141 ? 793056 : 1536; + var meaning = entityName.parent.kind === 142 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -17398,14 +17504,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 214 + return node.parent.kind === 215 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65: - case 155: - case 126: + case 156: + case 127: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93: case 91: @@ -17413,7 +17519,7 @@ var ts; return type.symbol; case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 135) { + if (constructorDeclaration && constructorDeclaration.kind === 136) { return constructorDeclaration.parent.symbol; } return undefined; @@ -17421,12 +17527,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 209 || node.parent.kind === 215) && + ((node.parent.kind === 210 || node.parent.kind === 216) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 156 && node.parent.argumentExpression === node) { + if (node.parent.kind == 157 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -17440,7 +17546,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 225) { + if (location && location.kind === 226) { return resolveEntityName(location.name, 107455); } return undefined; @@ -17514,7 +17620,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 227; + return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228; } function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { if (languageVersion >= 2) { @@ -17522,7 +17628,7 @@ var ts; } var node = getDeclarationOfAliasSymbol(symbol); if (node) { - if (node.kind === 210) { + if (node.kind === 211) { var defaultKeyword; if (languageVersion === 0) { defaultKeyword = "[\"default\"]"; @@ -17532,7 +17638,7 @@ var ts; } return getGeneratedNameForNode(node.parent) + defaultKeyword; } - if (node.kind === 213) { + if (node.kind === 214) { var moduleName = getGeneratedNameForNode(node.parent.parent.parent); var propertyName = node.propertyName || node.name; return moduleName + "." + ts.unescapeIdentifier(propertyName.text); @@ -17541,7 +17647,7 @@ var ts; } function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { - if (languageVersion >= 2) { + if (languageVersion >= 2 || compilerOptions.module === 4) { return undefined; } return "exports." + ts.unescapeIdentifier(symbol.name); @@ -17549,7 +17655,7 @@ var ts; var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 205 || node.kind === 204) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 206 || node.kind === 205) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; @@ -17572,22 +17678,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 208: - case 210: + case 209: case 211: - case 213: - case 217: + case 212: + case 214: + case 218: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 215: + case 216: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 214: + case 215: return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 227 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 228 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -17632,7 +17738,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 226) { + if (node.kind === 227) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -17663,7 +17769,7 @@ var ts; } } function serializeTypeReferenceNode(node, getGeneratedNameForNode) { - var type = getTypeFromTypeReference(node); + var type = getTypeFromTypeNode(node); if (type.flags & 16) { return "void 0"; } @@ -17700,26 +17806,26 @@ var ts; switch (node.kind) { case 99: return "void 0"; - case 149: + case 150: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 142: case 143: + case 144: return "Function"; - case 146: case 147: + case 148: return "Array"; case 113: return "Boolean"; - case 121: + case 122: case 8: return "String"; - case 119: + case 120: return "Number"; - case 141: + case 142: return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 144: case 145: - case 148: + case 146: + case 149: case 112: break; default: @@ -17731,11 +17837,11 @@ var ts; } function serializeTypeOfNode(node, getGeneratedNameForNode) { switch (node.kind) { - case 201: return "Function"; - case 132: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 129: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 136: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 202: return "Function"; + case 133: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 130: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 137: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 138: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); } if (ts.isFunctionLike(node)) { return "Function"; @@ -17745,7 +17851,7 @@ var ts; function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { if (node) { var valueDeclaration; - if (node.kind === 201) { + if (node.kind === 202) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -17760,10 +17866,10 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 146) { + if (parameterType.kind === 147) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 141 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 142 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -17809,15 +17915,21 @@ var ts; ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); return !!resolveName(location, name, 107455, undefined, undefined); } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 8388608, undefined, undefined); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 152 || (n.parent.kind === 198 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 153 || (n.parent.kind === 199 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 223; + symbol.valueDeclaration.parent.kind !== 224; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -17854,6 +17966,7 @@ var ts; resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, + getReferencedValueDeclaration: getReferencedValueDeclaration, serializeTypeOfNode: serializeTypeOfNode, serializeParameterTypesOfNode: serializeParameterTypesOfNode, serializeReturnTypeOfNode: serializeReturnTypeOfNode @@ -17899,10 +18012,10 @@ var ts; } function isReservedWordInStrictMode(node) { return (node.parserContextFlags & 1) && - (node.originalKeywordKind >= 102 && node.originalKeywordKind <= 110); + (102 <= node.originalKeywordKind && node.originalKeywordKind <= 110); } function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) { + if (ts.getAncestor(identifier, 202) || ts.getAncestor(identifier, 175)) { return grammarErrorOnNode(identifier, message, arg0); } return false; @@ -17912,19 +18025,19 @@ var ts; var impotClause = node.importClause; if (impotClause.namedBindings) { var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 211) { + if (nameBindings.kind === 212) { var name_11 = nameBindings.name; - if (name_11.originalKeywordKind) { + if (isReservedWordInStrictMode(name_11)) { var nameText = ts.declarationNameToString(name_11); return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } } - else if (nameBindings.kind === 212) { + else if (nameBindings.kind === 213) { var reportError = false; for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { var element = _a[_i]; var name_12 = element.name; - if (name_12.originalKeywordKind) { + if (isReservedWordInStrictMode(name_12)) { var nameText = ts.declarationNameToString(name_12); reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -17940,20 +18053,20 @@ var ts; if (name && name.kind === 65 && isReservedWordInStrictMode(name)) { var nameText = ts.declarationNameToString(name); switch (node.kind) { + case 130: + case 199: + case 201: case 129: - case 198: - case 200: - case 128: - case 152: - case 202: + case 153: case 203: case 204: - return checkGrammarIdentifierInStrictMode(name); - case 201: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); case 205: + return checkGrammarIdentifierInStrictMode(name); + case 202: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); + case 206: return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 208: + case 209: return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } } @@ -17963,17 +18076,17 @@ var ts; if (typeName.kind === 65) { checkGrammarTypeNameInStrictMode(typeName); } - else if (typeName.kind === 126) { + else if (typeName.kind === 127) { checkGrammarTypeNameInStrictMode(typeName.right); checkGrammarTypeReferenceInStrictMode(typeName.left); } } - function checkGrammarHeritageClauseElementInStrictMode(expression) { + function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { if (expression && expression.kind === 65) { return checkGrammarIdentifierInStrictMode(expression); } - else if (expression && expression.kind === 155) { - checkGrammarHeritageClauseElementInStrictMode(expression.expression); + else if (expression && expression.kind === 156) { + checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); } } function checkGrammarIdentifierInStrictMode(node, nameText) { @@ -18006,7 +18119,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 136 || node.kind === 137) { + else if (node.kind === 137 || node.kind === 138) { 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); @@ -18016,26 +18129,26 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 136: case 137: - case 135: - case 132: - case 131: - case 134: + case 138: + case 136: case 133: - case 140: - case 201: + case 132: + case 135: + case 134: + case 141: case 202: - case 205: - case 204: - case 180: - case 200: case 203: + case 206: + case 205: + case 181: + case 201: + case 204: + case 210: case 209: - case 208: + case 216: case 215: - case 214: - case 129: + case 130: break; default: return false; @@ -18069,7 +18182,7 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 206 || node.parent.kind === 227) { + else if (node.parent.kind === 207 || node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -18078,10 +18191,10 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 206 || node.parent.kind === 227) { + else if (node.parent.kind === 207 || node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 129) { + else if (node.kind === 130) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; @@ -18094,10 +18207,10 @@ var ts; else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 201) { + else if (node.parent.kind === 202) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 129) { + else if (node.kind === 130) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -18106,13 +18219,13 @@ var ts; if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 201) { + else if (node.parent.kind === 202) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 129) { + else if (node.kind === 130) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 206) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -18120,7 +18233,7 @@ var ts; break; } } - if (node.kind === 135) { + if (node.kind === 136) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -18131,13 +18244,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 209 || node.kind === 208) && flags & 2) { + else if ((node.kind === 210 || node.kind === 209) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 202 && flags & 2) { + else if (node.kind === 203 && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 129 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 130 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -18200,7 +18313,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 163) { + if (node.kind === 164) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -18235,7 +18348,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { + if (parameter.type.kind !== 122 && parameter.type.kind !== 120) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -18267,7 +18380,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 175) { + if (arg.kind === 176) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -18338,11 +18451,11 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 127) { + if (node.kind !== 128) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 169 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 170 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -18369,26 +18482,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_13 = prop.name; - if (prop.kind === 175 || - name_13.kind === 127) { + if (prop.kind === 176 || + name_13.kind === 128) { checkGrammarComputedPropertyName(name_13); continue; } var currentKind = void 0; - if (prop.kind === 224 || prop.kind === 225) { + if (prop.kind === 225 || prop.kind === 226) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_13.kind === 7) { checkGrammarNumericLiteral(name_13); } currentKind = Property; } - else if (prop.kind === 134) { + else if (prop.kind === 135) { currentKind = Property; } - else if (prop.kind === 136) { + else if (prop.kind === 137) { currentKind = GetAccessor; } - else if (prop.kind === 137) { + else if (prop.kind === 138) { currentKind = SetAccesor; } else { @@ -18422,24 +18535,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 199) { + if (forInOrOfStatement.initializer.kind === 200) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 187 + var diagnostic = forInOrOfStatement.kind === 188 ? 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 = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 187 + var diagnostic = forInOrOfStatement.kind === 188 ? 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 === 187 + var diagnostic = forInOrOfStatement.kind === 188 ? 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); @@ -18462,10 +18575,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 136 && accessor.parameters.length) { + else if (kind === 137 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 137) { + else if (kind === 138) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -18490,7 +18603,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 127 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 128 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -18500,7 +18613,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 154) { + if (node.parent.kind === 155) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -18508,7 +18621,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 201) { + if (node.parent.kind === 202) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -18519,22 +18632,22 @@ 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 === 202) { + else if (node.parent.kind === 203) { 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 === 145) { + else if (node.parent.kind === 146) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 186: case 187: case 188: - case 184: + case 189: case 185: + case 186: return true; - case 194: + case 195: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -18546,9 +18659,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 194: + case 195: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 189 + var isMisplacedContinueLabel = node.kind === 190 && !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); @@ -18556,8 +18669,8 @@ var ts; return false; } break; - case 193: - if (node.kind === 190 && !node.label) { + case 194: + if (node.kind === 191 && !node.label) { return false; } break; @@ -18570,13 +18683,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 190 + var message = node.kind === 191 ? 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 === 190 + var message = node.kind === 191 ? 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); @@ -18585,10 +18698,10 @@ var ts; function checkGrammarBindingElement(node) { if (node.dotDotDotToken) { var elements = node.parent.elements; - if (node !== elements[elements.length - 1]) { + 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 === 151 || node.name.kind === 150) { + if (node.name.kind === 152 || node.name.kind === 151) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -18598,7 +18711,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 187 && node.parent.parent.kind !== 188) { + if (node.parent.parent.kind !== 188 && node.parent.parent.kind !== 189) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -18628,7 +18741,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 175) { + if (element.kind !== 176) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -18645,15 +18758,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 183: case 184: case 185: - case 192: case 186: + case 193: case 187: case 188: + case 189: return false; - case 194: + case 195: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -18669,7 +18782,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 167) { + if (expression.kind === 168) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -18688,7 +18801,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 127) { + if (node.name.kind === 128) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -18758,18 +18871,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 201) { + if (node.parent.kind === 202) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 203) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 145) { + else if (node.parent.kind === 146) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -18779,11 +18892,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 202 || + if (node.kind === 203 || + node.kind === 210 || node.kind === 209 || - node.kind === 208 || + node.kind === 216 || node.kind === 215 || - node.kind === 214 || (node.flags & 2) || (node.flags & (1 | 256))) { return false; @@ -18793,7 +18906,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 === 180) { + if (ts.isDeclaration(decl) || decl.kind === 181) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -18812,7 +18925,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 === 179 || node.parent.kind === 206 || node.parent.kind === 227) { + if (node.parent.kind === 180 || node.parent.kind === 207 || node.parent.kind === 228) { 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); @@ -18893,7 +19006,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 209); + ts.Debug.assert(aliasEmitInfo.node.kind === 210); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -18966,10 +19079,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 198) { + if (declaration.kind === 199) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 212 || declaration.kind === 213 || declaration.kind === 210) { + else if (declaration.kind === 213 || declaration.kind === 214 || declaration.kind === 211) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -18980,7 +19093,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 209) { + if (moduleElementEmitInfo.node.kind === 210) { moduleElementEmitInfo.isVisible = true; } else { @@ -18988,12 +19101,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 205) { + if (nodeToCheck.kind === 206) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 205) { + if (nodeToCheck.kind === 206) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -19081,39 +19194,39 @@ var ts; function emitType(type) { switch (type.kind) { case 112: - case 121: - case 119: - case 113: case 122: + case 120: + case 113: + case 123: case 99: case 8: return writeTextOfNode(currentSourceFile, type); case 177: - return emitHeritageClauseElement(type); - case 141: - return emitTypeReference(type); - case 144: - return emitTypeQuery(type); - case 146: - return emitArrayType(type); - case 147: - return emitTupleType(type); - case 148: - return emitUnionType(type); - case 149: - return emitParenType(type); + return emitExpressionWithTypeArguments(type); case 142: - case 143: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 145: + return emitTypeQuery(type); + case 147: + return emitArrayType(type); + case 148: + return emitTupleType(type); + case 149: + return emitUnionType(type); + case 150: + return emitParenType(type); + case 143: + case 144: + return emitSignatureDeclarationWithJsDocComments(type); + case 146: return emitTypeLiteral(type); case 65: return emitEntityName(type); - case 126: + case 127: return emitEntityName(type); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 208 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 209 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -19121,17 +19234,17 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 126 ? entityName.left : entityName.expression; - var right = entityName.kind === 126 ? entityName.right : entityName.name; + var left = entityName.kind === 127 ? entityName.left : entityName.expression; + var right = entityName.kind === 127 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } } - function emitHeritageClauseElement(node) { - if (ts.isSupportedHeritageClauseElement(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 155); + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 156); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -19235,10 +19348,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 208 || - (node.parent.kind === 227 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 209 || + (node.parent.kind === 228 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 227) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -19247,7 +19360,7 @@ var ts; }); } else { - if (node.kind === 209) { + if (node.kind === 210) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -19265,23 +19378,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 200: - return writeFunctionDeclaration(node); - case 180: - return writeVariableStatement(node); - case 202: - return writeInterfaceDeclaration(node); case 201: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 181: + return writeVariableStatement(node); case 203: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 202: + return writeClassDeclaration(node); case 204: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 205: + return writeEnumDeclaration(node); + case 206: return writeModuleDeclaration(node); - case 208: - return writeImportEqualsDeclaration(node); case 209: + return writeImportEqualsDeclaration(node); + case 210: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -19295,7 +19408,7 @@ var ts; if (node.flags & 256) { write("default "); } - else if (node.kind !== 202) { + else if (node.kind !== 203) { write("declare "); } } @@ -19339,7 +19452,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 211) { + if (namedBindings.kind === 212) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -19365,7 +19478,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 211) { + if (node.importClause.namedBindings.kind === 212) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -19416,7 +19529,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 206) { + while (node.body.kind !== 207) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -19477,7 +19590,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 134 && (node.parent.flags & 32); + return node.parent.kind === 135 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -19487,15 +19600,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 142 || - node.parent.kind === 143 || - (node.parent.parent && node.parent.parent.kind === 145)) { - ts.Debug.assert(node.parent.kind === 134 || - node.parent.kind === 133 || - node.parent.kind === 142 || + if (node.parent.kind === 143 || + node.parent.kind === 144 || + (node.parent.parent && node.parent.parent.kind === 146)) { + ts.Debug.assert(node.parent.kind === 135 || + node.parent.kind === 134 || node.parent.kind === 143 || - node.parent.kind === 138 || - node.parent.kind === 139); + node.parent.kind === 144 || + node.parent.kind === 139 || + node.parent.kind === 140); emitType(node.constraint); } else { @@ -19505,31 +19618,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 201: + case 202: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 202: + case 203: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 139: + case 140: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 138: + case 139: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 135: case 134: - case 133: if (node.parent.flags & 128) { 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 === 201) { + else if (node.parent.parent.kind === 202) { 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 200: + case 201: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -19554,12 +19667,12 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - if (ts.isSupportedHeritageClauseElement(node)) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 201) { + if (node.parent.parent.kind === 202) { 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; @@ -19636,16 +19749,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 198 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 199 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 132 || node.kind === 131) && ts.hasQuestionToken(node)) { + if ((node.kind === 133 || node.kind === 132) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 132 || node.kind === 131) && node.parent.kind === 145) { + if ((node.kind === 133 || node.kind === 132) && node.parent.kind === 146) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -19654,14 +19767,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 198) { + if (node.kind === 199) { 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 === 132 || node.kind === 131) { + else if (node.kind === 133 || node.kind === 132) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -19669,7 +19782,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 === 201) { + else if (node.parent.kind === 202) { 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 : @@ -19695,7 +19808,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 175) { + if (element.kind !== 176) { elements.push(element); } } @@ -19761,7 +19874,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 136 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 137 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -19774,7 +19887,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 136 + return accessor.kind === 137 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -19783,7 +19896,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 137) { + if (accessorWithTypeAnnotation.kind === 138) { if (accessorWithTypeAnnotation.parent.flags & 128) { 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 : @@ -19829,17 +19942,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 200) { + if (node.kind === 201) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 134) { + else if (node.kind === 135) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 200) { + if (node.kind === 201) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 135) { + else if (node.kind === 136) { write("constructor"); } else { @@ -19856,11 +19969,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 139 || node.kind === 143) { + if (node.kind === 140 || node.kind === 144) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 140) { + if (node.kind === 141) { write("["); } else { @@ -19869,20 +19982,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 140) { + if (node.kind === 141) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 142 || node.kind === 143; - if (isFunctionTypeOrConstructorType || node.parent.kind === 145) { + var isFunctionTypeOrConstructorType = node.kind === 143 || node.kind === 144; + if (isFunctionTypeOrConstructorType || node.parent.kind === 146) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 135 && !(node.flags & 32)) { + else if (node.kind !== 136 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -19893,23 +20006,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 139: + case 140: 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 138: + case 139: 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 140: + case 141: 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 135: case 134: - case 133: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -19917,7 +20030,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 === 201) { + else if (node.parent.kind === 202) { 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 : @@ -19930,7 +20043,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 200: + case 201: 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 : @@ -19962,9 +20075,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 142 || - node.parent.kind === 143 || - node.parent.parent.kind === 145) { + if (node.parent.kind === 143 || + node.parent.kind === 144 || + node.parent.parent.kind === 146) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -19980,22 +20093,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 135: + case 136: 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 139: + case 140: 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 138: + case 139: 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 135: case 134: - case 133: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -20003,7 +20116,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 === 201) { + else if (node.parent.parent.kind === 202) { 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 : @@ -20015,7 +20128,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 200: + case 201: 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 : @@ -20026,12 +20139,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 150) { + if (bindingPattern.kind === 151) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 151) { + else if (bindingPattern.kind === 152) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -20050,10 +20163,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 175) { + if (bindingElement.kind === 176) { write(" "); } - else if (bindingElement.kind === 152) { + else if (bindingElement.kind === 153) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -20076,39 +20189,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 200: - case 205: - case 208: - case 202: case 201: - case 203: - case 204: - return emitModuleElement(node, isModuleElementVisible(node)); - case 180: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 206: case 209: + case 203: + case 202: + case 204: + case 205: + return emitModuleElement(node, isModuleElementVisible(node)); + case 181: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 210: return emitModuleElement(node, !node.importClause); - case 215: + case 216: return emitExportDeclaration(node); + case 136: case 135: case 134: - case 133: return writeFunctionDeclaration(node); - case 139: - case 138: case 140: + case 139: + case 141: return emitSignatureDeclarationWithJsDocComments(node); - case 136: case 137: + case 138: return emitAccessorDeclaration(node); + case 133: case 132: - case 131: return emitPropertyDeclaration(node); - case 226: - return emitEnumMemberDeclaration(node); - case 214: - return emitExportAssignment(node); case 227: + return emitEnumMemberDeclaration(node); + case 215: + return emitExportAssignment(node); + case 228: return emitSourceFile(node); } } @@ -20154,13 +20267,13 @@ var ts; } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; - var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\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 compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; - var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { @@ -20215,6 +20328,7 @@ var ts; var increaseIndent = writer.increaseIndent; var decreaseIndent = writer.decreaseIndent; var currentSourceFile; + var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; var blockScopedVariableToGeneratedName; @@ -20239,7 +20353,7 @@ var ts; var scopeEmitStart = function (scopeDeclaration, scopeName) { }; var scopeEmitEnd = function () { }; var sourceMapData; - if (compilerOptions.sourceMap) { + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } if (root) { @@ -20257,6 +20371,7 @@ var ts; return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; + exportFunctionForFile = undefined; emit(sourceFile); } function isUniqueName(name) { @@ -20333,25 +20448,25 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 200: case 201: - case 174: + case 202: + case 175: generateNameForFunctionOrClassDeclaration(node); break; - case 205: + case 206: generateNameForModuleOrEnum(node); generateNameForNode(node.body); break; - case 204: + case 205: generateNameForModuleOrEnum(node); break; - case 209: + case 210: generateNameForImportDeclaration(node); break; - case 215: + case 216: generateNameForExportDeclaration(node); break; - case 214: + case 215: generateNameForExportAssignment(node); break; } @@ -20369,7 +20484,7 @@ var ts; var sourceMapNameIndexMap = {}; var sourceMapNameIndices = []; function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; } var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan = { @@ -20477,6 +20592,12 @@ var ts; sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } } function recordScopeNameOfNode(node, scopeName) { function recordScopeNameIndex(scopeNameIndex) { @@ -20488,7 +20609,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_17 = node.name; - if (!name_17 || name_17.kind !== 127) { + if (!name_17 || name_17.kind !== 128) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -20505,18 +20626,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 200 || - node.kind === 162 || + else if (node.kind === 201 || + node.kind === 163 || + node.kind === 135 || node.kind === 134 || - node.kind === 133 || - node.kind === 136 || node.kind === 137 || - node.kind === 205 || - node.kind === 201 || - node.kind === 204) { + node.kind === 138 || + node.kind === 206 || + node.kind === 202 || + node.kind === 205) { if (node.name) { var name_18 = node.name; - scopeName = name_18.kind === 127 + scopeName = name_18.kind === 128 ? ts.getTextOfNode(name_18) : node.name.text; } @@ -20535,18 +20656,22 @@ var ts; ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { if (typeof JSON !== "undefined") { - return JSON.stringify({ + var map_1 = { version: version, file: file, sourceRoot: sourceRoot, sources: sources, names: names, mappings: mappings - }); + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; function serializeStringArray(list) { var output = ""; for (var i = 0, n = list.length; i < n; i++) { @@ -20560,9 +20685,18 @@ var ts; } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); sourceMapDataList.push(sourceMapData); - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); } var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); sourceMapData = { @@ -20574,6 +20708,7 @@ var ts; inputSourceFileNames: [], sourceMapNames: [], sourceMapMappings: "", + sourceMapSourcesContent: undefined, sourceMapDecodedMappings: [] }; sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); @@ -20601,7 +20736,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 227) { + if (node.kind != 228) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); @@ -20774,7 +20909,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if (compilerOptions.sourceMap && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -20846,10 +20981,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 171) { + if (node.template.kind === 172) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 169 + var needsParens = templateSpan.expression.kind === 170 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -20873,7 +21008,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 161 + var needsParens = templateSpan.expression.kind !== 162 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -20906,11 +21041,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 157: case 158: - return parent.expression === template; case 159: - case 161: + return parent.expression === template; + case 160: + case 162: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -20918,7 +21053,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 169: + case 170: switch (expression.operatorToken.kind) { case 35: case 36: @@ -20930,8 +21065,8 @@ var ts; default: return -1; } - case 172: - case 170: + case 173: + case 171: return -1; default: return 1; @@ -20943,11 +21078,11 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 152); + ts.Debug.assert(node.kind !== 153); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 127) { + else if (node.kind === 128) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -20978,36 +21113,36 @@ var ts; function isNotExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 129: - case 198: - case 152: + case 130: + case 199: + case 153: + case 133: case 132: - case 131: - case 224: case 225: case 226: + case 227: + case 135: case 134: - case 133: - case 200: - case 136: - case 137: - case 162: case 201: + case 137: + case 138: + case 163: case 202: - case 204: + case 203: case 205: - case 208: - case 210: + case 206: + case 209: case 211: + case 212: return parent.name === node; - case 213: - case 217: - return parent.name === node || parent.propertyName === node; - case 190: - case 189: case 214: + case 218: + return parent.name === node || parent.propertyName === node; + case 191: + case 190: + case 215: return false; - case 194: + case 195: return node.parent.label === node; } } @@ -21115,11 +21250,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: - case 153: - case 155: + case 154: case 156: case 157: - case 161: + case 158: + case 162: return false; } return true; @@ -21136,14 +21271,14 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 173) { + if (e.kind === 174) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < length && elements[i].kind !== 173) { + while (i < length && elements[i].kind !== 174) { i++; } write("["); @@ -21164,7 +21299,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 173; + return node.kind === 174; } function emitArrayLiteral(node) { var elements = node.elements; @@ -21225,7 +21360,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 136 || property.kind === 137) { + if (property.kind === 137 || property.kind === 138) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -21276,13 +21411,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 224) { + if (property.kind === 225) { emit(property.initializer); } - else if (property.kind === 225) { + else if (property.kind === 226) { emitExpressionIdentifier(property.name); } - else if (property.kind === 134) { + else if (property.kind === 135) { emitFunctionDeclaration(property); } else { @@ -21314,7 +21449,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 === 127) { + if (properties[i].name.kind === 128) { numInitialNonComputedProperties = i; break; } @@ -21328,30 +21463,30 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(169, startsOnNewLine); + var result = ts.createSynthesizedNode(170, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(155); + var result = ts.createSynthesizedNode(156); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(156); + var result = ts.createSynthesizedNode(157); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 158 && expr.kind !== 7) { + if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(161); + var node = ts.createSynthesizedNode(162); node.expression = expr; return node; } @@ -21400,7 +21535,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 155 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 156 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -21448,10 +21583,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 173; }); + return ts.forEach(elements, function (e) { return e.kind === 174; }); } function skipParentheses(node) { - while (node.kind === 161 || node.kind === 160) { + while (node.kind === 162 || node.kind === 161) { node = node.expression; } return node; @@ -21472,12 +21607,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 155) { + if (expr.kind === 156) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 156) { + else if (expr.kind === 157) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -21518,7 +21653,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 155 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 156 && node.expression.expression.kind === 91; } if (superCall && languageVersion < 2) { write(".call("); @@ -21555,20 +21690,20 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 163) { - if (node.expression.kind === 160) { + if (!node.parent || node.parent.kind !== 164) { + if (node.expression.kind === 161) { var operand = node.expression.expression; - while (operand.kind == 160) { + while (operand.kind == 161) { operand = operand.expression; } - if (operand.kind !== 167 && + if (operand.kind !== 168 && + operand.kind !== 167 && operand.kind !== 166 && operand.kind !== 165 && - operand.kind !== 164 && - operand.kind !== 168 && - operand.kind !== 158 && - !(operand.kind === 157 && node.parent.kind === 158) && - !(operand.kind === 162 && node.parent.kind === 157)) { + operand.kind !== 169 && + operand.kind !== 159 && + !(operand.kind === 158 && node.parent.kind === 159) && + !(operand.kind === 163 && node.parent.kind === 158)) { emit(operand); return; } @@ -21593,9 +21728,25 @@ var ts; write(" "); emit(node.expression); } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 || node.parent.kind === 153); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 167) { + if (node.operand.kind === 168) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -21605,23 +21756,73 @@ var ts; } } emit(node.operand); + if (exportChanged) { + write(")"); + } } function emitPostfixUnaryExpression(node) { - emit(node.operand); - write(ts.tokenToString(node.operator)); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 38) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 228) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 207) { + return false; + } + else { + current = current.parent; + } + } } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 154 || node.left.kind === 153)) { - emitDestructuring(node, node.parent.kind === 182); + (node.left.kind === 155 || node.left.kind === 154)) { + emitDestructuring(node, node.parent.kind === 183); } else { + var exportChanged = node.operatorToken.kind >= 53 && + node.operatorToken.kind <= 64 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } emit(node.left); var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (exportChanged) { + write(")"); + } } } function synthesizedNodeStartsOnNewLine(node) { @@ -21649,7 +21850,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 179) { + if (node && node.kind === 180) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -21664,12 +21865,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 206) { - ts.Debug.assert(node.parent.kind === 205); + if (node.kind === 207) { + ts.Debug.assert(node.parent.kind === 206); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 206) { + if (node.kind === 207) { emitTempDeclarations(true); } decreaseIndent(); @@ -21678,7 +21879,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 179) { + if (node.kind === 180) { write(" "); emit(node); } @@ -21690,7 +21891,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 163); + emitParenthesizedIf(node.expression, node.expression.kind === 164); write(";"); } function emitIfStatement(node) { @@ -21703,7 +21904,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 183) { + if (node.elseStatement.kind === 184) { write(" "); emit(node.elseStatement); } @@ -21715,7 +21916,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 179) { + if (node.statement.kind === 180) { write(" "); } else { @@ -21731,7 +21932,10 @@ var ts; write(")"); emitEmbeddedStatement(node.statement); } - function emitStartOfVariableDeclarationList(decl, startPos) { + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } var tokenKind = 98; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { @@ -21743,28 +21947,53 @@ var ts; } if (startPos !== undefined) { emitToken(tokenKind, startPos); + write(" "); } else { switch (tokenKind) { case 98: - return write("var "); + write("var "); + break; case 104: - return write("let "); + write("let "); + break; case 70: - return write("const "); + write("const "); + break; } } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; } function emitForStatement(node) { var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 199) { + if (node.initializer && node.initializer.kind === 200) { var variableDeclarationList = node.initializer; - var declarations = variableDeclarationList.declarations; - emitStartOfVariableDeclarationList(declarations[0], endPos); - write(" "); - emitCommaList(declarations); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } } else if (node.initializer) { emit(node.initializer); @@ -21777,25 +22006,23 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 188) { + if (languageVersion < 2 && node.kind === 189) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - emitStartOfVariableDeclarationList(decl, endPos); - write(" "); - emit(decl); + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 187) { + if (node.kind === 188) { write(" in "); } else { @@ -21863,7 +22090,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -21885,7 +22112,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 153 || node.initializer.kind === 154) { + if (node.initializer.kind === 154 || node.initializer.kind === 155) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -21894,7 +22121,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 179) { + if (node.statement.kind === 180) { emitLines(node.statement.statements); } else { @@ -21906,7 +22133,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 190 ? 66 : 71, node.pos); + emitToken(node.kind === 191 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } @@ -21951,7 +22178,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 220) { + if (node.kind === 221) { write("case "); emit(node.expression); write(":"); @@ -22006,7 +22233,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 205); + } while (node && node.kind !== 206); return node; } function emitContainingModuleName(node) { @@ -22021,7 +22248,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2) { + else if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } } @@ -22031,7 +22258,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(166); + var result = ts.createSynthesizedNode(167); result.expression = zero; return result; } @@ -22039,19 +22266,33 @@ var ts; if (node.flags & 1) { writeLine(); emitStart(node); - if (node.flags & 256) { - if (languageVersion === 0) { - write("exports[\"default\"]"); + if (compilerOptions.module === 4) { + write(exportFunctionForFile + "(\""); + if (node.flags & 256) { + write("default"); } else { - write("exports.default"); + emitNodeWithoutSourceMap(node.name); } + write("\", "); + emitDeclarationName(node); + write(")"); } else { - emitModuleMemberName(node); + if (node.flags & 256) { + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); } - write(" = "); - emitDeclarationName(node); emitEnd(node); write(";"); } @@ -22061,21 +22302,40 @@ var ts; for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); + if (compilerOptions.module === 4) { + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(specifier.name); + write("\", "); + emitExpressionIdentifier(name); + write(")"); + emitEnd(specifier.name); + } + else { + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + } write(";"); } } } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; - var isDeclaration = (root.kind === 198 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 129; - if (root.kind === 169) { + var canDefineTempVariablesInPlace = false; + if (root.kind === 199) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 130) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 170) { emitAssignmentExpression(root); } else { @@ -22087,7 +22347,14 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 198 || name.parent.kind === 152)) { + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 || name.parent.kind === 153); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(name); + write("\", "); + } + if (isVariableDeclarationOrBindingElement) { emitModuleMemberName(name.parent); } else { @@ -22095,11 +22362,14 @@ var ts; } write(" = "); emit(value); + if (exportChanged) { + write(")"); + } } function ensureIdentifier(expr) { if (expr.kind !== 65) { var identifier = createTempVariable(0); - if (!isDeclaration) { + if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -22109,14 +22379,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(169); + var equals = ts.createSynthesizedNode(170); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(170); + var cond = ts.createSynthesizedNode(171); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -22136,7 +22406,7 @@ var ts; return createPropertyAccessExpression(object, propName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(157); + var call = ts.createSynthesizedNode(158); var sliceIdentifier = ts.createSynthesizedNode(65); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -22151,7 +22421,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 224 || p.kind === 225) { + if (p.kind === 225 || p.kind === 226) { var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -22164,8 +22434,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175) { - if (e.kind !== 173) { + if (e.kind !== 176) { + if (e.kind !== 174) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -22175,14 +22445,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 169 && target.operatorToken.kind === 53) { + if (target.kind === 170 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 154) { + if (target.kind === 155) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 153) { + else if (target.kind === 154) { emitArrayLiteralAssignment(target, value); } else { @@ -22196,14 +22466,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 161) { + if (root.parent.kind !== 162) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 161) { + if (root.parent.kind !== 162) { write(")"); } } @@ -22223,11 +22493,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 150) { + if (pattern.kind === 151) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 175) { + else if (element.kind !== 176) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -22254,22 +22524,31 @@ var ts; } else { renameNonTopLevelLetAndConst(node.name); - emitModuleMemberName(node); var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 187 && - node.parent.parent.kind !== 188) { + node.parent.parent.kind !== 188 && + node.parent.parent.kind !== 189) { initializer = createVoidZero(); } } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } } } function emitExportVariableAssignments(node) { - if (node.kind === 175) { + if (node.kind === 176) { return; } var name = node.name; @@ -22281,7 +22560,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 198 && node.parent.kind !== 152)) { + if (!node.parent || (node.parent.kind !== 199 && node.parent.kind !== 153)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -22290,24 +22569,24 @@ var ts; if (languageVersion >= 2 || ts.nodeIsSynthesized(node) || node.kind !== 65 || - (node.parent.kind !== 198 && node.parent.kind !== 152)) { + (node.parent.kind !== 199 && node.parent.kind !== 153)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { return; } - var list = ts.getAncestor(node, 199); - if (list.parent.kind === 180) { - var isSourceFileLevelBinding = list.parent.parent.kind === 227; - var isModuleLevelBinding = list.parent.parent.kind === 206; - var isFunctionLevelBinding = list.parent.parent.kind === 179 && ts.isFunctionLike(list.parent.parent.parent); + var list = ts.getAncestor(node, 200); + if (list.parent.kind === 181) { + var isSourceFileLevelBinding = list.parent.parent.kind === 228; + var isModuleLevelBinding = list.parent.parent.kind === 207; + var isFunctionLevelBinding = list.parent.parent.kind === 180 && ts.isFunctionLike(list.parent.parent.parent); if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { return; } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 227 + var parent = blockScopeContainer.kind === 228 ? blockScopeContainer : blockScopeContainer.parent; if (resolver.resolvesToSomeValue(parent, node.text)) { @@ -22322,18 +22601,27 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 227; + node.parent.kind === 228; } function emitVariableStatement(node) { + var startIsEmitted = true; if (!(node.flags & 1)) { - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); } else if (isES6ExportedDeclaration(node)) { write("export "); - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } } - emitCommaList(node.declarationList.declarations); - write(";"); if (languageVersion < 2 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } @@ -22434,12 +22722,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 136 ? "get " : "set "); + write(node.kind === 137 ? "get " : "set "); emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 163 && languageVersion >= 2; + return node.kind === 164 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -22450,10 +22738,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 162) { + if (node.kind === 163) { return !!node.name; } - if (node.kind === 200) { + if (node.kind === 201) { return !!node.name || languageVersion < 2; } } @@ -22461,7 +22749,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 134 && node.kind !== 133) { + if (node.kind !== 135 && node.kind !== 134) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { @@ -22481,10 +22769,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 200 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 201 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 134 && node.kind !== 133) { + if (node.kind !== 135 && node.kind !== 134) { emitTrailingComments(node); } } @@ -22531,7 +22819,7 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 179) { + else if (node.body.kind === 180) { emitBlockFunctionBody(node, node.body); } else { @@ -22556,10 +22844,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 160) { + while (current.kind === 161) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 154); + emitParenthesizedIf(body, current.kind === 155); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -22631,9 +22919,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 182) { + if (statement && statement.kind === 183) { var expr = statement.expression; - if (expr && expr.kind === 157) { + if (expr && expr.kind === 158) { var func = expr.expression; if (func && func.kind === 91) { return statement; @@ -22664,7 +22952,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 127) { + else if (memberName.kind === 128) { emitComputedPropertyName(memberName); } else { @@ -22672,11 +22960,11 @@ var ts; emitNodeWithoutSourceMap(memberName); } } - function getInitializedProperties(node, static) { + function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 132 && static === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -22716,11 +23004,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 178) { + if (member.kind === 179) { writeLine(); write(";"); } - else if (member.kind === 134 || node.kind === 133) { + else if (member.kind === 135 || node.kind === 134) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -22739,7 +23027,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 136 || member.kind === 137) { + else if (member.kind === 137 || member.kind === 138) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -22789,22 +23077,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 134 || node.kind === 133) && !member.body) { + if ((member.kind === 135 || node.kind === 134) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 134 || - member.kind === 136 || - member.kind === 137) { + else if (member.kind === 135 || + member.kind === 137 || + member.kind === 138) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 136) { + if (member.kind === 137) { write("get "); } - else if (member.kind === 137) { + else if (member.kind === 138) { write("set "); } if (member.asteriskToken) { @@ -22815,7 +23103,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 178) { + else if (member.kind === 179) { writeLine(); write(";"); } @@ -22836,10 +23124,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 135 && !member.body) { + if (member.kind === 136 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 132 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 133 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -22939,7 +23227,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 201) { + if (node.kind === 202) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { write("export "); @@ -22956,7 +23244,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 174; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -22987,15 +23275,6 @@ var ts; scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } } if (isClassExpressionWithStaticProperties) { for (var _a = 0; _a < staticProperties.length; _a++) { @@ -23032,8 +23311,10 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 201) { - write("var "); + if (node.kind === 202) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } emitDeclarationName(node); write(" = "); } @@ -23088,11 +23369,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 201) { + if (node.kind === 202) { write(";"); } emitEnd(node); - if (node.kind === 201) { + if (node.kind === 202) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -23166,13 +23447,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 134) { + if (member.kind === 135) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 132) { + if (member.kind !== 133) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -23202,7 +23483,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 132) { + if (member.kind !== 133) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -23241,26 +23522,26 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 134: - case 136: + case 135: case 137: - case 132: + case 138: + case 133: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 134: + case 135: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 201: - case 134: - case 137: + case 202: + case 135: + case 138: return true; } return false; @@ -23420,7 +23701,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 205) { + if (moduleDeclaration.body.kind === 206) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -23436,7 +23717,9 @@ var ts; if (!shouldEmit) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (!isModuleMergedWithES6Class(node)) { + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -23453,7 +23736,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 206) { + if (node.body.kind === 207) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -23486,6 +23769,14 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -23502,16 +23793,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 208) { + if (node.kind === 209) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 211) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 209 && node.importClause && !!node.importClause.name; + return node.kind === 210 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -23538,7 +23829,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 211) { + if (node.importClause.namedBindings.kind === 212) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -23564,7 +23855,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 208 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 209 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -23576,7 +23867,7 @@ var ts; write(" = "); } else { - var isNakedImport = 209 && !node.importClause; + var isNakedImport = 210 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -23639,6 +23930,7 @@ var ts; } } function emitExportDeclaration(node) { + ts.Debug.assert(compilerOptions.module !== 4); if (languageVersion < 2) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); @@ -23731,8 +24023,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 200 && - expression.kind !== 201) { + if (expression.kind !== 201 && + expression.kind !== 202) { write(";"); } emitEnd(node); @@ -23740,14 +24032,21 @@ var ts; else { writeLine(); emitStart(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); + if (compilerOptions.module === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); } else { - write(".default = "); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); } - emit(node.expression); write(";"); emitEnd(node); } @@ -23761,18 +24060,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 209: + case 210: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 208: - if (node.moduleReference.kind === 219 && resolver.isReferencedAliasDeclaration(node)) { + case 209: + if (node.moduleReference.kind === 220 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 215: + case 216: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -23790,7 +24089,7 @@ var ts; } } break; - case 214: + case 215: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -23810,6 +24109,375 @@ var ts; write("}"); } } + function getLocalNameForExternalImport(importNode) { + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + else { + return getGeneratedNameForNode(importNode); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 8) { + return getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 216 || + (importNode.kind === 210 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 216 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 216) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") " + exportFunctionForFile + "(n, m[n]);"); + decreaseIndent(); + writeLine(); + write("}"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 65 && node.flags & 256) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 65) { + emitNodeWithoutSourceMap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + if (i !== 0) { + write(", "); + } + if (local.kind === 202 || local.kind === 206) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 65 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.kind === 201) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 202) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 206 && shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 199 || node.kind === 153) { + if (shouldHoistVariable(node, false)) { + var name_21 = node.name; + if (name_21.kind === 65) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_21); + } + else { + ts.forEachChild(name_21, visit); + } + } + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 12288) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 228; + } + function isCurrentFileSystemExternalModule() { + return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction); + writeLine(); + emitExecute(node, startIndex); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSetters(exportStarFunction) { + write("setters:["); + for (var i = 0; i < externalImports.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var importNode = externalImports[i]; + var importVariableName = getLocalNameForExternalImport(importNode) || ""; + var parameterName = "_" + importVariableName; + write("function (" + parameterName + ") {"); + switch (importNode.kind) { + case 210: + if (!importNode.importClause) { + break; + } + case 209: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + var defaultName = importNode.kind === 210 + ? importNode.importClause.name + : importNode.name; + if (defaultName) { + emitExportMemberAssignments(defaultName); + writeLine(); + } + if (importNode.kind === 210 && + importNode.importClause.namedBindings) { + var namedBindings = importNode.importClause.namedBindings; + if (namedBindings.kind === 212) { + emitExportMemberAssignments(namedBindings.name); + writeLine(); + } + else { + for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportMemberAssignments(element.name || element.propertyName); + writeLine(); + } + } + } + decreaseIndent(); + break; + case 216: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + if (importNode.exportClause) { + for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + writeLine(); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(e.name); + write("\", " + parameterName + "[\""); + emitNodeWithoutSourceMap(e.propertyName || e.name); + write("\"]);"); + } + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + decreaseIndent(); + break; + } + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 216: + case 210: + case 209: + case 201: + continue; + } + writeLine(); + emit(statement); + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node, startIndex) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + write("System.register(["); + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } function emitAMDDependencies(node, includeNonAmdDependencies) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); @@ -23837,19 +24505,8 @@ var ts; } for (var _c = 0; _c < externalImports.length; _c++) { var importNode = externalImports[_c]; - var externalModuleName = ""; - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - externalModuleName = getLiteralText(moduleName); - } - var importAliasName = void 0; - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { - importAliasName = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - else { - importAliasName = getGeneratedNameForNode(importNode); - } + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); @@ -23962,28 +24619,33 @@ var ts; writeLine(); emitDetachedComments(node); var startIndex = emitDirectivePrologues(node.statements, false); - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024) { + writeLines(paramHelper); + paramEmitted = true; } - decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024) { - writeLines(paramHelper); - paramEmitted = true; - } - if (ts.isExternalModule(node)) { + if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { if (languageVersion >= 2) { emitES6Module(node, startIndex); } else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 4) { + emitSystemModule(node, startIndex); + } else if (compilerOptions.module === 3) { emitUMDModule(node, startIndex); } @@ -24020,21 +24682,21 @@ var ts; } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 202: - case 200: - case 209: - case 208: case 203: - case 214: - return false; - case 205: - return shouldEmitModuleDeclaration(node); + case 201: + case 210: + case 209: case 204: + case 215: + return false; + case 206: + return shouldEmitModuleDeclaration(node); + case 205: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 179 && + if (node.kind !== 180 && node.parent && - node.parent.kind === 163 && + node.parent.kind === 164 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -24046,13 +24708,13 @@ var ts; switch (node.kind) { case 65: return emitIdentifier(node, allowGeneratedIdentifiers); - case 129: + case 130: return emitParameter(node); + case 135: case 134: - case 133: return emitMethod(node); - case 136: case 137: + case 138: return emitAccessor(node); case 93: return emitThis(node); @@ -24072,139 +24734,139 @@ var ts; case 12: case 13: return emitLiteral(node); - case 171: - return emitTemplateExpression(node); - case 176: - return emitTemplateSpan(node); - case 126: - return emitQualifiedName(node); - case 150: - return emitObjectBindingPattern(node); - case 151: - return emitArrayBindingPattern(node); - case 152: - return emitBindingElement(node); - case 153: - return emitArrayLiteral(node); - case 154: - return emitObjectLiteral(node); - case 224: - return emitPropertyAssignment(node); - case 225: - return emitShorthandPropertyAssignment(node); - case 127: - return emitComputedPropertyName(node); - case 155: - return emitPropertyAccess(node); - case 156: - return emitIndexedAccess(node); - case 157: - return emitCallExpression(node); - case 158: - return emitNewExpression(node); - case 159: - return emitTaggedTemplateExpression(node); - case 160: - return emit(node.expression); - case 161: - return emitParenExpression(node); - case 200: - case 162: - case 163: - return emitFunctionDeclaration(node); - case 164: - return emitDeleteExpression(node); - case 165: - return emitTypeOfExpression(node); - case 166: - return emitVoidExpression(node); - case 167: - return emitPrefixUnaryExpression(node); - case 168: - return emitPostfixUnaryExpression(node); - case 169: - return emitBinaryExpression(node); - case 170: - return emitConditionalExpression(node); - case 173: - return emitSpreadElementExpression(node); case 172: - return emitYieldExpression(node); - case 175: - return; - case 179: - case 206: - return emitBlock(node); - case 180: - return emitVariableStatement(node); - case 181: - return write(";"); - case 182: - return emitExpressionStatement(node); - case 183: - return emitIfStatement(node); - case 184: - return emitDoStatement(node); - case 185: - return emitWhileStatement(node); - case 186: - return emitForStatement(node); - case 188: - case 187: - return emitForInOrForOfStatement(node); - case 189: - case 190: - return emitBreakOrContinueStatement(node); - case 191: - return emitReturnStatement(node); - case 192: - return emitWithStatement(node); - case 193: - return emitSwitchStatement(node); - case 220: - case 221: - return emitCaseOrDefaultClause(node); - case 194: - return emitLabelledStatement(node); - case 195: - return emitThrowStatement(node); - case 196: - return emitTryStatement(node); - case 223: - return emitCatchClause(node); - case 197: - return emitDebuggerStatement(node); - case 198: - return emitVariableDeclaration(node); - case 174: - return emitClassExpression(node); - case 201: - return emitClassDeclaration(node); - case 202: - return emitInterfaceDeclaration(node); - case 204: - return emitEnumDeclaration(node); + return emitTemplateExpression(node); + case 178: + return emitTemplateSpan(node); + case 127: + return emitQualifiedName(node); + case 151: + return emitObjectBindingPattern(node); + case 152: + return emitArrayBindingPattern(node); + case 153: + return emitBindingElement(node); + case 154: + return emitArrayLiteral(node); + case 155: + return emitObjectLiteral(node); + case 225: + return emitPropertyAssignment(node); case 226: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 128: + return emitComputedPropertyName(node); + case 156: + return emitPropertyAccess(node); + case 157: + return emitIndexedAccess(node); + case 158: + return emitCallExpression(node); + case 159: + return emitNewExpression(node); + case 160: + return emitTaggedTemplateExpression(node); + case 161: + return emit(node.expression); + case 162: + return emitParenExpression(node); + case 201: + case 163: + case 164: + return emitFunctionDeclaration(node); + case 165: + return emitDeleteExpression(node); + case 166: + return emitTypeOfExpression(node); + case 167: + return emitVoidExpression(node); + case 168: + return emitPrefixUnaryExpression(node); + case 169: + return emitPostfixUnaryExpression(node); + case 170: + return emitBinaryExpression(node); + case 171: + return emitConditionalExpression(node); + case 174: + return emitSpreadElementExpression(node); + case 173: + return emitYieldExpression(node); + case 176: + return; + case 180: + case 207: + return emitBlock(node); + case 181: + return emitVariableStatement(node); + case 182: + return write(";"); + case 183: + return emitExpressionStatement(node); + case 184: + return emitIfStatement(node); + case 185: + return emitDoStatement(node); + case 186: + return emitWhileStatement(node); + case 187: + return emitForStatement(node); + case 189: + case 188: + return emitForInOrForOfStatement(node); + case 190: + case 191: + return emitBreakOrContinueStatement(node); + case 192: + return emitReturnStatement(node); + case 193: + return emitWithStatement(node); + case 194: + return emitSwitchStatement(node); + case 221: + case 222: + return emitCaseOrDefaultClause(node); + case 195: + return emitLabelledStatement(node); + case 196: + return emitThrowStatement(node); + case 197: + return emitTryStatement(node); + case 224: + return emitCatchClause(node); + case 198: + return emitDebuggerStatement(node); + case 199: + return emitVariableDeclaration(node); + case 175: + return emitClassExpression(node); + case 202: + return emitClassDeclaration(node); + case 203: + return emitInterfaceDeclaration(node); case 205: - return emitModuleDeclaration(node); - case 209: - return emitImportDeclaration(node); - case 208: - return emitImportEqualsDeclaration(node); - case 215: - return emitExportDeclaration(node); - case 214: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 227: + return emitEnumMember(node); + case 206: + return emitModuleDeclaration(node); + case 210: + return emitImportDeclaration(node); + case 209: + return emitImportEqualsDeclaration(node); + case 216: + return emitExportDeclaration(node); + case 215: + return emitExportAssignment(node); + case 228: return emitSourceFileNode(node); } } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -24224,7 +24886,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 227 || node.pos !== node.parent.pos) { + if (node.parent.kind === 228 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -24236,7 +24898,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 227 || node.end !== node.parent.end) { + if (node.parent.kind === 228 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -24285,12 +24947,12 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); } @@ -24331,6 +24993,8 @@ var ts; ts.ioReadTime = 0; ts.ioWriteTime = 0; ts.version = "1.5.0"; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -24401,6 +25065,9 @@ var ts; } } } + var newLine = options.newLine === 0 ? carriageReturnLineFeed : + options.newLine === 1 ? lineFeed : + ts.sys.newLine; return { getSourceFile: getSourceFile, getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, @@ -24408,14 +25075,14 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return ts.sys.newLine; } + getNewLine: function () { return newLine; } }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program) { - var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + function getPreEmitDiagnostics(program, sourceFile) { + var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics()); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -24653,7 +25320,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 209 || node.kind === 208 || node.kind === 215) { + if (node.kind === 210 || node.kind === 209 || node.kind === 216) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -24673,7 +25340,7 @@ var ts; } } } - else if (node.kind === 205 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 206 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -24756,6 +25423,22 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); } } + if (options.inlineSourceMap) { + if (options.sourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.mapRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.sourceRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { if (options.mapRoot) { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option)); @@ -24774,15 +25457,15 @@ var ts; var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } if (options.module && languageVersion >= 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } if (options.outDir || options.sourceRoot || @@ -24841,6 +25524,14 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "inlineSourceMap", + type: "boolean" + }, + { + name: "inlineSources", + type: "boolean" + }, { name: "listFiles", type: "boolean" @@ -24862,17 +25553,32 @@ var ts; type: { "commonjs": 1, "amd": 2, + "system": 4, "umd": 3 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + }, + { + name: "newLine", + type: { + "crlf": 0, + "lf": 1 + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF }, { name: "noEmit", type: "boolean", description: ts.Diagnostics.Do_not_emit_outputs }, + { + name: "noEmitHelpers", + type: "boolean" + }, { name: "noEmitOnError", type: "boolean", @@ -25086,13 +25792,23 @@ var ts; function readConfigFile(fileName) { try { var text = ts.sys.readFile(fileName); - return /\S/.test(text) ? JSON.parse(text) : {}; } catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } + return parseConfigFileText(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFile(json, basePath) { + function parseConfigFileText(fileName, jsonText) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileText = parseConfigFileText; + function parseConfigFile(json, host, basePath) { var errors = []; return { options: getCompilerOptions(), @@ -25148,7 +25864,7 @@ var ts; } } else { - var sysFiles = ts.sys.readDirectory(basePath, ".ts"); + var sysFiles = host.readDirectory(basePath, ".ts"); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { @@ -25324,12 +26040,13 @@ var ts; function performCompilation() { if (!cachedProgram) { if (configFileName) { - var configObject = ts.readConfigFile(configFileName); - if (!configObject) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, configFileName)); + var result = ts.readConfigFile(configFileName); + if (result.error) { + reportDiagnostic(result.error); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } - var configParseResult = ts.parseConfigFile(configObject, ts.getDirectoryPath(configFileName)); + var configObject = result.config; + var configParseResult = ts.parseConfigFile(configObject, ts.sys, ts.getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { reportDiagnostics(configParseResult.errors); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); diff --git a/bin/tsserver.js b/bin/tsserver.js index d5b7fdd0094..1707ef70411 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -444,7 +444,7 @@ var ts; for (var _i = 0; _i < parts.length; _i++) { var part = parts[_i]; if (part !== ".") { - if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); } else { @@ -536,7 +536,7 @@ var ts; function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { directoryComponents.length--; } for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { @@ -960,7 +960,7 @@ var ts; A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, @@ -1021,8 +1021,8 @@ var ts; or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, @@ -1064,9 +1064,9 @@ var ts; The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, @@ -1075,28 +1075,27 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, + Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, @@ -1119,7 +1118,7 @@ var ts; Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, @@ -1211,15 +1210,15 @@ var ts; Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, @@ -1273,11 +1272,13 @@ var ts; Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "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}'." }, 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}'." }, @@ -1353,6 +1354,7 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, @@ -1366,6 +1368,10 @@ var ts; Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, + Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1377,7 +1383,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1398,7 +1404,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -1412,6 +1418,9 @@ var ts; Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1424,7 +1433,6 @@ var ts; 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." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, @@ -1480,7 +1488,7 @@ var ts; "false": 80, "finally": 81, "for": 82, - "from": 124, + "from": 125, "function": 83, "get": 116, "if": 84, @@ -1491,33 +1499,34 @@ var ts; "interface": 103, "let": 104, "module": 117, + "namespace": 118, "new": 88, "null": 89, - "number": 119, + "number": 120, "package": 105, "private": 106, "protected": 107, "public": 108, - "require": 118, + "require": 119, "return": 90, - "set": 120, + "set": 121, "static": 109, - "string": 121, + "string": 122, "super": 91, "switch": 92, - "symbol": 122, + "symbol": 123, "this": 93, "throw": 94, "true": 95, "try": 96, - "type": 123, + "type": 124, "typeof": 97, "var": 98, "void": 99, "while": 100, "with": 101, "yield": 110, - "of": 125, + "of": 126, "{": 14, "}": 15, "(": 16, @@ -1839,7 +1848,7 @@ var ts; } collecting = true; if (result && result.length) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } continue; case 9: @@ -1885,7 +1894,7 @@ var ts; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { if (result && result.length && isLineBreak(ch)) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } pos++; continue; @@ -2729,6 +2738,14 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "inlineSourceMap", + type: "boolean" + }, + { + name: "inlineSources", + type: "boolean" + }, { name: "listFiles", type: "boolean" @@ -2750,17 +2767,32 @@ var ts; type: { "commonjs": 1, "amd": 2, + "system": 4, "umd": 3 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + }, + { + name: "newLine", + type: { + "crlf": 0, + "lf": 1 + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF }, { name: "noEmit", type: "boolean", description: ts.Diagnostics.Do_not_emit_outputs }, + { + name: "noEmitHelpers", + type: "boolean" + }, { name: "noEmitOnError", type: "boolean", @@ -2974,13 +3006,23 @@ var ts; function readConfigFile(fileName) { try { var text = ts.sys.readFile(fileName); - return /\S/.test(text) ? JSON.parse(text) : {}; } catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } + return parseConfigFileText(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFile(json, basePath) { + function parseConfigFileText(fileName, jsonText) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileText = parseConfigFileText; + function parseConfigFile(json, host, basePath) { var errors = []; return { options: getCompilerOptions(), @@ -3036,7 +3078,7 @@ var ts; } } else { - var sysFiles = ts.sys.readDirectory(basePath, ".ts"); + var sysFiles = host.readDirectory(basePath, ".ts"); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { @@ -3112,7 +3154,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 227) { + while (node && node.kind !== 228) { node = node.parent; } return node; @@ -3201,15 +3243,15 @@ var ts; return current; } switch (current.kind) { - case 227: - case 207: - case 223: - case 205: - case 186: + case 228: + case 208: + case 224: + case 206: case 187: case 188: + case 189: return current; - case 179: + case 180: if (!isFunctionLike(current.parent)) { return current; } @@ -3220,9 +3262,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 198 && + declaration.kind === 199 && declaration.parent && - declaration.parent.kind === 223; + declaration.parent.kind === 224; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3258,22 +3300,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 227: + case 228: 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 198: - case 152: - case 201: - case 174: + case 199: + case 153: case 202: + case 175: + case 203: + case 206: case 205: - case 204: - case 226: - case 200: - case 162: + case 227: + case 201: + case 163: errorNode = node.name; break; } @@ -3295,11 +3337,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 204 && isConst(node); + return node.kind === 205 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 152 || isBindingPattern(node))) { + while (node && (node.kind === 153 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3307,14 +3349,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 198) { + if (node.kind === 199) { node = node.parent; } - if (node && node.kind === 199) { + if (node && node.kind === 200) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 180) { + if (node && node.kind === 181) { flags |= node.flags; } return flags; @@ -3329,11 +3371,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 182 && node.expression.kind === 8; + return node.kind === 183 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 129 || node.kind === 128) { + if (node.kind === 130 || node.kind === 129) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3355,23 +3397,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191: + case 192: return visitor(node); - case 207: - case 179: - case 183: + case 208: + case 180: case 184: case 185: case 186: case 187: case 188: - case 192: + case 189: case 193: - case 220: - case 221: case 194: - case 196: - case 223: + case 221: + case 222: + case 195: + case 197: + case 224: return ts.forEachChild(node, traverse); } } @@ -3380,14 +3422,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 152: - case 226: - case 129: - case 224: - case 132: - case 131: + case 153: + case 227: + case 130: case 225: - case 198: + case 133: + case 132: + case 226: + case 199: return true; } } @@ -3397,8 +3439,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 136: case 137: + case 138: return true; } } @@ -3408,22 +3450,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 135: - case 162: - case 200: - case 163: - case 134: - case 133: case 136: + case 163: + case 201: + case 164: + case 135: + case 134: case 137: case 138: case 139: case 140: - case 142: + case 141: case 143: - case 162: + case 144: case 163: - case 200: + case 164: + case 201: return true; } } @@ -3431,11 +3473,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 179 && isFunctionLike(node.parent); + return node && node.kind === 180 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 134 && node.parent.kind === 154; + return node && node.kind === 135 && node.parent.kind === 155; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3454,36 +3496,36 @@ var ts; return undefined; } switch (node.kind) { - case 127: - if (node.parent.parent.kind === 201) { + case 128: + if (node.parent.parent.kind === 202) { return node; } node = node.parent; break; - case 130: - if (node.parent.kind === 129 && isClassElement(node.parent.parent)) { + case 131: + if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 163: + case 164: if (!includeArrowFunctions) { continue; } - case 200: - case 162: - case 205: - case 132: - case 131: - case 134: + case 201: + case 163: + case 206: case 133: + case 132: case 135: + case 134: case 136: case 137: - case 204: - case 227: + case 138: + case 205: + case 228: return node; } } @@ -3495,40 +3537,40 @@ var ts; if (!node) return node; switch (node.kind) { - case 127: - if (node.parent.parent.kind === 201) { + case 128: + if (node.parent.parent.kind === 202) { return node; } node = node.parent; break; - case 130: - if (node.parent.kind === 129 && isClassElement(node.parent.parent)) { + case 131: + if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 200: - case 162: + case 201: case 163: + case 164: if (!includeFunctions) { continue; } - case 132: - case 131: - case 134: case 133: + case 132: case 135: + case 134: case 136: case 137: + case 138: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 159) { + if (node.kind === 160) { return node.tag; } return node.expression; @@ -3536,40 +3578,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 201: + case 202: return true; - case 132: - return node.parent.kind === 201; - case 129: - return node.parent.body && node.parent.parent.kind === 201; - case 136: + case 133: + return node.parent.kind === 202; + case 130: + return node.parent.body && node.parent.parent.kind === 202; case 137: - case 134: - return node.body && node.parent.kind === 201; + case 138: + case 135: + return node.body && node.parent.kind === 202; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 201: + case 202: if (node.decorators) { return true; } return false; - case 132: - case 129: + case 133: + case 130: if (node.decorators) { return true; } return false; - case 136: + case 137: if (node.body && node.decorators) { return true; } return false; - case 134: - case 137: + case 135: + case 138: if (node.body && node.decorators) { return true; } @@ -3580,10 +3622,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 201: + case 202: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 134: - case 137: + case 135: + case 138: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3601,7 +3643,6 @@ var ts; case 95: case 80: case 9: - case 153: case 154: case 155: case 156: @@ -3611,69 +3652,70 @@ var ts; case 160: case 161: case 162: - case 174: case 163: - case 166: + case 175: case 164: - case 165: case 167: + case 165: + case 166: case 168: case 169: case 170: - case 173: case 171: + case 174: + case 172: case 10: - case 175: + case 176: return true; - case 126: - while (node.parent.kind === 126) { + case 127: + while (node.parent.kind === 127) { node = node.parent; } - return node.parent.kind === 144; + return node.parent.kind === 145; case 65: - if (node.parent.kind === 144) { + if (node.parent.kind === 145) { return true; } case 7: case 8: var parent_1 = node.parent; switch (parent_1.kind) { - case 198: - case 129: + case 199: + case 130: + case 133: case 132: - case 131: - case 226: - case 224: - case 152: + case 227: + case 225: + case 153: return parent_1.initializer === node; - case 182: case 183: case 184: case 185: - case 191: + case 186: case 192: case 193: - case 220: - case 195: - case 193: + case 194: + case 221: + case 196: + case 194: return parent_1.expression === node; - case 186: + case 187: var forStatement = parent_1; - return (forStatement.initializer === node && forStatement.initializer.kind !== 199) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 200) || forStatement.condition === node || forStatement.incrementor === node; - case 187: case 188: + case 189: var forInStatement = parent_1; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 199) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200) || forInStatement.expression === node; - case 160: + case 161: return node === parent_1.expression; - case 176: + case 178: return node === parent_1.expression; - case 127: + case 128: return node === parent_1.expression; - case 130: + case 131: return true; default: if (isExpression(parent_1)) { @@ -3691,7 +3733,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 && node.moduleReference.kind === 219; + return node.kind === 209 && node.moduleReference.kind === 220; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3700,40 +3742,40 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 && node.moduleReference.kind !== 219; + return node.kind === 209 && node.moduleReference.kind !== 220; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 209) { + if (node.kind === 210) { return node.moduleSpecifier; } - if (node.kind === 208) { + if (node.kind === 209) { var reference = node.moduleReference; - if (reference.kind === 219) { + if (reference.kind === 220) { return reference.expression; } } - if (node.kind === 215) { + if (node.kind === 216) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 129 && node.dotDotDotToken !== undefined; + return node && node.kind === 130 && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 129: + case 130: return node.questionToken !== undefined; + case 135: case 134: - case 133: return node.questionToken !== undefined; + case 226: case 225: - case 224: + case 133: case 132: - case 131: return node.questionToken !== undefined; } } @@ -3741,7 +3783,7 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; + return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { @@ -3757,7 +3799,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 151 || node.kind === 150); + return !!node && (node.kind === 152 || node.kind === 151); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -3772,33 +3814,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 163: - case 152: - case 201: - case 135: - case 204: - case 226: - case 217: - case 200: - case 162: - case 136: - case 210: - case 208: - case 213: + case 164: + case 153: case 202: - case 134: - case 133: + case 136: case 205: - case 211: - case 129: - case 224: - case 132: - case 131: + case 227: + case 218: + case 201: + case 163: case 137: - case 225: + case 211: + case 209: + case 214: case 203: - case 128: - case 198: + case 135: + case 134: + case 206: + case 212: + case 130: + case 225: + case 133: + case 132: + case 138: + case 226: + case 204: + case 129: + case 199: return true; } return false; @@ -3806,25 +3848,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 190: - case 189: - case 197: - case 184: - case 182: - case 181: - case 187: - case 188: - case 186: - case 183: - case 194: case 191: - case 193: - case 94: - case 196: - case 180: + case 190: + case 198: case 185: + case 183: + case 182: + case 188: + case 189: + case 187: + case 184: + case 195: case 192: - case 214: + case 194: + case 94: + case 197: + case 181: + case 186: + case 193: + case 215: return true; default: return false; @@ -3833,13 +3875,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 135: - case 132: - case 134: case 136: - case 137: case 133: - case 140: + case 135: + case 137: + case 138: + case 134: + case 141: return true; default: return false; @@ -3851,7 +3893,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 213 || parent.kind === 217) { + if (parent.kind === 214 || parent.kind === 218) { if (parent.propertyName) { return true; } @@ -3863,12 +3905,12 @@ var ts; } ts.isDeclarationName = isDeclarationName; function isAliasSymbolDeclaration(node) { - return node.kind === 208 || - node.kind === 210 && !!node.name || - node.kind === 211 || - node.kind === 213 || - node.kind === 217 || - node.kind === 214 && node.expression.kind === 65; + return node.kind === 209 || + node.kind === 211 && !!node.name || + node.kind === 212 || + node.kind === 214 || + node.kind === 218 || + node.kind === 215 && node.expression.kind === 65; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -3951,7 +3993,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 125; + return 66 <= token && token <= 126; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -3960,19 +4002,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 127 && + declaration.name.kind === 128 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 155 && isESSymbolIdentifier(node.expression); + return node.kind === 156 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 127) { + if (name.kind === 128) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4006,7 +4048,7 @@ var ts; } ts.isModifier = isModifier; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 205 || n.kind === 227; + return isFunctionLike(n) || n.kind === 206 || n.kind === 228; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4169,7 +4211,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); } } } @@ -4230,7 +4272,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 135 && nodeIsPresent(member.body)) { + if (member.kind === 136 && nodeIsPresent(member.body)) { return member; } }); @@ -4238,8 +4280,8 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; + if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -4253,10 +4295,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 136) { + if (accessor.kind === 137) { getAccessor = accessor; } - else if (accessor.kind === 137) { + else if (accessor.kind === 138) { setAccessor = accessor; } else { @@ -4265,7 +4307,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 136 || member.kind === 137) + if ((member.kind === 137 || member.kind === 138) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4276,10 +4318,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 136 && !getAccessor) { + if (member.kind === 137 && !getAccessor) { getAccessor = member; } - if (member.kind === 137 && !setAccessor) { + if (member.kind === 138 && !setAccessor) { setAccessor = member; } } @@ -4400,22 +4442,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 155: case 156: - case 158: case 157: case 159: - case 153: - case 161: + case 158: + case 160: case 154: - case 174: case 162: + case 155: + case 175: + case 163: case 65: case 9: case 7: case 8: case 10: - case 171: + case 172: case 80: case 89: case 93: @@ -4431,30 +4473,84 @@ var ts; return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; - function isSupportedHeritageClauseElement(node) { - return isSupportedHeritageClauseElementExpression(node.expression); + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } - ts.isSupportedHeritageClauseElement = isSupportedHeritageClauseElement; - function isSupportedHeritageClauseElementExpression(node) { + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { if (node.kind === 65) { return true; } - else if (node.kind === 155) { - return isSupportedHeritageClauseElementExpression(node.expression); + else if (node.kind === 156) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { return false; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 126 && node.parent.right === node) || - (node.parent.kind === 155 && node.parent.name === node); + return (node.parent.kind === 127 && node.parent.right === node) || + (node.parent.kind === 156 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + var leadSurrogate = undefined; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; })(ts || (ts = {})); var ts; (function (ts) { @@ -4576,7 +4672,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(229); + var nodeConstructors = new Array(230); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4614,20 +4710,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 126: + case 127: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 128: + case 129: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 129: + case 130: + case 133: case 132: - case 131: - case 224: case 225: - case 198: - case 152: + case 226: + case 199: + case 153: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -4636,24 +4732,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 142: case 143: - case 138: + case 144: case 139: case 140: + case 141: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 134: - case 133: case 135: + case 134: case 136: case 137: - case 162: - case 200: + case 138: case 163: + case 201: + case 164: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -4664,151 +4760,144 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 141: + case 142: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 144: - return visitNode(cbNode, node.exprName); case 145: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 146: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 147: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 148: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 149: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 150: + return visitNode(cbNode, node.type); case 151: - return visitNodes(cbNodes, node.elements); - case 153: + case 152: return visitNodes(cbNodes, node.elements); case 154: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 155: + return visitNodes(cbNodes, node.properties); + case 156: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 156: + case 157: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 157: case 158: + case 159: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 159: + case 160: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 160: + case 161: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 161: - return visitNode(cbNode, node.expression); - case 164: + case 162: return visitNode(cbNode, node.expression); case 165: return visitNode(cbNode, node.expression); case 166: return visitNode(cbNode, node.expression); case 167: - return visitNode(cbNode, node.operand); - case 172: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression); case 168: return visitNode(cbNode, node.operand); + case 173: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); case 169: + return visitNode(cbNode, node.operand); + case 170: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 170: + case 171: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 173: + case 174: return visitNode(cbNode, node.expression); - case 179: - case 206: + case 180: + case 207: return visitNodes(cbNodes, node.statements); - case 227: + case 228: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 180: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 199: + case 200: return visitNodes(cbNodes, node.declarations); - case 182: - return visitNode(cbNode, node.expression); case 183: + return visitNode(cbNode, node.expression); + case 184: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 184: + case 185: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 186: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 187: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 188: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 189: - case 190: - return visitNode(cbNode, node.label); - case 191: - return visitNode(cbNode, node.expression); - case 192: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 190: + case 191: + return visitNode(cbNode, node.label); + case 192: + return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 207: + case 208: return visitNodes(cbNodes, node.clauses); - case 220: + case 221: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 221: + case 222: return visitNodes(cbNodes, node.statements); - case 194: + case 195: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 195: - return visitNode(cbNode, node.expression); case 196: + return visitNode(cbNode, node.expression); + case 197: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 223: + case 224: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 130: + case 131: return visitNode(cbNode, node.expression); - case 201: - case 174: - 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 202: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -4819,65 +4908,72 @@ var ts; return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 204: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 226: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNode(cbNode, node.type); case 205: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 227: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 208: + case 209: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 209: + case 210: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 210: + case 211: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 211: - return visitNode(cbNode, node.name); case 212: - case 216: + return visitNode(cbNode, node.name); + case 213: + case 217: return visitNodes(cbNodes, node.elements); - case 215: + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 213: - case 217: + case 214: + case 218: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 214: + case 215: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 171: + case 172: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 176: + case 178: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 127: + case 128: return visitNode(cbNode, node.expression); - case 222: + case 223: return visitNodes(cbNodes, node.types); case 177: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 219: + case 220: return visitNode(cbNode, node.expression); - case 218: + case 219: return visitNodes(cbNodes, node.decorators); } } @@ -4963,7 +5059,7 @@ var ts; } } function createSourceFile(fileName, languageVersion) { - sourceFile = createNode(227, 0); + sourceFile = createNode(228, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5256,7 +5352,7 @@ var ts; return parseIdentifierName(); } function parseComputedPropertyName() { - var node = createNode(127); + var node = createNode(128); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5550,14 +5646,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { + case 210: case 209: - case 208: + case 216: case 215: - case 214: - case 201: case 202: + case 203: + case 206: case 205: - case 204: return true; } return isReusableStatement(node); @@ -5567,13 +5663,13 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 135: - case 140: - case 134: case 136: + case 141: + case 135: case 137: - case 132: - case 178: + case 138: + case 133: + case 179: return true; } } @@ -5582,8 +5678,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 220: case 221: + case 222: return true; } } @@ -5592,56 +5688,56 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 200: + case 201: + case 181: case 180: - case 179: + case 184: case 183: - case 182: - case 195: + case 196: + case 192: + case 194: case 191: - case 193: case 190: + case 188: case 189: case 187: - case 188: case 186: - case 185: - case 192: - case 181: - case 196: - case 194: - case 184: + case 193: + case 182: case 197: + case 195: + case 185: + case 198: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 226; + return node.kind === 227; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 139: - case 133: case 140: - case 131: - case 138: + case 134: + case 141: + case 132: + case 139: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 198) { + if (node.kind !== 199) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 129) { + if (node.kind !== 130) { return false; } var parameter = node; @@ -5736,7 +5832,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(126, entity.pos); + var node = createNode(127, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -5753,20 +5849,20 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(171); + var template = createNode(172); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(176); + var span = createNode(178); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -5800,7 +5896,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(141); + var node = createNode(142); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24) { node.typeArguments = parseBracketedList(17, parseType, 24, 25); @@ -5808,13 +5904,13 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(144); + var node = createNode(145); parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(128); + var node = createNode(129); node.name = parseIdentifier(); if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { @@ -5849,7 +5945,7 @@ var ts; } } function parseParameter() { - var node = createNode(129); + var node = createNode(130); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); @@ -5901,7 +5997,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 139) { + if (kind === 140) { parseExpected(88); } fillSignature(51, false, false, node); @@ -5941,7 +6037,7 @@ var ts; return token === 51 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(140, fullStart); + var node = createNode(141, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15, parseParameter, 18, 19); @@ -5954,7 +6050,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(133, fullStart); + var method = createNode(134, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -5962,7 +6058,7 @@ var ts; return finishNode(method); } else { - var property = createNode(131, fullStart); + var property = createNode(132, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6004,14 +6100,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(138); + return parseSignatureMember(139); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(139); + return parseSignatureMember(140); } case 8: case 7: @@ -6041,7 +6137,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(145); + var node = createNode(146); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -6057,12 +6153,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(147); + var node = createNode(148); node.elementTypes = parseBracketedList(18, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(149); + var node = createNode(150); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6070,7 +6166,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 143) { + if (kind === 144) { parseExpected(88); } fillSignature(32, false, false, node); @@ -6083,10 +6179,10 @@ var ts; function parseNonArrayType() { switch (token) { case 112: - case 121: - case 119: - case 113: case 122: + case 120: + case 113: + case 123: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 99: @@ -6106,10 +6202,10 @@ var ts; function isStartOfType() { switch (token) { case 112: - case 121: - case 119: - case 113: case 122: + case 120: + case 113: + case 123: case 99: case 97: case 14: @@ -6131,7 +6227,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(146, type.pos); + var node = createNode(147, type.pos); node.elementType = type; type = finishNode(node); } @@ -6146,7 +6242,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(148, type.pos); + var node = createNode(149, type.pos); node.types = types; type = finishNode(node); } @@ -6191,10 +6287,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(142); + return parseFunctionOrConstructorType(143); } if (token === 88) { - return parseFunctionOrConstructorType(143); + return parseFunctionOrConstructorType(144); } return parseUnionTypeOrHigher(); } @@ -6332,7 +6428,7 @@ var ts; (isIdentifier() || token === 14 || token === 18); } function parseYieldExpression() { - var node = createNode(172); + var node = createNode(173); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6346,8 +6442,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(163, identifier.pos); - var parameter = createNode(129, identifier.pos); + var node = createNode(164, identifier.pos); + var parameter = createNode(130, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -6425,7 +6521,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(163); + var node = createNode(164); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6452,7 +6548,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(170, leftOperand.pos); + var node = createNode(171, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -6465,7 +6561,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 125; + return t === 86 || t === 126; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6526,37 +6622,37 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(169, left.pos); + var node = createNode(170, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(167); + var node = createNode(168); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(164); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(165); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(166); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(167); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function parseUnaryExpressionOrHigher() { switch (token) { case 33: @@ -6582,7 +6678,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(168, expression.pos); + var node = createNode(169, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -6605,14 +6701,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(155, expression.pos); + var node = createNode(156, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(160); + var node = createNode(161); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -6623,7 +6719,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(155, expression.pos); + var propertyAccess = createNode(156, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -6631,7 +6727,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(156, expression.pos); + var indexedAccess = createNode(157, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -6645,7 +6741,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(159, expression.pos); + var tagExpression = createNode(160, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -6664,7 +6760,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(157, expression.pos); + var callExpr = createNode(158, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -6672,7 +6768,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(157, expression.pos); + var callExpr = createNode(158, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -6762,28 +6858,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(161); + var node = createNode(162); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(173); + var node = createNode(174); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(175) : + token === 23 ? createNode(176) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(153); + var node = createNode(154); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; @@ -6793,11 +6889,11 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116)) { - return parseAccessorDeclaration(136, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(120)) { return parseAccessorDeclaration(137, fullStart, decorators, modifiers); } + else if (parseContextualModifier(121)) { + return parseAccessorDeclaration(138, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -6817,13 +6913,13 @@ var ts; return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(225, fullStart); + var shorthandDeclaration = createNode(226, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(224, fullStart); + var propertyAssignment = createNode(225, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -6832,7 +6928,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(154); + var node = createNode(155); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; @@ -6846,7 +6942,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(162); + var node = createNode(163); parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -6861,7 +6957,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(158); + var node = createNode(159); parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -6871,7 +6967,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(179); + var node = createNode(180); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2, checkForStrictMode, parseStatement); parseExpected(15); @@ -6896,12 +6992,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(181); + var node = createNode(182); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(183); + var node = createNode(184); parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -6911,7 +7007,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(184); + var node = createNode(185); parseExpected(75); node.statement = parseStatement(); parseExpected(100); @@ -6922,7 +7018,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(185); + var node = createNode(186); parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -6945,21 +7041,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86)) { - var forInStatement = createNode(187, pos); + var forInStatement = createNode(188, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(125)) { - var forOfStatement = createNode(188, pos); + else if (parseOptional(126)) { + var forOfStatement = createNode(189, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(186, pos); + var forStatement = createNode(187, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -6977,7 +7073,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 190 ? 66 : 71); + parseExpected(kind === 191 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -6985,7 +7081,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(191); + var node = createNode(192); parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -6994,7 +7090,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(192); + var node = createNode(193); parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7003,7 +7099,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(220); + var node = createNode(221); parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); @@ -7011,7 +7107,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(221); + var node = createNode(222); parseExpected(73); parseExpected(51); node.statements = parseList(4, false, parseStatement); @@ -7021,12 +7117,12 @@ var ts; return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(193); + var node = createNode(194); parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(207, scanner.getStartPos()); + var caseBlock = createNode(208, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); parseExpected(15); @@ -7036,14 +7132,14 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(195); + var node = createNode(196); parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(196); + var node = createNode(197); parseExpected(96); node.tryBlock = parseBlock(false, false); node.catchClause = token === 68 ? parseCatchClause() : undefined; @@ -7054,7 +7150,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(223); + var result = createNode(224); parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); @@ -7064,7 +7160,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(197); + var node = createNode(198); parseExpected(72); parseSemicolon(); return finishNode(node); @@ -7073,13 +7169,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(194, fullStart); + var labeledStatement = createNode(195, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(182, fullStart); + var expressionStatement = createNode(183, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -7120,8 +7216,9 @@ var ts; return !isConstEnum; case 103: case 117: + case 118: case 77: - case 123: + case 124: if (isDeclarationStart()) { return false; } @@ -7166,9 +7263,9 @@ var ts; case 82: return parseForOrForInOrForOfStatement(); case 71: - return parseBreakOrContinueStatement(189); - case 66: return parseBreakOrContinueStatement(190); + case 66: + return parseBreakOrContinueStatement(191); case 90: return parseReturnStatement(); case 101: @@ -7231,16 +7328,16 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(175); + return createNode(176); } - var node = createNode(152); + var node = createNode(153); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(152); + var node = createNode(153); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 51) { @@ -7255,14 +7352,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(150); + var node = createNode(151); parseExpected(14); node.elements = parseDelimitedList(10, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(151); + var node = createNode(152); parseExpected(18); node.elements = parseDelimitedList(11, parseArrayBindingElement); parseExpected(19); @@ -7281,7 +7378,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(198); + var node = createNode(199); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7290,7 +7387,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(199); + var node = createNode(200); switch (token) { case 98: break; @@ -7304,7 +7401,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 125 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 126 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -7319,7 +7416,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(180, fullStart); + var node = createNode(181, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7327,7 +7424,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83); @@ -7338,7 +7435,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(135, pos); + var node = createNode(136, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114); @@ -7347,7 +7444,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(134, fullStart); + var method = createNode(135, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -7358,7 +7455,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(132, fullStart); + var property = createNode(133, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -7425,7 +7522,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 120 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 121 || idToken === 116) { return true; } switch (token) { @@ -7452,7 +7549,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(130, decoratorStart); + var decorator = createNode(131, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -7485,7 +7582,7 @@ var ts; } function parseClassElement() { if (token === 22) { - var result = createNode(178); + var result = createNode(179); nextToken(); return finishNode(result); } @@ -7516,10 +7613,10 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 174); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 175); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 201); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var savedStrictModeContext = inStrictModeContext(); @@ -7560,15 +7657,15 @@ var ts; } function parseHeritageClause() { if (token === 79 || token === 102) { - var node = createNode(222); + var node = createNode(223); node.token = token; nextToken(); - node.types = parseDelimitedList(8, parseHeritageClauseElement); + node.types = parseDelimitedList(8, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } - function parseHeritageClauseElement() { + function parseExpressionWithTypeArguments() { var node = createNode(177); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { @@ -7583,7 +7680,7 @@ var ts; return parseList(6, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(202, fullStart); + var node = createNode(203, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103); @@ -7594,10 +7691,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(204, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(123); + parseExpected(124); node.name = parseIdentifier(); parseExpected(53); node.type = parseType(); @@ -7605,13 +7702,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(226, scanner.getStartPos()); + var node = createNode(227, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77); @@ -7626,7 +7723,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(206, scanner.getStartPos()); + var node = createNode(207, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, false, parseModuleElement); parseExpected(15); @@ -7636,19 +7733,19 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { - var node = createNode(205, fullStart); + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20) - ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -7656,13 +7753,20 @@ var ts; return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { - parseExpected(117); - return token === 8 - ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) - : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(118)) { + flags |= 32768; + } + else { + parseExpected(117); + if (token === 8) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 118 && + return token === 119 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -7671,7 +7775,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 124; + token === 125; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85); @@ -7679,8 +7783,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 124) { - var importEqualsDeclaration = createNode(208, fullStart); + if (token !== 23 && token !== 125) { + var importEqualsDeclaration = createNode(209, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -7690,14 +7794,14 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(209, fullStart); + var importDeclaration = createNode(210, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(124); + parseExpected(125); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -7710,13 +7814,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(210, fullStart); + var importClause = createNode(211, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(212); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(213); } return finishNode(importClause); } @@ -7726,8 +7830,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(219); - parseExpected(118); + var node = createNode(220); + parseExpected(119); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -7741,7 +7845,7 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(211); + var namespaceImport = createNode(212); parseExpected(35); parseExpected(111); namespaceImport.name = parseIdentifier(); @@ -7749,14 +7853,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 212 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(20, kind === 213 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(217); + return parseImportOrExportSpecifier(218); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(213); + return parseImportOrExportSpecifier(214); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -7775,22 +7879,22 @@ var ts; else { node.name = identifierName; } - if (kind === 213 && checkIdentifierIsKeyword) { + if (kind === 214 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(124); + parseExpected(125); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(216); - if (parseOptional(124)) { + node.exportClause = parseNamedImportsOrExports(217); + if (parseOptional(125)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -7798,7 +7902,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53)) { @@ -7825,11 +7929,12 @@ var ts; case 69: case 103: case 77: - case 123: + case 124: return lookAhead(nextTokenIsIdentifierOrKeyword); case 85: return lookAhead(nextTokenCanFollowImportKeyword); case 117: + case 118: return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); case 78: return lookAhead(nextTokenCanFollowExportKeyword); @@ -7895,17 +8000,18 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 123: + case 124: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77: return parseEnumDeclaration(fullStart, decorators, modifiers); case 117: + case 118: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: if (decorators) { - var node = createMissingNode(218, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(219, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -7985,10 +8091,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 208 && node.moduleReference.kind === 219 - || node.kind === 209 - || node.kind === 214 + || node.kind === 209 && node.moduleReference.kind === 220 + || node.kind === 210 || node.kind === 215 + || node.kind === 216 ? node : undefined; }); @@ -8275,16 +8381,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 202 || node.kind === 203) { + if (node.kind === 203 || node.kind === 204) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 209 || node.kind === 208) && !(node.flags & 1)) { + else if ((node.kind === 210 || node.kind === 209) && !(node.flags & 1)) { return 0; } - else if (node.kind === 206) { + else if (node.kind === 207) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -8300,7 +8406,7 @@ var ts; }); return state; } - else if (node.kind === 205) { + else if (node.kind === 206) { return getModuleInstanceState(node.body); } else { @@ -8353,10 +8459,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 205 && node.name.kind === 8) { + if (node.kind === 206 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 127) { + if (node.name.kind === 128) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -8364,22 +8470,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 143: - case 135: + case 144: + case 136: return "__constructor"; - case 142: - case 138: - return "__call"; + case 143: case 139: - return "__new"; + return "__call"; case 140: + return "__new"; + case 141: return "__index"; - case 215: + case 216: return "__export"; - case 214: + case 215: return node.isExportEquals ? "export=" : "default"; - case 200: case 201: + case 202: return node.flags & 256 ? "default" : undefined; } } @@ -8411,7 +8517,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if ((node.kind === 201 || node.kind === 174) && symbol.exports) { + if ((node.kind === 202 || node.kind === 175) && symbol.exports) { var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { @@ -8427,7 +8533,7 @@ var ts; function declareModuleMember(node, symbolKind, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolKind & 8388608) { - if (node.kind === 217 || (node.kind === 208 && hasExportModifier)) { + if (node.kind === 218 || (node.kind === 209 && hasExportModifier)) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); } else { @@ -8435,7 +8541,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 32768) { + if (hasExportModifier || container.flags & 65536) { var exportKind = (symbolKind & 107455 ? 1048576 : 0) | (symbolKind & 793056 ? 2097152 : 0) | (symbolKind & 1536 ? 4194304 : 0); @@ -8461,7 +8567,7 @@ var ts; addToContainerChain(container); } if (isBlockScopeContainer) { - setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 227); + setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 228); } ts.forEachChild(node, bind); container = saveContainer; @@ -8476,41 +8582,41 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 205: + case 206: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227: + case 228: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 142: case 143: - case 138: + case 144: case 139: case 140: - case 134: - case 133: + case 141: case 135: + case 134: case 136: case 137: - case 200: - case 162: + case 138: + case 201: case 163: + case 164: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 174: - case 201: + case 175: + case 202: if (node.flags & 128) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 145: - case 154: - case 202: + case 146: + case 155: + case 203: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 204: + case 205: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -8525,11 +8631,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 227 ? node : node.body; - if (body.kind === 227 || body.kind === 206) { + var body = node.kind === 228 ? node : node.body; + if (body.kind === 228 || body.kind === 207) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 215 || stat.kind === 214) { + if (stat.kind === 216 || stat.kind === 215) { return true; } } @@ -8538,10 +8644,10 @@ var ts; } function setExportContextFlag(node) { if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 32768; + node.flags |= 65536; } else { - node.flags &= ~32768; + node.flags &= ~65536; } } function bindModuleDeclaration(node) { @@ -8579,7 +8685,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 142 ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 143 ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -8591,10 +8697,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolKind, symbolExcludes) { switch (blockScopeContainer.kind) { - case 205: + case 206: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227: + case 228: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; @@ -8617,14 +8723,14 @@ var ts; function bind(node) { node.parent = parent; switch (node.kind) { - case 128: + case 129: bindDeclaration(node, 262144, 530912, false); break; - case 129: + case 130: bindParameter(node); break; - case 198: - case 152: + case 199: + case 153: if (ts.isBindingPattern(node.name)) { bindChildren(node, 0, false); } @@ -8635,68 +8741,68 @@ var ts; bindDeclaration(node, 1, 107454, false); } break; + case 133: case 132: - case 131: bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455, false); break; - case 224: case 225: + case 226: bindPropertyOrMethodOrAccessor(node, 4, 107455, false); break; - case 226: + case 227: bindPropertyOrMethodOrAccessor(node, 8, 107455, false); break; - case 138: case 139: case 140: + case 141: bindDeclaration(node, 131072, 0, false); break; + case 135: case 134: - case 133: bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263, true); break; - case 200: + case 201: bindDeclaration(node, 16, 106927, true); break; - case 135: + case 136: bindDeclaration(node, 16384, 0, true); break; - case 136: + case 137: bindPropertyOrMethodOrAccessor(node, 32768, 41919, true); break; - case 137: + case 138: bindPropertyOrMethodOrAccessor(node, 65536, 74687, true); break; - case 142: case 143: + case 144: bindFunctionOrConstructorType(node); break; - case 145: + case 146: bindAnonymousDeclaration(node, 2048, "__type", false); break; - case 154: + case 155: bindAnonymousDeclaration(node, 4096, "__object", false); break; - case 162: case 163: + case 164: bindAnonymousDeclaration(node, 16, "__function", true); break; - case 174: + case 175: bindAnonymousDeclaration(node, 32, "__class", false); break; - case 223: + case 224: bindCatchVariableDeclaration(node); break; - case 201: + case 202: bindBlockScopedDeclaration(node, 32, 899583); break; - case 202: + case 203: bindDeclaration(node, 64, 792992, false); break; - case 203: + case 204: bindDeclaration(node, 524288, 793056, false); break; - case 204: + case 205: if (ts.isConst(node)) { bindDeclaration(node, 128, 899967, false); } @@ -8704,16 +8810,16 @@ var ts; bindDeclaration(node, 256, 899327, false); } break; - case 205: + case 206: bindModuleDeclaration(node); break; - case 208: - case 211: - case 213: - case 217: + case 209: + case 212: + case 214: + case 218: bindDeclaration(node, 8388608, 8388608, false); break; - case 210: + case 211: if (node.name) { bindDeclaration(node, 8388608, 8388608, false); } @@ -8721,13 +8827,13 @@ var ts; bindChildren(node, 0, false); } break; - case 215: + case 216: if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } bindChildren(node, 0, false); break; - case 214: + case 215: if (node.expression.kind === 65) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } @@ -8736,20 +8842,20 @@ var ts; } bindChildren(node, 0, false); break; - case 227: + case 228: setExportContextFlag(node); if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512, '"' + ts.removeFileExtension(node.fileName) + '"', true); break; } - case 179: + case 180: bindChildren(node, 0, !ts.isFunctionLike(node.parent)); break; - case 223: - case 186: + case 224: case 187: case 188: - case 207: + case 189: + case 208: bindChildren(node, 0, true); break; default: @@ -8767,8 +8873,8 @@ var ts; bindDeclaration(node, 1, 107455, false); } if (node.flags & 112 && - node.parent.kind === 135 && - (node.parent.parent.kind === 201 || node.parent.parent.kind === 174)) { + node.parent.kind === 136 && + (node.parent.parent.kind === 202 || node.parent.parent.kind === 175)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -8862,7 +8968,6 @@ var ts; var undefinedType = createIntrinsicType(32 | 262144, "undefined"); var nullType = createIntrinsicType(64 | 262144, "null"); var unknownType = createIntrinsicType(1, "unknown"); - var resolvingType = createIntrinsicType(1, "__resolving__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -8892,6 +8997,8 @@ var ts; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var resolutionTargets = []; + var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -9054,10 +9161,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 227); + return ts.getAncestor(node, 228); } function isGlobalSourceFile(node) { - return node.kind === 227 && !ts.isExternalModule(node); + return node.kind === 228 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -9099,34 +9206,34 @@ var ts; } } switch (location.kind) { - case 227: + case 228: if (!ts.isExternalModule(location)) break; - case 205: + case 206: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 217)) { + if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 218)) { break loop; } result = undefined; } - else if (location.kind === 227 || - (location.kind === 205 && location.name.kind === 8)) { - result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & 8914931); + else if (location.kind === 228 || + (location.kind === 206 && location.name.kind === 8)) { + result = getSymbolOfNode(location).exports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) { + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } break; - case 204: + case 205: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 133: case 132: - case 131: - if (location.parent.kind === 201 && !(location.flags & 128)) { + if (location.parent.kind === 202 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -9135,8 +9242,8 @@ var ts; } } break; - case 201: case 202: + case 203: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -9145,28 +9252,28 @@ var ts; break loop; } break; - case 127: + case 128: grandparent = location.parent.parent; - if (grandparent.kind === 201 || grandparent.kind === 202) { + if (grandparent.kind === 202 || grandparent.kind === 203) { 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 134: - case 133: case 135: + case 134: case 136: case 137: - case 200: - case 163: + case 138: + case 201: + case 164: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 162: + case 163: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9177,15 +9284,15 @@ var ts; break loop; } break; - case 174: + case 175: var className = location.name; if (className && name === className.text) { result = location.symbol; break loop; } break; - case 130: - if (location.parent && location.parent.kind === 129) { + case 131: + if (location.parent && location.parent.kind === 130) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -9223,14 +9330,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 198); + var variableDeclaration = ts.getAncestor(declaration, 199); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 180 || - variableDeclaration.parent.parent.kind === 186) { + if (variableDeclaration.parent.parent.kind === 181 || + variableDeclaration.parent.parent.kind === 187) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 188 || - variableDeclaration.parent.parent.kind === 187) { + else if (variableDeclaration.parent.parent.kind === 189 || + variableDeclaration.parent.parent.kind === 188) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -9252,10 +9359,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 208) { + if (node.kind === 209) { return node; } - while (node && node.kind !== 209) { + while (node && node.kind !== 210) { node = node.parent; } return node; @@ -9265,7 +9372,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 219) { + if (node.moduleReference.kind === 220) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -9275,7 +9382,7 @@ var ts; if (moduleSymbol) { var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } return exportDefaultSymbol; } @@ -9354,17 +9461,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 208: + case 209: return getTargetOfImportEqualsDeclaration(node); - case 210: - return getTargetOfImportClause(node); case 211: + return getTargetOfImportClause(node); + case 212: return getTargetOfNamespaceImport(node); - case 213: - return getTargetOfImportSpecifier(node); - case 217: - return getTargetOfExportSpecifier(node); case 214: + return getTargetOfImportSpecifier(node); + case 218: + return getTargetOfExportSpecifier(node); + case 215: return getTargetOfExportAssignment(node); } } @@ -9406,10 +9513,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 214) { + if (node.kind === 215) { checkExpressionCached(node.expression); } - else if (node.kind === 217) { + else if (node.kind === 218) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -9419,17 +9526,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 208); + importDeclaration = ts.getAncestor(entityName, 209); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 126) { + if (entityName.kind === 65 || entityName.parent.kind === 127) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 208); + ts.Debug.assert(entityName.parent.kind === 209); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -9442,14 +9549,15 @@ var ts; } var symbol; if (name.kind === 65) { - symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); + var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, message, name); if (!symbol) { return undefined; } } - else if (name.kind === 126 || name.kind === 155) { - var left = name.kind === 126 ? name.left : name.expression; - var right = name.kind === 126 ? name.right : name.name; + else if (name.kind === 127 || name.kind === 156) { + var left = name.kind === 127 ? name.left : name.expression; + var right = name.kind === 127 ? name.right : name.name; var namespace = resolveEntityName(left, 1536); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -9502,10 +9610,10 @@ var ts; if (sourceFile.symbol) { return sourceFile.symbol; } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.fileName); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); return; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); } function resolveExternalModuleSymbol(moduleSymbol) { return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; @@ -9513,7 +9621,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); if (symbol && !(symbol.flags & (1536 | 3))) { - error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } return symbol; @@ -9593,7 +9701,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 135 && ts.nodeIsPresent(member.body)) { + if (member.kind === 136 && ts.nodeIsPresent(member.body)) { return member; } } @@ -9658,17 +9766,17 @@ var ts; } } switch (location_1.kind) { - case 227: + case 228: if (!ts.isExternalModule(location_1)) { break; } - case 205: + case 206: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 201: case 202: + case 203: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -9783,8 +9891,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 205 && declaration.name.kind === 8) || - (declaration.kind === 227 && ts.isExternalModule(declaration)); + return (declaration.kind === 206 && declaration.name.kind === 8) || + (declaration.kind === 228 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -9816,11 +9924,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 144) { + if (entityName.parent.kind === 145) { meaning = 107455 | 1048576; } - else if (entityName.kind === 126 || entityName.kind === 155 || - entityName.parent.kind === 208) { + else if (entityName.kind === 127 || entityName.kind === 156 || + entityName.parent.kind === 209) { meaning = 1536; } else { @@ -9864,10 +9972,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 149) { + while (node.kind === 150) { node = node.parent; } - if (node.kind === 203) { + if (node.kind === 204) { return getSymbolOfNode(node); } } @@ -10039,7 +10147,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 227 || declaration.parent.kind === 206; + return declaration.parent.kind === 228 || declaration.parent.kind === 207; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -10114,7 +10222,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -10127,7 +10235,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 119); + writeKeyword(writer, 120); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -10271,12 +10379,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 205) { + if (node.kind === 206) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 227) { + else if (node.kind === 228) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10319,59 +10427,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 152: + case 153: return isDeclarationVisible(node.parent.parent); - case 198: + case 199: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 205: - case 201: + case 206: case 202: case 203: - case 200: case 204: - case 208: + case 201: + case 205: + case 209: var parent_2 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 208 && parent_2.kind !== 227 && ts.isInAmbientContext(parent_2))) { + !(node.kind !== 209 && parent_2.kind !== 228 && ts.isInAmbientContext(parent_2))) { return isGlobalSourceFile(parent_2); } return isDeclarationVisible(parent_2); - case 132: - case 131: - case 136: - case 137: - case 134: case 133: + case 132: + case 137: + case 138: + case 135: + case 134: if (node.flags & (32 | 64)) { return false; } - case 135: - case 139: - case 138: + case 136: case 140: - case 129: - case 206: - case 142: - case 143: - case 145: + case 139: case 141: + case 130: + case 207: + case 143: + case 144: case 146: + case 142: case 147: case 148: case 149: + case 150: return isDeclarationVisible(node.parent); - case 210: case 211: - case 213: - return false; - case 128: - case 227: - return true; + case 212: case 214: return false; + case 129: + case 228: + return true; + case 215: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -10386,10 +10494,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 214) { + if (node.parent && node.parent.kind === 215) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -10413,15 +10521,35 @@ var ts; }); } } + function pushTypeResolution(target) { + var i = 0; + var count = resolutionTargets.length; + while (i < count && resolutionTargets[i] !== target) { + i++; + } + if (i < count) { + do { + resolutionResults[i++] = false; + } while (i < count); + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + return true; + } + function popTypeResolution() { + resolutionTargets.pop(); + return resolutionResults.pop(); + } function getRootDeclaration(node) { - while (node.kind === 152) { + while (node.kind === 153) { node = node.parent.parent; } return node; } function getDeclarationContainer(node) { node = getRootDeclaration(node); - return node.kind === 198 ? node.parent.parent.parent : node.parent; + return node.kind === 199 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -10444,7 +10572,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 150) { + if (pattern.kind === 151) { var name_5 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_5.text) || isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || @@ -10481,10 +10609,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 187) { + if (declaration.parent.parent.kind === 188) { return anyType; } - if (declaration.parent.parent.kind === 188) { + if (declaration.parent.parent.kind === 189) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -10493,10 +10621,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129) { + if (declaration.kind === 130) { var func = declaration.parent; - if (func.kind === 137 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136); + if (func.kind === 138 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10509,7 +10637,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 225) { + if (declaration.kind === 226) { return checkIdentifier(declaration.name); } return undefined; @@ -10538,7 +10666,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 175 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 176 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -10553,7 +10681,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 150 + return pattern.kind === 151 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -10563,7 +10691,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 224 ? getWidenedType(type) : type; + return declaration.kind !== 225 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -10571,7 +10699,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 129 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 130 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -10584,26 +10712,29 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 223) { + if (declaration.parent.kind === 224) { return links.type = anyType; } - if (declaration.kind === 214) { + if (declaration.kind === 215) { return links.type = checkExpression(declaration.expression); } - links.type = resolvingType; + if (!pushTypeResolution(symbol)) { + return unknownType; + } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var diagnostic = symbol.valueDeclaration.type ? - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation : - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer; - error(symbol.valueDeclaration, diagnostic, symbolToString(symbol)); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } } + links.type = type; } return links.type; } @@ -10612,7 +10743,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 136) { + if (accessor.kind === 137) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -10624,15 +10755,12 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - checkAndStoreTypeOfAccessors(symbol, links); - return links.type; - } - function checkAndStoreTypeOfAccessors(symbol, links) { - links = links || getSymbolLinks(symbol); if (!links.type) { - links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 136); - var setter = ts.getDeclarationOfKind(symbol, 137); + if (!pushTypeResolution(symbol)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 137); + var setter = ts.getDeclarationOfKind(symbol, 138); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -10655,17 +10783,16 @@ var ts; } } } - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 136); - error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 137); + 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)); + } } + links.type = type; } + return links.type; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -10729,7 +10856,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 202 || node.kind === 201) { + if (node.kind === 203 || node.kind === 202) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -10763,10 +10890,10 @@ var ts; } function resolveBaseTypesOfClass(type) { type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 201); + var declaration = ts.getDeclarationOfKind(type.symbol, 202); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); if (baseTypeNode) { - var baseType = getTypeFromHeritageClauseElement(baseTypeNode); + var baseType = getTypeFromTypeNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -10786,10 +10913,10 @@ var ts; type.baseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 202 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 203 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; - var baseType = getTypeFromHeritageClauseElement(node); + var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 | 2048)) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -10827,17 +10954,16 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 203); - var type = getTypeFromTypeNode(declaration.type); - if (links.declaredType === resolvingType) { - links.declaredType = type; + if (!pushTypeResolution(links)) { + return unknownType; } - } - else if (links.declaredType === resolvingType) { - links.declaredType = unknownType; - var declaration = ts.getDeclarationOfKind(symbol, 203); - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 204); + var type = getTypeFromTypeNode(declaration.type); + if (!popTypeResolution()) { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; } return links.declaredType; } @@ -10855,7 +10981,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 128).constraint) { + if (!ts.getDeclarationOfKind(symbol, 129).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11302,7 +11428,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 136 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -11331,8 +11457,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 136 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 137); + if (declaration.kind === 137 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 138); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -11350,19 +11476,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 142: case 143: - case 200: - case 134: - case 133: + case 144: + case 201: case 135: - case 138: + case 134: + case 136: case 139: case 140: - case 136: + case 141: case 137: - case 162: + case 138: case 163: + case 164: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11376,7 +11502,9 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - signature.resolvedReturnType = resolvingType; + if (!pushTypeResolution(signature)) { + return unknownType; + } var type; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); @@ -11387,27 +11515,25 @@ var ts; else { type = getReturnTypeFromBody(signature.declaration); } - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = type; - } - } - else if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + } } } + signature.resolvedReturnType = type; } return signature.resolvedReturnType; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); if (type.flags & 4096 && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -11432,7 +11558,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 135 || signature.declaration.kind === 139; + var isConstructor = signature.declaration.kind === 136 || signature.declaration.kind === 140; var type = createObjectType(32768 | 65536); type.members = emptySymbols; type.properties = emptyArray; @@ -11446,7 +11572,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 119 : 121; + var syntaxKind = kind === 1 ? 120 : 122; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -11476,7 +11602,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11526,13 +11652,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 141 && n.typeName.kind === 65) { + if (n.kind === 142 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -11551,18 +11677,12 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReference(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromHeritageClauseElement(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromTypeReferenceOrHeritageClauseElement(node) { + function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var type; - if (node.kind !== 177 || ts.isSupportedHeritageClauseElement(node)) { - var typeNameOrExpression = node.kind === 141 + if (node.kind !== 177 || ts.isSupportedExpressionWithTypeArguments(node)) { + var typeNameOrExpression = node.kind === 142 ? node.typeName : node.expression; var symbol = resolveEntityName(typeNameOrExpression, 793056); @@ -11608,9 +11728,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 201: case 202: - case 204: + case 203: + case 205: return declaration; } } @@ -11799,38 +11919,38 @@ var ts; switch (node.kind) { case 112: return anyType; - case 121: + case 122: return stringType; - case 119: + case 120: return numberType; case 113: return booleanType; - case 122: + case 123: return esSymbolType; case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 141: - return getTypeFromTypeReference(node); - case 177: - return getTypeFromHeritageClauseElement(node); - case 144: - return getTypeFromTypeQueryNode(node); - case 146: - return getTypeFromArrayTypeNode(node); - case 147: - return getTypeFromTupleTypeNode(node); - case 148: - return getTypeFromUnionTypeNode(node); - case 149: - return getTypeFromTypeNode(node.type); case 142: - case 143: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + case 177: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); case 145: + return getTypeFromTypeQueryNode(node); + case 147: + return getTypeFromArrayTypeNode(node); + case 148: + return getTypeFromTupleTypeNode(node); + case 149: + return getTypeFromUnionTypeNode(node); + case 150: + return getTypeFromTypeNode(node.type); + case 143: + case 144: + case 146: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 65: - case 126: + case 127: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -11981,27 +12101,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 162: case 163: + case 164: return isContextSensitiveFunctionLikeDeclaration(node); - case 154: + case 155: return ts.forEach(node.properties, isContextSensitive); - case 153: + case 154: return ts.forEach(node.elements, isContextSensitive); - case 170: + case 171: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 169: + case 170: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 224: + case 225: return isContextSensitive(node.initializer); + case 135: case 134: - case 133: return isContextSensitiveFunctionLikeDeclaration(node); - case 161: + case 162: return isContextSensitive(node.expression); } return false; @@ -12775,22 +12895,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 133: case 132: - case 131: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 129: + case 130: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 200: + case 201: + case 135: case 134: - case 133: - case 136: case 137: - case 162: + case 138: case 163: + case 164: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -13033,10 +13153,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 144: + case 145: return true; case 65: - case 126: + case 127: node = node.parent; continue; default: @@ -13078,7 +13198,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 161) { + while (n.kind === 162) { n = n.expression; } if (n.kind === 65 && getResolvedSymbol(n) === symbol) { @@ -13095,46 +13215,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 169: + case 170: return isAssignedInBinaryExpression(node); - case 198: - case 152: - return isAssignedInVariableDeclaration(node); - case 150: - case 151: + case 199: case 153: + return isAssignedInVariableDeclaration(node); + case 151: + case 152: case 154: case 155: case 156: case 157: case 158: - case 160: + case 159: case 161: - case 167: - case 164: + case 162: + case 168: case 165: case 166: - case 168: - case 170: - case 173: - case 179: + case 167: + case 169: + case 171: + case 174: case 180: - case 182: + case 181: case 183: case 184: case 185: case 186: case 187: case 188: - case 191: + case 189: case 192: case 193: - case 220: - case 221: case 194: + case 221: + case 222: case 195: case 196: - case 223: + case 197: + case 224: return ts.forEachChild(node, isAssignedIn); } return false; @@ -13170,17 +13290,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 183: + case 184: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 170: + case 171: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 169: + case 170: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -13190,14 +13310,14 @@ var ts; } } break; - case 227: - case 205: - case 200: - case 134: - case 133: - case 136: - case 137: + case 228: + case 206: + case 201: case 135: + case 134: + case 137: + case 138: + case 136: break loop; } if (narrowedType !== type) { @@ -13210,7 +13330,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 165 || expr.right.kind !== 8) { + if (expr.left.kind !== 166 || expr.right.kind !== 8) { return type; } var left = expr.left; @@ -13269,23 +13389,38 @@ var ts; return type; } var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (!prototypeProperty) { - return type; + if (prototypeProperty) { + var targetType = getTypeOfSymbol(prototypeProperty); + if (targetType !== anyType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + } + } } - var targetType = getTypeOfSymbol(prototypeProperty); - if (isTypeSubtypeOf(targetType, type)) { - return targetType; + var constructSignatures; + if (rightType.flags & 2048) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + else if (rightType.flags & 32768) { + constructSignatures = getSignaturesOfType(rightType, 1); + } + if (constructSignatures && constructSignatures.length !== 0) { + var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + } + return instanceType; } return type; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 161: + case 162: return narrowType(type, expr.expression, assumeTrue); - case 169: + case 170: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -13300,7 +13435,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 167: + case 168: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -13311,7 +13446,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163 && languageVersion < 2) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 && 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); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -13335,15 +13470,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 223) { + symbol.valueDeclaration.parent.kind === 224) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 199) { + while (container.kind !== 200) { container = container.parent; } container = container.parent; - if (container.kind === 180) { + if (container.kind === 181) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -13360,9 +13495,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 201 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 132 || container.kind === 135) { + if (container.kind === 133 || container.kind === 136) { getNodeLinks(classNode).flags |= 4; } else { @@ -13372,36 +13507,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 163) { + if (container.kind === 164) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 205: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); + case 206: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 204: + case 205: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 135: + case 136: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 133: case 132: - case 131: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 127: + case 128: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 201 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13410,15 +13545,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 129) { + if (n.kind === 130) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 157 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 201); + var isCallExpression = node.parent.kind === 158 && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 202); var baseClass; if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -13434,31 +13569,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 135; + canUseSuperExpression = container.kind === 136; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 163) { + while (container && container.kind === 164) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } - if (container && container.parent && container.parent.kind === 201) { + if (container && container.parent && container.parent.kind === 202) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 134 || - container.kind === 133 || - container.kind === 136 || - container.kind === 137; + container.kind === 135 || + container.kind === 134 || + container.kind === 137 || + container.kind === 138; } else { canUseSuperExpression = - container.kind === 134 || - container.kind === 133 || - container.kind === 136 || + container.kind === 135 || + container.kind === 134 || container.kind === 137 || + container.kind === 138 || + container.kind === 133 || container.kind === 132 || - container.kind === 131 || - container.kind === 135; + container.kind === 136; } } } @@ -13472,7 +13607,7 @@ var ts; getNodeLinks(node).flags |= 16; returnType = baseClass; } - if (container.kind === 135 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 136 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -13482,7 +13617,7 @@ var ts; return returnType; } } - if (container && container.kind === 127) { + if (container && container.kind === 128) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -13507,7 +13642,7 @@ var ts; } if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); } } } @@ -13520,7 +13655,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129) { + if (declaration.kind === 130) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -13535,7 +13670,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 135 || func.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137))) { + if (func.type || func.kind === 136 || func.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 138))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignatureForFunctionLikeDeclaration(func); @@ -13555,7 +13690,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 159) { + if (template.parent.kind === 160) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -13663,32 +13798,32 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 198: - case 129: + case 199: + case 130: + case 133: case 132: - case 131: - case 152: - return getContextualTypeForInitializerExpression(node); - case 163: - case 191: - return getContextualTypeForReturnExpression(node); - case 157: - case 158: - return getContextualTypeForArgument(parent, node); - case 160: - return getTypeFromTypeNode(parent.type); - case 169: - return getContextualTypeForBinaryOperand(node); - case 224: - return getContextualTypeForObjectLiteralElement(parent); case 153: - return getContextualTypeForElementExpression(node); - case 170: - return getContextualTypeForConditionalOperand(node); - case 176: - ts.Debug.assert(parent.parent.kind === 171); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 164: + case 192: + return getContextualTypeForReturnExpression(node); + case 158: + case 159: + return getContextualTypeForArgument(parent, node); case 161: + return getTypeFromTypeNode(parent.type); + case 170: + return getContextualTypeForBinaryOperand(node); + case 225: + return getContextualTypeForObjectLiteralElement(parent); + case 154: + return getContextualTypeForElementExpression(node); + case 171: + return getContextualTypeForConditionalOperand(node); + case 178: + ts.Debug.assert(parent.parent.kind === 172); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 162: return getContextualType(parent); } return undefined; @@ -13703,13 +13838,13 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 162 || node.kind === 163; + return node.kind === 163 || node.kind === 164; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -13753,13 +13888,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 169 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 170 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (parent.kind === 224) { + if (parent.kind === 225) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 153) { + if (parent.kind === 154) { return isAssignmentTarget(parent); } return false; @@ -13778,7 +13913,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 173) { + if (inDestructuringPattern && e.kind === 174) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? checkIteratedType(restArrayType, undefined) : undefined); @@ -13790,7 +13925,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 173; + hasSpreadElement = hasSpreadElement || e.kind === 174; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -13801,7 +13936,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 127 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 128 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return allConstituentTypesHaveKind(checkComputedPropertyName(name), 1 | 132); @@ -13831,18 +13966,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 224 || - memberDecl.kind === 225 || + if (memberDecl.kind === 225 || + memberDecl.kind === 226 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 224) { + if (memberDecl.kind === 225) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 134) { + else if (memberDecl.kind === 135) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 225); + ts.Debug.assert(memberDecl.kind === 226); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -13857,7 +13992,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 136 || memberDecl.kind === 137); + ts.Debug.assert(memberDecl.kind === 137 || memberDecl.kind === 138); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -13890,7 +14025,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 132; + return s.valueDeclaration ? s.valueDeclaration.kind : 133; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -13900,7 +14035,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 201); + var enclosingClassDeclaration = ts.getAncestor(node, 202); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -13947,7 +14082,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -13959,14 +14094,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 155 + var left = node.kind === 156 ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 134) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { return false; } else { @@ -13981,7 +14116,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 158 && node.parent.expression === node) { + if (node.parent.kind === 159 && 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); @@ -14077,7 +14212,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 159) { + if (node.kind === 160) { checkExpression(node.template); } else { @@ -14130,7 +14265,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 173) { + if (args[i].kind === 174) { return i; } } @@ -14140,11 +14275,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 159) { + if (node.kind === 160) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 171) { + if (tagExpression.template.kind === 172) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -14159,7 +14294,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 158); + ts.Debug.assert(callExpression.kind === 159); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -14211,10 +14346,10 @@ var ts; } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175) { + if (arg.kind !== 176) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 159) { + if (i === 0 && args[i].parent.kind === 160) { argType = globalTemplateStringsArrayType; } else { @@ -14254,9 +14389,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175) { + if (arg.kind !== 176) { var paramType = getTypeAtPosition(signature, i); - var argType = i === 0 && node.kind === 159 + var argType = i === 0 && node.kind === 160 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) @@ -14270,10 +14405,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 159) { + if (node.kind === 160) { var template = node.template; args = [template]; - if (template.kind === 171) { + if (template.kind === 172) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -14286,7 +14421,7 @@ var ts; } function getEffectiveTypeArguments(callExpression) { if (callExpression.expression.kind === 91) { - var containingClass = ts.getAncestor(callExpression, 201); + var containingClass = ts.getAncestor(callExpression, 202); var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -14295,7 +14430,7 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 159; + var isTaggedTemplate = node.kind === 160; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); @@ -14505,13 +14640,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 157) { + if (node.kind === 158) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 158) { + else if (node.kind === 159) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 159) { + else if (node.kind === 160) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -14526,12 +14661,12 @@ var ts; if (node.expression.kind === 91) { return voidType; } - if (node.kind === 158) { + if (node.kind === 159) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 135 && - declaration.kind !== 139 && - declaration.kind !== 143) { + declaration.kind !== 136 && + declaration.kind !== 140 && + declaration.kind !== 144) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -14567,9 +14702,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var parameter = signature.parameters[signature.parameters.length - 1]; + var parameter = ts.lastOrUndefined(signature.parameters); var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -14578,7 +14713,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 179) { + if (func.body.kind !== 180) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -14616,7 +14751,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 195); + return (body.statements.length === 1) && (body.statements[0].kind === 196); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -14625,7 +14760,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 179) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 180) { return; } var bodyBlock = func.body; @@ -14638,9 +14773,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 162) { + if (!hasGrammarError && node.kind === 163) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -14657,10 +14792,9 @@ var ts; if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type) { - signature.resolvedReturnType = resolvingType; + if (!node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); - if (signature.resolvedReturnType === resolvingType) { + if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } @@ -14668,19 +14802,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 134 && node.kind !== 133) { + if (produceDiagnostics && node.kind !== 135 && node.kind !== 134) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 179) { + if (node.body.kind === 180) { checkSourceElement(node.body); } else { @@ -14710,13 +14844,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 155: { + case 156: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 156: + case 157: return true; - case 161: + case 162: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14725,11 +14859,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65: - case 155: { + case 156: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 156: { + case 157: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { @@ -14739,7 +14873,7 @@ var ts; } return false; } - case 161: + case 162: return isConstVariableReference(n.expression); default: return false; @@ -14864,7 +14998,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 224 || p.kind === 225) { + if (p.kind === 225 || p.kind === 226) { var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : getTypeOfPropertyOfType(sourceType, name_8.text) || @@ -14888,8 +15022,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175) { - if (e.kind !== 173) { + if (e.kind !== 176) { + if (e.kind !== 174) { var propName = "" + i; var type = sourceType.flags & 1 ? sourceType : isTupleLikeType(sourceType) @@ -14913,7 +15047,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 169 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 170 && restExpression.operatorToken.kind === 53) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -14926,14 +15060,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 169 && target.operatorToken.kind === 53) { + if (target.kind === 170 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 154) { + if (target.kind === 155) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 153) { + if (target.kind === 154) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -14950,7 +15084,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 154 || node.left.kind === 153)) { + if (operator === 53 && (node.left.kind === 155 || node.left.kind === 154)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -15124,14 +15258,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 127) { + if (node.name.kind === 128) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 127) { + if (node.name.kind === 128) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -15158,7 +15292,7 @@ var ts; } function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 126) { + if (node.kind == 127) { type = checkQualifiedName(node); } else { @@ -15166,9 +15300,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 155 && node.parent.expression === node) || - (node.parent.kind === 156 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 126) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 156 && node.parent.expression === node) || + (node.parent.kind === 157 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 127) && 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); } @@ -15194,54 +15328,54 @@ var ts; return booleanType; case 7: return checkNumericLiteral(node); - case 171: + case 172: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 153: - return checkArrayLiteral(node, contextualMapper); case 154: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 155: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 156: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 157: + return checkIndexedAccess(node); case 158: - return checkCallExpression(node); case 159: - return checkTaggedTemplateExpression(node); + return checkCallExpression(node); case 160: - return checkTypeAssertion(node); + return checkTaggedTemplateExpression(node); case 161: - return checkExpression(node.expression, contextualMapper); - case 174: - return checkClassExpression(node); + return checkTypeAssertion(node); case 162: - case 163: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 165: - return checkTypeOfExpression(node); - case 164: - return checkDeleteExpression(node); - case 166: - return checkVoidExpression(node); - case 167: - return checkPrefixUnaryExpression(node); - case 168: - return checkPostfixUnaryExpression(node); - case 169: - return checkBinaryExpression(node, contextualMapper); - case 170: - return checkConditionalExpression(node, contextualMapper); - case 173: - return checkSpreadElementExpression(node, contextualMapper); + return checkExpression(node.expression, contextualMapper); case 175: + return checkClassExpression(node); + case 163: + case 164: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 166: + return checkTypeOfExpression(node); + case 165: + return checkDeleteExpression(node); + case 167: + return checkVoidExpression(node); + case 168: + return checkPrefixUnaryExpression(node); + case 169: + return checkPostfixUnaryExpression(node); + case 170: + return checkBinaryExpression(node, contextualMapper); + case 171: + return checkConditionalExpression(node, contextualMapper); + case 174: + return checkSpreadElementExpression(node, contextualMapper); + case 176: return undefinedType; - case 172: + case 173: checkYieldExpression(node); return unknownType; } @@ -15270,7 +15404,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 135 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 136 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -15282,12 +15416,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 140) { + if (node.kind === 141) { checkGrammarIndexSignature(node); } - else if (node.kind === 142 || node.kind === 200 || node.kind === 143 || - node.kind === 138 || node.kind === 135 || - node.kind === 139) { + else if (node.kind === 143 || node.kind === 201 || node.kind === 144 || + node.kind === 139 || node.kind === 136 || + node.kind === 140) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -15299,10 +15433,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 139: + case 140: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 138: + case 139: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -15311,7 +15445,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 202) { + if (node.kind === 203) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -15326,7 +15460,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 121: + case 122: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -15334,7 +15468,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 119: + case 120: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -15371,17 +15505,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 157 && n.expression.kind === 91; + return n.kind === 158 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 162: - case 200: case 163: - case 154: return false; + case 201: + case 164: + case 155: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -15389,12 +15523,12 @@ var ts; if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 162 && n.kind !== 200) { + else if (n.kind !== 163 && n.kind !== 201) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 132 && + return n.kind === 133 && !(n.flags & 128) && !!n.initializer; } @@ -15404,7 +15538,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 182 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 183 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -15420,13 +15554,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 136) { + if (node.kind === 137) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 136 ? 137 : 136; + var otherKind = node.kind === 137 ? 138 : 137; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -15441,7 +15575,7 @@ var ts; } } } - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + getTypeOfAccessors(getSymbolOfNode(node)); } checkFunctionLikeDeclaration(node); } @@ -15450,15 +15584,15 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrHeritageClauseElement(node); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkHeritageClauseElement(node) { - checkGrammarHeritageClauseElementInStrictMode(node.expression); - return checkTypeReferenceOrHeritageClauseElement(node); + function checkExpressionWithTypeArguments(node) { + checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkTypeReferenceOrHeritageClauseElement(node) { + function checkTypeReferenceOrExpressionWithTypeArguments(node) { checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrHeritageClauseElement(node); + var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); if (type !== unknownType && node.typeArguments) { var len = node.typeArguments.length; for (var i = 0; i < len; i++) { @@ -15511,9 +15645,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 202) { - ts.Debug.assert(signatureDeclarationNode.kind === 138 || signatureDeclarationNode.kind === 139); - var signatureKind = signatureDeclarationNode.kind === 138 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203) { + ts.Debug.assert(signatureDeclarationNode.kind === 139 || signatureDeclarationNode.kind === 140); + var signatureKind = signatureDeclarationNode.kind === 139 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -15531,7 +15665,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 202 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 203 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -15604,7 +15738,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) { - ts.Debug.assert(node.kind === 134 || node.kind === 133); + ts.Debug.assert(node.kind === 135 || node.kind === 134); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -15631,11 +15765,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 202 || node.parent.kind === 145 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 203 || node.parent.kind === 146 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 200 || node.kind === 134 || node.kind === 133 || node.kind === 135) { + if (node.kind === 201 || node.kind === 135 || node.kind === 134 || node.kind === 136) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -15732,16 +15866,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 202: + case 203: return 2097152; - case 205: + case 206: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 201: - case 204: + case 202: + case 205: return 2097152 | 1048576; - case 208: + case 209: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -15755,29 +15889,29 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 201: + case 202: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 132: + case 133: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 134: - case 136: + case 135: case 137: + case 138: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 129: + case 130: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 141) { + if (node && node.kind === 142) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 | 132 | 258))) { @@ -15790,19 +15924,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 132: + case 133: checkTypeNodeAsExpression(node.type); break; - case 129: + case 130: checkTypeNodeAsExpression(node.type); break; - case 134: - checkTypeNodeAsExpression(node.type); - break; - case 136: + case 135: checkTypeNodeAsExpression(node.type); break; case 137: + checkTypeNodeAsExpression(node.type); + break; + case 138: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -15822,24 +15956,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 201: + case 202: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 134: + case 135: checkParameterTypeAnnotationsAsExpressions(node); + case 138: case 137: - case 136: - case 132: - case 129: + case 133: + case 130: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 129) { + if (node.kind === 130) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -15859,7 +15993,7 @@ var ts; checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 127) { + if (node.name && node.name.kind === 128) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -15884,11 +16018,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 179) { + if (node.kind === 180) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 206) { + if (ts.isFunctionBlock(node) || node.kind === 207) { checkFunctionExpressionBodies(node); } } @@ -15906,19 +16040,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 132 || - node.kind === 131 || + if (node.kind === 133 || + node.kind === 132 || + node.kind === 135 || node.kind === 134 || - node.kind === 133 || - node.kind === 136 || - node.kind === 137) { + node.kind === 137 || + node.kind === 138) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = getRootDeclaration(node); - if (root.kind === 129 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 130 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -15948,7 +16082,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 201); + var enclosingClass = ts.getAncestor(node, 202); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } @@ -15966,12 +16100,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 205 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 206 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 227 && ts.isExternalModule(parent)) { - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + if (parent.kind === 228 && ts.isExternalModule(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)); } } function checkVarDeclaredNamesNotShadowed(node) { @@ -15981,7 +16115,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || isParameterDeclaration(node)) { return; } - if (node.kind === 198 && !node.initializer) { + if (node.kind === 199 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -15991,15 +16125,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 199); - var container = varDeclList.parent.kind === 180 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200); + var container = varDeclList.parent.kind === 181 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 179 && ts.isFunctionLike(container.parent) || + (container.kind === 180 && ts.isFunctionLike(container.parent) || + container.kind === 207 || container.kind === 206 || - container.kind === 205 || - container.kind === 227); + container.kind === 228); if (!namesShareScope) { var name_9 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_9, name_9); @@ -16009,13 +16143,13 @@ var ts; } } function isParameterDeclaration(node) { - while (node.kind === 152) { + while (node.kind === 153) { node = node.parent.parent; } - return node.kind === 129; + return node.kind === 130; } function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 129) { + if (getRootDeclaration(node).kind !== 130) { return; } var func = ts.getContainingFunction(node); @@ -16024,7 +16158,7 @@ var ts; if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 129) { + if (referencedSymbol.valueDeclaration.kind === 130) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -16045,7 +16179,7 @@ var ts; checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 127) { + if (node.name.kind === 128) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -16054,7 +16188,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && getRootDeclaration(node).kind === 129 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 130 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -16082,9 +16216,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 132 && node.kind !== 131) { + if (node.kind !== 133 && node.kind !== 132) { checkExportsOnMergedDeclarations(node); - if (node.kind === 198 || node.kind === 152) { + if (node.kind === 199 || node.kind === 153) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -16113,7 +16247,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 179 || node.kind === 154) { + if (node.kind === 180 || node.kind === 155) { return true; } node = node.parent; @@ -16141,12 +16275,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 199) { + if (node.initializer && node.initializer.kind == 200) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -16161,13 +16295,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 153 || varExpr.kind === 154) { + if (varExpr.kind === 154 || varExpr.kind === 155) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -16182,7 +16316,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { 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); @@ -16192,7 +16326,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 153 || varExpr.kind === 154) { + if (varExpr.kind === 154 || varExpr.kind === 155) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 | 258)) { @@ -16353,7 +16487,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 136 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137))); + return !!(node.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -16367,11 +16501,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 137) { + if (func.kind === 138) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 135) { + if (func.kind === 136) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -16398,7 +16532,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 221 && !hasDuplicateDefaultClause) { + if (clause.kind === 222 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -16410,7 +16544,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 220) { + if (produceDiagnostics && clause.kind === 221) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -16427,7 +16561,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 194 && current.label.text === node.label.text) { + if (current.kind === 195 && 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; @@ -16491,7 +16625,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 201) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 202) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -16522,7 +16656,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 128 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -16573,7 +16707,7 @@ var ts; } function checkClassDeclaration(node) { checkGrammarDeclarationNameInStrictMode(node); - if (node.parent.kind !== 206 && node.parent.kind !== 227) { + if (node.parent.kind !== 207 && node.parent.kind !== 228) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); } if (!node.name && !(node.flags & 256)) { @@ -16593,11 +16727,11 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedHeritageClauseElement(baseTypeNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkHeritageClauseElement(baseTypeNode); + checkExpressionWithTypeArguments(baseTypeNode); } var baseTypes = getBaseTypes(type); if (baseTypes.length) { @@ -16618,12 +16752,12 @@ var ts; var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { - if (!ts.isSupportedHeritageClauseElement(typeRefNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(typeRefNode); + checkExpressionWithTypeArguments(typeRefNode); if (produceDiagnostics) { - var t = getTypeFromHeritageClauseElement(typeRefNode); + var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { @@ -16703,7 +16837,7 @@ var ts; } } function isAccessor(kind) { - return kind === 136 || kind === 137; + return kind === 137 || kind === 138; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -16769,7 +16903,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 202); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203); 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); @@ -16786,10 +16920,10 @@ var ts; } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedHeritageClauseElement(heritageElement)) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(heritageElement); + checkExpressionWithTypeArguments(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -16810,7 +16944,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 127 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 128 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -16846,7 +16980,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 167: + case 168: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -16857,7 +16991,7 @@ var ts; case 47: return ~value; } return undefined; - case 169: + case 170: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -16882,11 +17016,11 @@ var ts; return undefined; case 7: return +e.text; - case 161: + case 162: return evalConstant(e.expression); case 65: + case 157: case 156: - case 155: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -16897,7 +17031,7 @@ var ts; } else { var expression; - if (e.kind === 156) { + if (e.kind === 157) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -16914,7 +17048,7 @@ var ts; if (current.kind === 65) { break; } - else if (current.kind === 155) { + else if (current.kind === 156) { current = current.expression; } else { @@ -16971,7 +17105,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 204) { + if (declaration.kind !== 205) { return false; } var enumDeclaration = declaration; @@ -16994,8 +17128,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 201 || - (declaration.kind === 200 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 202 || + (declaration.kind === 201 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -17033,13 +17167,13 @@ var ts; var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); } else if (node.pos < firstNonAmbientClassOrFunc.pos) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); + 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, 201); + var mergedClass = ts.getDeclarationOfKind(symbol, 202); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048; @@ -17047,10 +17181,10 @@ var ts; } if (node.name.kind === 8) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } if (isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name); + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } } @@ -17058,10 +17192,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 126) { + if (node.kind === 127) { node = node.left; } - else if (node.kind === 155) { + else if (node.kind === 156) { node = node.expression; } else { @@ -17077,15 +17211,15 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 206 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 227 && !inAmbientExternalModule) { - error(moduleName, node.kind === 215 ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : - ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 228 && !inAmbientExternalModule) { + error(moduleName, node.kind === 216 ? + 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 && isExternalModuleNameRelative(moduleName.text)) { - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } return true; @@ -17098,7 +17232,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 217 ? + var message = node.kind === 218 ? 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)); @@ -17121,7 +17255,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211) { + if (importClause.namedBindings.kind === 212) { checkImportBinding(importClause.namedBindings); } else { @@ -17166,15 +17300,15 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 206 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 227 && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 228 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } @@ -17186,9 +17320,9 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 227 ? node.parent : node.parent.parent; - if (container.kind === 205 && container.name.kind === 65) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); + var container = node.parent.kind === 228 ? node.parent : node.parent.parent; + if (container.kind === 206 && container.name.kind === 65) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { @@ -17201,15 +17335,20 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if (node.isExportEquals && languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (languageVersion >= 2) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } + else if (compilerOptions.module === 4) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } } } function getModuleStatements(node) { - if (node.kind === 227) { + if (node.kind === 228) { return node.statements; } - if (node.kind === 205 && node.body.kind === 206) { + if (node.kind === 206 && node.body.kind === 207) { return node.body.statements; } return emptyArray; @@ -17238,163 +17377,162 @@ var ts; if (!node) return; switch (node.kind) { - case 128: - return checkTypeParameter(node); case 129: + return checkTypeParameter(node); + case 130: return checkParameter(node); + case 133: case 132: - case 131: return checkPropertyDeclaration(node); - case 142: case 143: - case 138: + case 144: case 139: - return checkSignatureDeclaration(node); case 140: return checkSignatureDeclaration(node); - case 134: - case 133: - return checkMethodDeclaration(node); - case 135: - return checkConstructorDeclaration(node); - case 136: - case 137: - return checkAccessorDeclaration(node); case 141: + return checkSignatureDeclaration(node); + case 135: + case 134: + return checkMethodDeclaration(node); + case 136: + return checkConstructorDeclaration(node); + case 137: + case 138: + return checkAccessorDeclaration(node); + case 142: return checkTypeReferenceNode(node); - case 144: - return checkTypeQuery(node); case 145: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 146: - return checkArrayType(node); + return checkTypeLiteral(node); case 147: - return checkTupleType(node); + return checkArrayType(node); case 148: - return checkUnionType(node); + return checkTupleType(node); case 149: + return checkUnionType(node); + case 150: return checkSourceElement(node.type); - case 200: - return checkFunctionDeclaration(node); - case 179: - case 206: - return checkBlock(node); - case 180: - return checkVariableStatement(node); - case 182: - return checkExpressionStatement(node); - case 183: - return checkIfStatement(node); - case 184: - return checkDoStatement(node); - case 185: - return checkWhileStatement(node); - case 186: - return checkForStatement(node); - case 187: - return checkForInStatement(node); - case 188: - return checkForOfStatement(node); - case 189: - case 190: - return checkBreakOrContinueStatement(node); - case 191: - return checkReturnStatement(node); - case 192: - return checkWithStatement(node); - case 193: - return checkSwitchStatement(node); - case 194: - return checkLabeledStatement(node); - case 195: - return checkThrowStatement(node); - case 196: - return checkTryStatement(node); - case 198: - return checkVariableDeclaration(node); - case 152: - return checkBindingElement(node); case 201: - return checkClassDeclaration(node); - case 202: - return checkInterfaceDeclaration(node); - case 203: - return checkTypeAliasDeclaration(node); - case 204: - return checkEnumDeclaration(node); - case 205: - return checkModuleDeclaration(node); - case 209: - return checkImportDeclaration(node); - case 208: - return checkImportEqualsDeclaration(node); - case 215: - return checkExportDeclaration(node); - case 214: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 180: + case 207: + return checkBlock(node); case 181: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 183: + return checkExpressionStatement(node); + case 184: + return checkIfStatement(node); + case 185: + return checkDoStatement(node); + case 186: + return checkWhileStatement(node); + case 187: + return checkForStatement(node); + case 188: + return checkForInStatement(node); + case 189: + return checkForOfStatement(node); + case 190: + case 191: + return checkBreakOrContinueStatement(node); + case 192: + return checkReturnStatement(node); + case 193: + return checkWithStatement(node); + case 194: + return checkSwitchStatement(node); + case 195: + return checkLabeledStatement(node); + case 196: + return checkThrowStatement(node); case 197: + return checkTryStatement(node); + case 199: + return checkVariableDeclaration(node); + case 153: + return checkBindingElement(node); + case 202: + return checkClassDeclaration(node); + case 203: + return checkInterfaceDeclaration(node); + case 204: + return checkTypeAliasDeclaration(node); + case 205: + return checkEnumDeclaration(node); + case 206: + return checkModuleDeclaration(node); + case 210: + return checkImportDeclaration(node); + case 209: + return checkImportEqualsDeclaration(node); + case 216: + return checkExportDeclaration(node); + case 215: + return checkExportAssignment(node); + case 182: checkGrammarStatementInAmbientContext(node); return; - case 218: + case 198: + checkGrammarStatementInAmbientContext(node); + return; + case 219: return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 162: case 163: + case 164: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case 135: case 134: - case 133: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 135: case 136: case 137: - case 200: + case 138: + case 201: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 192: + case 193: checkFunctionExpressionBodies(node.expression); break; - case 129: + case 130: + case 133: case 132: - case 131: - case 150: case 151: case 152: case 153: case 154: - case 224: case 155: + case 225: case 156: case 157: case 158: case 159: - case 171: - case 176: case 160: + case 172: + case 178: case 161: - case 165: + case 162: case 166: - case 164: case 167: + case 165: case 168: case 169: case 170: - case 173: - case 179: - case 206: + case 171: + case 174: case 180: - case 182: + case 207: + case 181: case 183: case 184: case 185: @@ -17404,21 +17542,22 @@ var ts; case 189: case 190: case 191: - case 193: - case 207: - case 220: - case 221: + case 192: case 194: + case 208: + case 221: + case 222: case 195: case 196: - case 223: - case 198: + case 197: + case 224: case 199: - case 201: - case 204: - case 226: - case 214: + case 200: + case 202: + case 205: case 227: + case 215: + case 228: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -17478,7 +17617,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 192 && node.parent.statement === node) { + if (node.parent.kind === 193 && node.parent.statement === node) { return true; } node = node.parent; @@ -17500,23 +17639,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227: + case 228: if (!ts.isExternalModule(location)) { break; } - case 205: + case 206: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 204: + case 205: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 201: case 202: + case 203: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 162: + case 163: if (location.name) { copySymbol(location.symbol, meaning); } @@ -17552,22 +17691,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227: + case 228: if (!ts.isExternalModule(location)) break; - case 205: + case 206: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 204: + case 205: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 201: case 202: + case 203: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 162: + case 163: if (location.name) { copySymbol(location.symbol, meaning); } @@ -17586,104 +17725,104 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 128: - case 201: + case 129: case 202: case 203: case 204: + case 205: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 126) { + while (node.parent && node.parent.kind === 127) { node = node.parent; } - return node.parent && node.parent.kind === 141; + return node.parent && node.parent.kind === 142; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 155) { + while (node.parent && node.parent.kind === 156) { node = node.parent; } return node.parent && node.parent.kind === 177; } function isTypeNode(node) { - if (141 <= node.kind && node.kind <= 149) { + if (142 <= node.kind && node.kind <= 150) { return true; } switch (node.kind) { case 112: - case 119: - case 121: - case 113: + case 120: case 122: + case 113: + case 123: return true; case 99: - return node.parent.kind !== 166; + return node.parent.kind !== 167; case 8: - return node.parent.kind === 129; + return node.parent.kind === 130; case 177: return true; case 65: - if (node.parent.kind === 126 && node.parent.right === node) { + if (node.parent.kind === 127 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 155 && node.parent.name === node) { + else if (node.parent.kind === 156 && node.parent.name === node) { node = node.parent; } - case 126: - case 155: - ts.Debug.assert(node.kind === 65 || node.kind === 126 || node.kind === 155, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 127: + case 156: + ts.Debug.assert(node.kind === 65 || node.kind === 127 || node.kind === 156, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_5 = node.parent; - if (parent_5.kind === 144) { + if (parent_5.kind === 145) { return false; } - if (141 <= parent_5.kind && parent_5.kind <= 149) { + if (142 <= parent_5.kind && parent_5.kind <= 150) { return true; } switch (parent_5.kind) { case 177: return true; - case 128: - return node === parent_5.constraint; - case 132: - case 131: case 129: - case 198: + return node === parent_5.constraint; + case 133: + case 132: + case 130: + case 199: return node === parent_5.type; - case 200: - case 162: + case 201: case 163: + case 164: + case 136: case 135: case 134: - case 133: - case 136: case 137: - return node === parent_5.type; case 138: + return node === parent_5.type; case 139: case 140: + case 141: return node === parent_5.type; - case 160: + case 161: return node === parent_5.type; - case 157: case 158: - return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; case 159: + return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; + case 160: return false; } } return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 126) { + while (nodeOnRightSide.parent.kind === 127) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 208) { + if (nodeOnRightSide.parent.kind === 209) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 214) { + if (nodeOnRightSide.parent.kind === 215) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -17695,10 +17834,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 214) { + if (entityName.parent.kind === 215) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 155) { + if (entityName.kind !== 156) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -17719,14 +17858,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 155) { + else if (entityName.kind === 156) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 126) { + else if (entityName.kind === 127) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -17735,7 +17874,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 141 ? 793056 : 1536; + var meaning = entityName.parent.kind === 142 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -17749,14 +17888,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 214 + return node.parent.kind === 215 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65: - case 155: - case 126: + case 156: + case 127: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93: case 91: @@ -17764,7 +17903,7 @@ var ts; return type.symbol; case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 135) { + if (constructorDeclaration && constructorDeclaration.kind === 136) { return constructorDeclaration.parent.symbol; } return undefined; @@ -17772,12 +17911,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 209 || node.parent.kind === 215) && + ((node.parent.kind === 210 || node.parent.kind === 216) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 156 && node.parent.argumentExpression === node) { + if (node.parent.kind == 157 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -17791,7 +17930,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 225) { + if (location && location.kind === 226) { return resolveEntityName(location.name, 107455); } return undefined; @@ -17865,7 +18004,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 227; + return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228; } function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { if (languageVersion >= 2) { @@ -17873,7 +18012,7 @@ var ts; } var node = getDeclarationOfAliasSymbol(symbol); if (node) { - if (node.kind === 210) { + if (node.kind === 211) { var defaultKeyword; if (languageVersion === 0) { defaultKeyword = "[\"default\"]"; @@ -17883,7 +18022,7 @@ var ts; } return getGeneratedNameForNode(node.parent) + defaultKeyword; } - if (node.kind === 213) { + if (node.kind === 214) { var moduleName = getGeneratedNameForNode(node.parent.parent.parent); var propertyName = node.propertyName || node.name; return moduleName + "." + ts.unescapeIdentifier(propertyName.text); @@ -17892,7 +18031,7 @@ var ts; } function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { - if (languageVersion >= 2) { + if (languageVersion >= 2 || compilerOptions.module === 4) { return undefined; } return "exports." + ts.unescapeIdentifier(symbol.name); @@ -17900,7 +18039,7 @@ var ts; var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 205 || node.kind === 204) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 206 || node.kind === 205) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; @@ -17923,22 +18062,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 208: - case 210: + case 209: case 211: - case 213: - case 217: + case 212: + case 214: + case 218: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 215: + case 216: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 214: + case 215: return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 227 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 228 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -17983,7 +18122,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 226) { + if (node.kind === 227) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -18014,7 +18153,7 @@ var ts; } } function serializeTypeReferenceNode(node, getGeneratedNameForNode) { - var type = getTypeFromTypeReference(node); + var type = getTypeFromTypeNode(node); if (type.flags & 16) { return "void 0"; } @@ -18051,26 +18190,26 @@ var ts; switch (node.kind) { case 99: return "void 0"; - case 149: + case 150: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 142: case 143: + case 144: return "Function"; - case 146: case 147: + case 148: return "Array"; case 113: return "Boolean"; - case 121: + case 122: case 8: return "String"; - case 119: + case 120: return "Number"; - case 141: + case 142: return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 144: case 145: - case 148: + case 146: + case 149: case 112: break; default: @@ -18082,11 +18221,11 @@ var ts; } function serializeTypeOfNode(node, getGeneratedNameForNode) { switch (node.kind) { - case 201: return "Function"; - case 132: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 129: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 136: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 202: return "Function"; + case 133: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 130: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 137: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 138: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); } if (ts.isFunctionLike(node)) { return "Function"; @@ -18096,7 +18235,7 @@ var ts; function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { if (node) { var valueDeclaration; - if (node.kind === 201) { + if (node.kind === 202) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -18111,10 +18250,10 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 146) { + if (parameterType.kind === 147) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 141 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 142 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -18160,15 +18299,21 @@ var ts; ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); return !!resolveName(location, name, 107455, undefined, undefined); } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 8388608, undefined, undefined); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 152 || (n.parent.kind === 198 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 153 || (n.parent.kind === 199 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 223; + symbol.valueDeclaration.parent.kind !== 224; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -18205,6 +18350,7 @@ var ts; resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, + getReferencedValueDeclaration: getReferencedValueDeclaration, serializeTypeOfNode: serializeTypeOfNode, serializeParameterTypesOfNode: serializeParameterTypesOfNode, serializeReturnTypeOfNode: serializeReturnTypeOfNode @@ -18250,10 +18396,10 @@ var ts; } function isReservedWordInStrictMode(node) { return (node.parserContextFlags & 1) && - (node.originalKeywordKind >= 102 && node.originalKeywordKind <= 110); + (102 <= node.originalKeywordKind && node.originalKeywordKind <= 110); } function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) { + if (ts.getAncestor(identifier, 202) || ts.getAncestor(identifier, 175)) { return grammarErrorOnNode(identifier, message, arg0); } return false; @@ -18263,19 +18409,19 @@ var ts; var impotClause = node.importClause; if (impotClause.namedBindings) { var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 211) { + if (nameBindings.kind === 212) { var name_11 = nameBindings.name; - if (name_11.originalKeywordKind) { + if (isReservedWordInStrictMode(name_11)) { var nameText = ts.declarationNameToString(name_11); return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } } - else if (nameBindings.kind === 212) { + else if (nameBindings.kind === 213) { var reportError = false; for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { var element = _a[_i]; var name_12 = element.name; - if (name_12.originalKeywordKind) { + if (isReservedWordInStrictMode(name_12)) { var nameText = ts.declarationNameToString(name_12); reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -18291,20 +18437,20 @@ var ts; if (name && name.kind === 65 && isReservedWordInStrictMode(name)) { var nameText = ts.declarationNameToString(name); switch (node.kind) { + case 130: + case 199: + case 201: case 129: - case 198: - case 200: - case 128: - case 152: - case 202: + case 153: case 203: case 204: - return checkGrammarIdentifierInStrictMode(name); - case 201: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); case 205: + return checkGrammarIdentifierInStrictMode(name); + case 202: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); + case 206: return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 208: + case 209: return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } } @@ -18314,17 +18460,17 @@ var ts; if (typeName.kind === 65) { checkGrammarTypeNameInStrictMode(typeName); } - else if (typeName.kind === 126) { + else if (typeName.kind === 127) { checkGrammarTypeNameInStrictMode(typeName.right); checkGrammarTypeReferenceInStrictMode(typeName.left); } } - function checkGrammarHeritageClauseElementInStrictMode(expression) { + function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { if (expression && expression.kind === 65) { return checkGrammarIdentifierInStrictMode(expression); } - else if (expression && expression.kind === 155) { - checkGrammarHeritageClauseElementInStrictMode(expression.expression); + else if (expression && expression.kind === 156) { + checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); } } function checkGrammarIdentifierInStrictMode(node, nameText) { @@ -18357,7 +18503,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 136 || node.kind === 137) { + else if (node.kind === 137 || node.kind === 138) { 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); @@ -18367,26 +18513,26 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 136: case 137: - case 135: - case 132: - case 131: - case 134: + case 138: + case 136: case 133: - case 140: - case 201: + case 132: + case 135: + case 134: + case 141: case 202: - case 205: - case 204: - case 180: - case 200: case 203: + case 206: + case 205: + case 181: + case 201: + case 204: + case 210: case 209: - case 208: + case 216: case 215: - case 214: - case 129: + case 130: break; default: return false; @@ -18420,7 +18566,7 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 206 || node.parent.kind === 227) { + else if (node.parent.kind === 207 || node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -18429,10 +18575,10 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 206 || node.parent.kind === 227) { + else if (node.parent.kind === 207 || node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 129) { + else if (node.kind === 130) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; @@ -18445,10 +18591,10 @@ var ts; else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 201) { + else if (node.parent.kind === 202) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 129) { + else if (node.kind === 130) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -18457,13 +18603,13 @@ var ts; if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 201) { + else if (node.parent.kind === 202) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 129) { + else if (node.kind === 130) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 206) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -18471,7 +18617,7 @@ var ts; break; } } - if (node.kind === 135) { + if (node.kind === 136) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -18482,13 +18628,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 209 || node.kind === 208) && flags & 2) { + else if ((node.kind === 210 || node.kind === 209) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 202 && flags & 2) { + else if (node.kind === 203 && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 129 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 130 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -18551,7 +18697,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 163) { + if (node.kind === 164) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -18586,7 +18732,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { + if (parameter.type.kind !== 122 && parameter.type.kind !== 120) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -18618,7 +18764,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 175) { + if (arg.kind === 176) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -18689,11 +18835,11 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 127) { + if (node.kind !== 128) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 169 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 170 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -18720,26 +18866,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_13 = prop.name; - if (prop.kind === 175 || - name_13.kind === 127) { + if (prop.kind === 176 || + name_13.kind === 128) { checkGrammarComputedPropertyName(name_13); continue; } var currentKind = void 0; - if (prop.kind === 224 || prop.kind === 225) { + if (prop.kind === 225 || prop.kind === 226) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_13.kind === 7) { checkGrammarNumericLiteral(name_13); } currentKind = Property; } - else if (prop.kind === 134) { + else if (prop.kind === 135) { currentKind = Property; } - else if (prop.kind === 136) { + else if (prop.kind === 137) { currentKind = GetAccessor; } - else if (prop.kind === 137) { + else if (prop.kind === 138) { currentKind = SetAccesor; } else { @@ -18773,24 +18919,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 199) { + if (forInOrOfStatement.initializer.kind === 200) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 187 + var diagnostic = forInOrOfStatement.kind === 188 ? 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 = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 187 + var diagnostic = forInOrOfStatement.kind === 188 ? 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 === 187 + var diagnostic = forInOrOfStatement.kind === 188 ? 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); @@ -18813,10 +18959,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 136 && accessor.parameters.length) { + else if (kind === 137 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 137) { + else if (kind === 138) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -18841,7 +18987,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 127 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 128 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -18851,7 +18997,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 154) { + if (node.parent.kind === 155) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -18859,7 +19005,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 201) { + if (node.parent.kind === 202) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -18870,22 +19016,22 @@ 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 === 202) { + else if (node.parent.kind === 203) { 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 === 145) { + else if (node.parent.kind === 146) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 186: case 187: case 188: - case 184: + case 189: case 185: + case 186: return true; - case 194: + case 195: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -18897,9 +19043,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 194: + case 195: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 189 + var isMisplacedContinueLabel = node.kind === 190 && !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); @@ -18907,8 +19053,8 @@ var ts; return false; } break; - case 193: - if (node.kind === 190 && !node.label) { + case 194: + if (node.kind === 191 && !node.label) { return false; } break; @@ -18921,13 +19067,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 190 + var message = node.kind === 191 ? 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 === 190 + var message = node.kind === 191 ? 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); @@ -18936,10 +19082,10 @@ var ts; function checkGrammarBindingElement(node) { if (node.dotDotDotToken) { var elements = node.parent.elements; - if (node !== elements[elements.length - 1]) { + 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 === 151 || node.name.kind === 150) { + if (node.name.kind === 152 || node.name.kind === 151) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -18949,7 +19095,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 187 && node.parent.parent.kind !== 188) { + if (node.parent.parent.kind !== 188 && node.parent.parent.kind !== 189) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -18979,7 +19125,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 175) { + if (element.kind !== 176) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -18996,15 +19142,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 183: case 184: case 185: - case 192: case 186: + case 193: case 187: case 188: + case 189: return false; - case 194: + case 195: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -19020,7 +19166,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 167) { + if (expression.kind === 168) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -19039,7 +19185,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 127) { + if (node.name.kind === 128) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -19109,18 +19255,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 201) { + if (node.parent.kind === 202) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 203) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 145) { + else if (node.parent.kind === 146) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -19130,11 +19276,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 202 || + if (node.kind === 203 || + node.kind === 210 || node.kind === 209 || - node.kind === 208 || + node.kind === 216 || node.kind === 215 || - node.kind === 214 || (node.flags & 2) || (node.flags & (1 | 256))) { return false; @@ -19144,7 +19290,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 === 180) { + if (ts.isDeclaration(decl) || decl.kind === 181) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -19163,7 +19309,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 === 179 || node.parent.kind === 206 || node.parent.kind === 227) { + if (node.parent.kind === 180 || node.parent.kind === 207 || node.parent.kind === 228) { 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); @@ -19244,7 +19390,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 209); + ts.Debug.assert(aliasEmitInfo.node.kind === 210); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -19317,10 +19463,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 198) { + if (declaration.kind === 199) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 212 || declaration.kind === 213 || declaration.kind === 210) { + else if (declaration.kind === 213 || declaration.kind === 214 || declaration.kind === 211) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -19331,7 +19477,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 209) { + if (moduleElementEmitInfo.node.kind === 210) { moduleElementEmitInfo.isVisible = true; } else { @@ -19339,12 +19485,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 205) { + if (nodeToCheck.kind === 206) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 205) { + if (nodeToCheck.kind === 206) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -19432,39 +19578,39 @@ var ts; function emitType(type) { switch (type.kind) { case 112: - case 121: - case 119: - case 113: case 122: + case 120: + case 113: + case 123: case 99: case 8: return writeTextOfNode(currentSourceFile, type); case 177: - return emitHeritageClauseElement(type); - case 141: - return emitTypeReference(type); - case 144: - return emitTypeQuery(type); - case 146: - return emitArrayType(type); - case 147: - return emitTupleType(type); - case 148: - return emitUnionType(type); - case 149: - return emitParenType(type); + return emitExpressionWithTypeArguments(type); case 142: - case 143: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 145: + return emitTypeQuery(type); + case 147: + return emitArrayType(type); + case 148: + return emitTupleType(type); + case 149: + return emitUnionType(type); + case 150: + return emitParenType(type); + case 143: + case 144: + return emitSignatureDeclarationWithJsDocComments(type); + case 146: return emitTypeLiteral(type); case 65: return emitEntityName(type); - case 126: + case 127: return emitEntityName(type); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 208 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 209 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -19472,17 +19618,17 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 126 ? entityName.left : entityName.expression; - var right = entityName.kind === 126 ? entityName.right : entityName.name; + var left = entityName.kind === 127 ? entityName.left : entityName.expression; + var right = entityName.kind === 127 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } } - function emitHeritageClauseElement(node) { - if (ts.isSupportedHeritageClauseElement(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 155); + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 156); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -19586,10 +19732,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 208 || - (node.parent.kind === 227 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 209 || + (node.parent.kind === 228 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 227) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -19598,7 +19744,7 @@ var ts; }); } else { - if (node.kind === 209) { + if (node.kind === 210) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -19616,23 +19762,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 200: - return writeFunctionDeclaration(node); - case 180: - return writeVariableStatement(node); - case 202: - return writeInterfaceDeclaration(node); case 201: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 181: + return writeVariableStatement(node); case 203: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 202: + return writeClassDeclaration(node); case 204: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 205: + return writeEnumDeclaration(node); + case 206: return writeModuleDeclaration(node); - case 208: - return writeImportEqualsDeclaration(node); case 209: + return writeImportEqualsDeclaration(node); + case 210: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -19646,7 +19792,7 @@ var ts; if (node.flags & 256) { write("default "); } - else if (node.kind !== 202) { + else if (node.kind !== 203) { write("declare "); } } @@ -19690,7 +19836,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 211) { + if (namedBindings.kind === 212) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -19716,7 +19862,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 211) { + if (node.importClause.namedBindings.kind === 212) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -19767,7 +19913,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 206) { + while (node.body.kind !== 207) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -19828,7 +19974,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 134 && (node.parent.flags & 32); + return node.parent.kind === 135 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -19838,15 +19984,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 142 || - node.parent.kind === 143 || - (node.parent.parent && node.parent.parent.kind === 145)) { - ts.Debug.assert(node.parent.kind === 134 || - node.parent.kind === 133 || - node.parent.kind === 142 || + if (node.parent.kind === 143 || + node.parent.kind === 144 || + (node.parent.parent && node.parent.parent.kind === 146)) { + ts.Debug.assert(node.parent.kind === 135 || + node.parent.kind === 134 || node.parent.kind === 143 || - node.parent.kind === 138 || - node.parent.kind === 139); + node.parent.kind === 144 || + node.parent.kind === 139 || + node.parent.kind === 140); emitType(node.constraint); } else { @@ -19856,31 +20002,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 201: + case 202: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 202: + case 203: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 139: + case 140: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 138: + case 139: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 135: case 134: - case 133: if (node.parent.flags & 128) { 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 === 201) { + else if (node.parent.parent.kind === 202) { 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 200: + case 201: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -19905,12 +20051,12 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - if (ts.isSupportedHeritageClauseElement(node)) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 201) { + if (node.parent.parent.kind === 202) { 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; @@ -19987,16 +20133,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 198 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 199 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 132 || node.kind === 131) && ts.hasQuestionToken(node)) { + if ((node.kind === 133 || node.kind === 132) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 132 || node.kind === 131) && node.parent.kind === 145) { + if ((node.kind === 133 || node.kind === 132) && node.parent.kind === 146) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -20005,14 +20151,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 198) { + if (node.kind === 199) { 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 === 132 || node.kind === 131) { + else if (node.kind === 133 || node.kind === 132) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -20020,7 +20166,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 === 201) { + else if (node.parent.kind === 202) { 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 : @@ -20046,7 +20192,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 175) { + if (element.kind !== 176) { elements.push(element); } } @@ -20112,7 +20258,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 136 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 137 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -20125,7 +20271,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 136 + return accessor.kind === 137 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -20134,7 +20280,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 137) { + if (accessorWithTypeAnnotation.kind === 138) { if (accessorWithTypeAnnotation.parent.flags & 128) { 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 : @@ -20180,17 +20326,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 200) { + if (node.kind === 201) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 134) { + else if (node.kind === 135) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 200) { + if (node.kind === 201) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 135) { + else if (node.kind === 136) { write("constructor"); } else { @@ -20207,11 +20353,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 139 || node.kind === 143) { + if (node.kind === 140 || node.kind === 144) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 140) { + if (node.kind === 141) { write("["); } else { @@ -20220,20 +20366,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 140) { + if (node.kind === 141) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 142 || node.kind === 143; - if (isFunctionTypeOrConstructorType || node.parent.kind === 145) { + var isFunctionTypeOrConstructorType = node.kind === 143 || node.kind === 144; + if (isFunctionTypeOrConstructorType || node.parent.kind === 146) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 135 && !(node.flags & 32)) { + else if (node.kind !== 136 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -20244,23 +20390,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 139: + case 140: 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 138: + case 139: 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 140: + case 141: 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 135: case 134: - case 133: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -20268,7 +20414,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 === 201) { + else if (node.parent.kind === 202) { 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 : @@ -20281,7 +20427,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 200: + case 201: 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 : @@ -20313,9 +20459,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 142 || - node.parent.kind === 143 || - node.parent.parent.kind === 145) { + if (node.parent.kind === 143 || + node.parent.kind === 144 || + node.parent.parent.kind === 146) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -20331,22 +20477,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 135: + case 136: 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 139: + case 140: 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 138: + case 139: 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 135: case 134: - case 133: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -20354,7 +20500,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 === 201) { + else if (node.parent.parent.kind === 202) { 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 : @@ -20366,7 +20512,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 200: + case 201: 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 : @@ -20377,12 +20523,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 150) { + if (bindingPattern.kind === 151) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 151) { + else if (bindingPattern.kind === 152) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -20401,10 +20547,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 175) { + if (bindingElement.kind === 176) { write(" "); } - else if (bindingElement.kind === 152) { + else if (bindingElement.kind === 153) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -20427,39 +20573,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 200: - case 205: - case 208: - case 202: case 201: - case 203: - case 204: - return emitModuleElement(node, isModuleElementVisible(node)); - case 180: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 206: case 209: + case 203: + case 202: + case 204: + case 205: + return emitModuleElement(node, isModuleElementVisible(node)); + case 181: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 210: return emitModuleElement(node, !node.importClause); - case 215: + case 216: return emitExportDeclaration(node); + case 136: case 135: case 134: - case 133: return writeFunctionDeclaration(node); - case 139: - case 138: case 140: + case 139: + case 141: return emitSignatureDeclarationWithJsDocComments(node); - case 136: case 137: + case 138: return emitAccessorDeclaration(node); + case 133: case 132: - case 131: return emitPropertyDeclaration(node); - case 226: - return emitEnumMemberDeclaration(node); - case 214: - return emitExportAssignment(node); case 227: + return emitEnumMemberDeclaration(node); + case 215: + return emitExportAssignment(node); + case 228: return emitSourceFile(node); } } @@ -20505,13 +20651,13 @@ var ts; } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; - var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\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 compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; - var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { @@ -20566,6 +20712,7 @@ var ts; var increaseIndent = writer.increaseIndent; var decreaseIndent = writer.decreaseIndent; var currentSourceFile; + var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; var blockScopedVariableToGeneratedName; @@ -20590,7 +20737,7 @@ var ts; var scopeEmitStart = function (scopeDeclaration, scopeName) { }; var scopeEmitEnd = function () { }; var sourceMapData; - if (compilerOptions.sourceMap) { + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } if (root) { @@ -20608,6 +20755,7 @@ var ts; return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; + exportFunctionForFile = undefined; emit(sourceFile); } function isUniqueName(name) { @@ -20684,25 +20832,25 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 200: case 201: - case 174: + case 202: + case 175: generateNameForFunctionOrClassDeclaration(node); break; - case 205: + case 206: generateNameForModuleOrEnum(node); generateNameForNode(node.body); break; - case 204: + case 205: generateNameForModuleOrEnum(node); break; - case 209: + case 210: generateNameForImportDeclaration(node); break; - case 215: + case 216: generateNameForExportDeclaration(node); break; - case 214: + case 215: generateNameForExportAssignment(node); break; } @@ -20720,7 +20868,7 @@ var ts; var sourceMapNameIndexMap = {}; var sourceMapNameIndices = []; function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; } var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan = { @@ -20828,6 +20976,12 @@ var ts; sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } } function recordScopeNameOfNode(node, scopeName) { function recordScopeNameIndex(scopeNameIndex) { @@ -20839,7 +20993,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_17 = node.name; - if (!name_17 || name_17.kind !== 127) { + if (!name_17 || name_17.kind !== 128) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -20856,18 +21010,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 200 || - node.kind === 162 || + else if (node.kind === 201 || + node.kind === 163 || + node.kind === 135 || node.kind === 134 || - node.kind === 133 || - node.kind === 136 || node.kind === 137 || - node.kind === 205 || - node.kind === 201 || - node.kind === 204) { + node.kind === 138 || + node.kind === 206 || + node.kind === 202 || + node.kind === 205) { if (node.name) { var name_18 = node.name; - scopeName = name_18.kind === 127 + scopeName = name_18.kind === 128 ? ts.getTextOfNode(name_18) : node.name.text; } @@ -20886,18 +21040,22 @@ var ts; ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { if (typeof JSON !== "undefined") { - return JSON.stringify({ + var map_1 = { version: version, file: file, sourceRoot: sourceRoot, sources: sources, names: names, mappings: mappings - }); + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; function serializeStringArray(list) { var output = ""; for (var i = 0, n = list.length; i < n; i++) { @@ -20911,9 +21069,18 @@ var ts; } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); sourceMapDataList.push(sourceMapData); - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); } var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); sourceMapData = { @@ -20925,6 +21092,7 @@ var ts; inputSourceFileNames: [], sourceMapNames: [], sourceMapMappings: "", + sourceMapSourcesContent: undefined, sourceMapDecodedMappings: [] }; sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); @@ -20952,7 +21120,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 227) { + if (node.kind != 228) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); @@ -21125,7 +21293,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if (compilerOptions.sourceMap && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -21197,10 +21365,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 171) { + if (node.template.kind === 172) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 169 + var needsParens = templateSpan.expression.kind === 170 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -21224,7 +21392,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 161 + var needsParens = templateSpan.expression.kind !== 162 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -21257,11 +21425,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 157: case 158: - return parent.expression === template; case 159: - case 161: + return parent.expression === template; + case 160: + case 162: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -21269,7 +21437,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 169: + case 170: switch (expression.operatorToken.kind) { case 35: case 36: @@ -21281,8 +21449,8 @@ var ts; default: return -1; } - case 172: - case 170: + case 173: + case 171: return -1; default: return 1; @@ -21294,11 +21462,11 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 152); + ts.Debug.assert(node.kind !== 153); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 127) { + else if (node.kind === 128) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -21329,36 +21497,36 @@ var ts; function isNotExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 129: - case 198: - case 152: + case 130: + case 199: + case 153: + case 133: case 132: - case 131: - case 224: case 225: case 226: + case 227: + case 135: case 134: - case 133: - case 200: - case 136: - case 137: - case 162: case 201: + case 137: + case 138: + case 163: case 202: - case 204: + case 203: case 205: - case 208: - case 210: + case 206: + case 209: case 211: + case 212: return parent.name === node; - case 213: - case 217: - return parent.name === node || parent.propertyName === node; - case 190: - case 189: case 214: + case 218: + return parent.name === node || parent.propertyName === node; + case 191: + case 190: + case 215: return false; - case 194: + case 195: return node.parent.label === node; } } @@ -21466,11 +21634,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: - case 153: - case 155: + case 154: case 156: case 157: - case 161: + case 158: + case 162: return false; } return true; @@ -21487,14 +21655,14 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 173) { + if (e.kind === 174) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < length && elements[i].kind !== 173) { + while (i < length && elements[i].kind !== 174) { i++; } write("["); @@ -21515,7 +21683,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 173; + return node.kind === 174; } function emitArrayLiteral(node) { var elements = node.elements; @@ -21576,7 +21744,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 136 || property.kind === 137) { + if (property.kind === 137 || property.kind === 138) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -21627,13 +21795,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 224) { + if (property.kind === 225) { emit(property.initializer); } - else if (property.kind === 225) { + else if (property.kind === 226) { emitExpressionIdentifier(property.name); } - else if (property.kind === 134) { + else if (property.kind === 135) { emitFunctionDeclaration(property); } else { @@ -21665,7 +21833,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 === 127) { + if (properties[i].name.kind === 128) { numInitialNonComputedProperties = i; break; } @@ -21679,30 +21847,30 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(169, startsOnNewLine); + var result = ts.createSynthesizedNode(170, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(155); + var result = ts.createSynthesizedNode(156); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(156); + var result = ts.createSynthesizedNode(157); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 158 && expr.kind !== 7) { + if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(161); + var node = ts.createSynthesizedNode(162); node.expression = expr; return node; } @@ -21751,7 +21919,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 155 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 156 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -21799,10 +21967,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 173; }); + return ts.forEach(elements, function (e) { return e.kind === 174; }); } function skipParentheses(node) { - while (node.kind === 161 || node.kind === 160) { + while (node.kind === 162 || node.kind === 161) { node = node.expression; } return node; @@ -21823,12 +21991,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 155) { + if (expr.kind === 156) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 156) { + else if (expr.kind === 157) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -21869,7 +22037,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 155 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 156 && node.expression.expression.kind === 91; } if (superCall && languageVersion < 2) { write(".call("); @@ -21906,20 +22074,20 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 163) { - if (node.expression.kind === 160) { + if (!node.parent || node.parent.kind !== 164) { + if (node.expression.kind === 161) { var operand = node.expression.expression; - while (operand.kind == 160) { + while (operand.kind == 161) { operand = operand.expression; } - if (operand.kind !== 167 && + if (operand.kind !== 168 && + operand.kind !== 167 && operand.kind !== 166 && operand.kind !== 165 && - operand.kind !== 164 && - operand.kind !== 168 && - operand.kind !== 158 && - !(operand.kind === 157 && node.parent.kind === 158) && - !(operand.kind === 162 && node.parent.kind === 157)) { + operand.kind !== 169 && + operand.kind !== 159 && + !(operand.kind === 158 && node.parent.kind === 159) && + !(operand.kind === 163 && node.parent.kind === 158)) { emit(operand); return; } @@ -21944,9 +22112,25 @@ var ts; write(" "); emit(node.expression); } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 || node.parent.kind === 153); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 167) { + if (node.operand.kind === 168) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -21956,23 +22140,73 @@ var ts; } } emit(node.operand); + if (exportChanged) { + write(")"); + } } function emitPostfixUnaryExpression(node) { - emit(node.operand); - write(ts.tokenToString(node.operator)); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 38) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 228) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 207) { + return false; + } + else { + current = current.parent; + } + } } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 154 || node.left.kind === 153)) { - emitDestructuring(node, node.parent.kind === 182); + (node.left.kind === 155 || node.left.kind === 154)) { + emitDestructuring(node, node.parent.kind === 183); } else { + var exportChanged = node.operatorToken.kind >= 53 && + node.operatorToken.kind <= 64 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } emit(node.left); var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (exportChanged) { + write(")"); + } } } function synthesizedNodeStartsOnNewLine(node) { @@ -22000,7 +22234,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 179) { + if (node && node.kind === 180) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -22015,12 +22249,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 206) { - ts.Debug.assert(node.parent.kind === 205); + if (node.kind === 207) { + ts.Debug.assert(node.parent.kind === 206); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 206) { + if (node.kind === 207) { emitTempDeclarations(true); } decreaseIndent(); @@ -22029,7 +22263,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 179) { + if (node.kind === 180) { write(" "); emit(node); } @@ -22041,7 +22275,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 163); + emitParenthesizedIf(node.expression, node.expression.kind === 164); write(";"); } function emitIfStatement(node) { @@ -22054,7 +22288,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 183) { + if (node.elseStatement.kind === 184) { write(" "); emit(node.elseStatement); } @@ -22066,7 +22300,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 179) { + if (node.statement.kind === 180) { write(" "); } else { @@ -22082,7 +22316,10 @@ var ts; write(")"); emitEmbeddedStatement(node.statement); } - function emitStartOfVariableDeclarationList(decl, startPos) { + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } var tokenKind = 98; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { @@ -22094,28 +22331,53 @@ var ts; } if (startPos !== undefined) { emitToken(tokenKind, startPos); + write(" "); } else { switch (tokenKind) { case 98: - return write("var "); + write("var "); + break; case 104: - return write("let "); + write("let "); + break; case 70: - return write("const "); + write("const "); + break; } } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; } function emitForStatement(node) { var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 199) { + if (node.initializer && node.initializer.kind === 200) { var variableDeclarationList = node.initializer; - var declarations = variableDeclarationList.declarations; - emitStartOfVariableDeclarationList(declarations[0], endPos); - write(" "); - emitCommaList(declarations); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } } else if (node.initializer) { emit(node.initializer); @@ -22128,25 +22390,23 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 188) { + if (languageVersion < 2 && node.kind === 189) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - emitStartOfVariableDeclarationList(decl, endPos); - write(" "); - emit(decl); + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 187) { + if (node.kind === 188) { write(" in "); } else { @@ -22214,7 +22474,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 199) { + if (node.initializer.kind === 200) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -22236,7 +22496,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 153 || node.initializer.kind === 154) { + if (node.initializer.kind === 154 || node.initializer.kind === 155) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -22245,7 +22505,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 179) { + if (node.statement.kind === 180) { emitLines(node.statement.statements); } else { @@ -22257,7 +22517,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 190 ? 66 : 71, node.pos); + emitToken(node.kind === 191 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } @@ -22302,7 +22562,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 220) { + if (node.kind === 221) { write("case "); emit(node.expression); write(":"); @@ -22357,7 +22617,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 205); + } while (node && node.kind !== 206); return node; } function emitContainingModuleName(node) { @@ -22372,7 +22632,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2) { + else if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } } @@ -22382,7 +22642,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(166); + var result = ts.createSynthesizedNode(167); result.expression = zero; return result; } @@ -22390,19 +22650,33 @@ var ts; if (node.flags & 1) { writeLine(); emitStart(node); - if (node.flags & 256) { - if (languageVersion === 0) { - write("exports[\"default\"]"); + if (compilerOptions.module === 4) { + write(exportFunctionForFile + "(\""); + if (node.flags & 256) { + write("default"); } else { - write("exports.default"); + emitNodeWithoutSourceMap(node.name); } + write("\", "); + emitDeclarationName(node); + write(")"); } else { - emitModuleMemberName(node); + if (node.flags & 256) { + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); } - write(" = "); - emitDeclarationName(node); emitEnd(node); write(";"); } @@ -22412,21 +22686,40 @@ var ts; for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); + if (compilerOptions.module === 4) { + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(specifier.name); + write("\", "); + emitExpressionIdentifier(name); + write(")"); + emitEnd(specifier.name); + } + else { + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + } write(";"); } } } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; - var isDeclaration = (root.kind === 198 && !(ts.getCombinedNodeFlags(root) & 1)) || root.kind === 129; - if (root.kind === 169) { + var canDefineTempVariablesInPlace = false; + if (root.kind === 199) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 130) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 170) { emitAssignmentExpression(root); } else { @@ -22438,7 +22731,14 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 198 || name.parent.kind === 152)) { + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 || name.parent.kind === 153); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(name); + write("\", "); + } + if (isVariableDeclarationOrBindingElement) { emitModuleMemberName(name.parent); } else { @@ -22446,11 +22746,14 @@ var ts; } write(" = "); emit(value); + if (exportChanged) { + write(")"); + } } function ensureIdentifier(expr) { if (expr.kind !== 65) { var identifier = createTempVariable(0); - if (!isDeclaration) { + if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -22460,14 +22763,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(169); + var equals = ts.createSynthesizedNode(170); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(170); + var cond = ts.createSynthesizedNode(171); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -22487,7 +22790,7 @@ var ts; return createPropertyAccessExpression(object, propName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(157); + var call = ts.createSynthesizedNode(158); var sliceIdentifier = ts.createSynthesizedNode(65); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -22502,7 +22805,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 224 || p.kind === 225) { + if (p.kind === 225 || p.kind === 226) { var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -22515,8 +22818,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175) { - if (e.kind !== 173) { + if (e.kind !== 176) { + if (e.kind !== 174) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -22526,14 +22829,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 169 && target.operatorToken.kind === 53) { + if (target.kind === 170 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 154) { + if (target.kind === 155) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 153) { + else if (target.kind === 154) { emitArrayLiteralAssignment(target, value); } else { @@ -22547,14 +22850,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 161) { + if (root.parent.kind !== 162) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 161) { + if (root.parent.kind !== 162) { write(")"); } } @@ -22574,11 +22877,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 150) { + if (pattern.kind === 151) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 175) { + else if (element.kind !== 176) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -22605,22 +22908,31 @@ var ts; } else { renameNonTopLevelLetAndConst(node.name); - emitModuleMemberName(node); var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 187 && - node.parent.parent.kind !== 188) { + node.parent.parent.kind !== 188 && + node.parent.parent.kind !== 189) { initializer = createVoidZero(); } } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } } } function emitExportVariableAssignments(node) { - if (node.kind === 175) { + if (node.kind === 176) { return; } var name = node.name; @@ -22632,7 +22944,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 198 && node.parent.kind !== 152)) { + if (!node.parent || (node.parent.kind !== 199 && node.parent.kind !== 153)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -22641,24 +22953,24 @@ var ts; if (languageVersion >= 2 || ts.nodeIsSynthesized(node) || node.kind !== 65 || - (node.parent.kind !== 198 && node.parent.kind !== 152)) { + (node.parent.kind !== 199 && node.parent.kind !== 153)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { return; } - var list = ts.getAncestor(node, 199); - if (list.parent.kind === 180) { - var isSourceFileLevelBinding = list.parent.parent.kind === 227; - var isModuleLevelBinding = list.parent.parent.kind === 206; - var isFunctionLevelBinding = list.parent.parent.kind === 179 && ts.isFunctionLike(list.parent.parent.parent); + var list = ts.getAncestor(node, 200); + if (list.parent.kind === 181) { + var isSourceFileLevelBinding = list.parent.parent.kind === 228; + var isModuleLevelBinding = list.parent.parent.kind === 207; + var isFunctionLevelBinding = list.parent.parent.kind === 180 && ts.isFunctionLike(list.parent.parent.parent); if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { return; } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 227 + var parent = blockScopeContainer.kind === 228 ? blockScopeContainer : blockScopeContainer.parent; if (resolver.resolvesToSomeValue(parent, node.text)) { @@ -22673,18 +22985,27 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 227; + node.parent.kind === 228; } function emitVariableStatement(node) { + var startIsEmitted = true; if (!(node.flags & 1)) { - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); } else if (isES6ExportedDeclaration(node)) { write("export "); - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } } - emitCommaList(node.declarationList.declarations); - write(";"); if (languageVersion < 2 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } @@ -22785,12 +23106,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 136 ? "get " : "set "); + write(node.kind === 137 ? "get " : "set "); emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 163 && languageVersion >= 2; + return node.kind === 164 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -22801,10 +23122,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 162) { + if (node.kind === 163) { return !!node.name; } - if (node.kind === 200) { + if (node.kind === 201) { return !!node.name || languageVersion < 2; } } @@ -22812,7 +23133,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 134 && node.kind !== 133) { + if (node.kind !== 135 && node.kind !== 134) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { @@ -22832,10 +23153,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 200 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 201 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 134 && node.kind !== 133) { + if (node.kind !== 135 && node.kind !== 134) { emitTrailingComments(node); } } @@ -22882,7 +23203,7 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 179) { + else if (node.body.kind === 180) { emitBlockFunctionBody(node, node.body); } else { @@ -22907,10 +23228,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 160) { + while (current.kind === 161) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 154); + emitParenthesizedIf(body, current.kind === 155); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -22982,9 +23303,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 182) { + if (statement && statement.kind === 183) { var expr = statement.expression; - if (expr && expr.kind === 157) { + if (expr && expr.kind === 158) { var func = expr.expression; if (func && func.kind === 91) { return statement; @@ -23015,7 +23336,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 127) { + else if (memberName.kind === 128) { emitComputedPropertyName(memberName); } else { @@ -23023,11 +23344,11 @@ var ts; emitNodeWithoutSourceMap(memberName); } } - function getInitializedProperties(node, static) { + function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 132 && static === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -23067,11 +23388,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 178) { + if (member.kind === 179) { writeLine(); write(";"); } - else if (member.kind === 134 || node.kind === 133) { + else if (member.kind === 135 || node.kind === 134) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -23090,7 +23411,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 136 || member.kind === 137) { + else if (member.kind === 137 || member.kind === 138) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -23140,22 +23461,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 134 || node.kind === 133) && !member.body) { + if ((member.kind === 135 || node.kind === 134) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 134 || - member.kind === 136 || - member.kind === 137) { + else if (member.kind === 135 || + member.kind === 137 || + member.kind === 138) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 136) { + if (member.kind === 137) { write("get "); } - else if (member.kind === 137) { + else if (member.kind === 138) { write("set "); } if (member.asteriskToken) { @@ -23166,7 +23487,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 178) { + else if (member.kind === 179) { writeLine(); write(";"); } @@ -23187,10 +23508,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 135 && !member.body) { + if (member.kind === 136 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 132 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 133 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -23290,7 +23611,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 201) { + if (node.kind === 202) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { write("export "); @@ -23307,7 +23628,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 174; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -23338,15 +23659,6 @@ var ts; scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } } if (isClassExpressionWithStaticProperties) { for (var _a = 0; _a < staticProperties.length; _a++) { @@ -23383,8 +23695,10 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 201) { - write("var "); + if (node.kind === 202) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } emitDeclarationName(node); write(" = "); } @@ -23439,11 +23753,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 201) { + if (node.kind === 202) { write(";"); } emitEnd(node); - if (node.kind === 201) { + if (node.kind === 202) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -23517,13 +23831,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 134) { + if (member.kind === 135) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 132) { + if (member.kind !== 133) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -23553,7 +23867,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 132) { + if (member.kind !== 133) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -23592,26 +23906,26 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 134: - case 136: + case 135: case 137: - case 132: + case 138: + case 133: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 134: + case 135: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 201: - case 134: - case 137: + case 202: + case 135: + case 138: return true; } return false; @@ -23771,7 +24085,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 205) { + if (moduleDeclaration.body.kind === 206) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -23787,7 +24101,9 @@ var ts; if (!shouldEmit) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (!isModuleMergedWithES6Class(node)) { + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -23804,7 +24120,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 206) { + if (node.body.kind === 207) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -23837,6 +24153,14 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -23853,16 +24177,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 208) { + if (node.kind === 209) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 211) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 209 && node.importClause && !!node.importClause.name; + return node.kind === 210 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -23889,7 +24213,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 211) { + if (node.importClause.namedBindings.kind === 212) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -23915,7 +24239,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 208 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 209 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -23927,7 +24251,7 @@ var ts; write(" = "); } else { - var isNakedImport = 209 && !node.importClause; + var isNakedImport = 210 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -23990,6 +24314,7 @@ var ts; } } function emitExportDeclaration(node) { + ts.Debug.assert(compilerOptions.module !== 4); if (languageVersion < 2) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); @@ -24082,8 +24407,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 200 && - expression.kind !== 201) { + if (expression.kind !== 201 && + expression.kind !== 202) { write(";"); } emitEnd(node); @@ -24091,14 +24416,21 @@ var ts; else { writeLine(); emitStart(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); + if (compilerOptions.module === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); } else { - write(".default = "); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); } - emit(node.expression); write(";"); emitEnd(node); } @@ -24112,18 +24444,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 209: + case 210: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 208: - if (node.moduleReference.kind === 219 && resolver.isReferencedAliasDeclaration(node)) { + case 209: + if (node.moduleReference.kind === 220 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 215: + case 216: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -24141,7 +24473,7 @@ var ts; } } break; - case 214: + case 215: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -24161,6 +24493,375 @@ var ts; write("}"); } } + function getLocalNameForExternalImport(importNode) { + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + else { + return getGeneratedNameForNode(importNode); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 8) { + return getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 216 || + (importNode.kind === 210 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 216 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 216) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") " + exportFunctionForFile + "(n, m[n]);"); + decreaseIndent(); + writeLine(); + write("}"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 65 && node.flags & 256) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 65) { + emitNodeWithoutSourceMap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + if (i !== 0) { + write(", "); + } + if (local.kind === 202 || local.kind === 206) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 65 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.kind === 201) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 202) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 206 && shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 199 || node.kind === 153) { + if (shouldHoistVariable(node, false)) { + var name_21 = node.name; + if (name_21.kind === 65) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_21); + } + else { + ts.forEachChild(name_21, visit); + } + } + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 12288) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 228; + } + function isCurrentFileSystemExternalModule() { + return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction); + writeLine(); + emitExecute(node, startIndex); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSetters(exportStarFunction) { + write("setters:["); + for (var i = 0; i < externalImports.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var importNode = externalImports[i]; + var importVariableName = getLocalNameForExternalImport(importNode) || ""; + var parameterName = "_" + importVariableName; + write("function (" + parameterName + ") {"); + switch (importNode.kind) { + case 210: + if (!importNode.importClause) { + break; + } + case 209: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + var defaultName = importNode.kind === 210 + ? importNode.importClause.name + : importNode.name; + if (defaultName) { + emitExportMemberAssignments(defaultName); + writeLine(); + } + if (importNode.kind === 210 && + importNode.importClause.namedBindings) { + var namedBindings = importNode.importClause.namedBindings; + if (namedBindings.kind === 212) { + emitExportMemberAssignments(namedBindings.name); + writeLine(); + } + else { + for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportMemberAssignments(element.name || element.propertyName); + writeLine(); + } + } + } + decreaseIndent(); + break; + case 216: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + if (importNode.exportClause) { + for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + writeLine(); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(e.name); + write("\", " + parameterName + "[\""); + emitNodeWithoutSourceMap(e.propertyName || e.name); + write("\"]);"); + } + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + decreaseIndent(); + break; + } + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 216: + case 210: + case 209: + case 201: + continue; + } + writeLine(); + emit(statement); + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node, startIndex) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + write("System.register(["); + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } function emitAMDDependencies(node, includeNonAmdDependencies) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); @@ -24188,19 +24889,8 @@ var ts; } for (var _c = 0; _c < externalImports.length; _c++) { var importNode = externalImports[_c]; - var externalModuleName = ""; - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - externalModuleName = getLiteralText(moduleName); - } - var importAliasName = void 0; - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { - importAliasName = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - else { - importAliasName = getGeneratedNameForNode(importNode); - } + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); @@ -24313,28 +25003,33 @@ var ts; writeLine(); emitDetachedComments(node); var startIndex = emitDirectivePrologues(node.statements, false); - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024) { + writeLines(paramHelper); + paramEmitted = true; } - decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024) { - writeLines(paramHelper); - paramEmitted = true; - } - if (ts.isExternalModule(node)) { + if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { if (languageVersion >= 2) { emitES6Module(node, startIndex); } else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 4) { + emitSystemModule(node, startIndex); + } else if (compilerOptions.module === 3) { emitUMDModule(node, startIndex); } @@ -24371,21 +25066,21 @@ var ts; } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 202: - case 200: - case 209: - case 208: case 203: - case 214: - return false; - case 205: - return shouldEmitModuleDeclaration(node); + case 201: + case 210: + case 209: case 204: + case 215: + return false; + case 206: + return shouldEmitModuleDeclaration(node); + case 205: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 179 && + if (node.kind !== 180 && node.parent && - node.parent.kind === 163 && + node.parent.kind === 164 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -24397,13 +25092,13 @@ var ts; switch (node.kind) { case 65: return emitIdentifier(node, allowGeneratedIdentifiers); - case 129: + case 130: return emitParameter(node); + case 135: case 134: - case 133: return emitMethod(node); - case 136: case 137: + case 138: return emitAccessor(node); case 93: return emitThis(node); @@ -24423,139 +25118,139 @@ var ts; case 12: case 13: return emitLiteral(node); - case 171: - return emitTemplateExpression(node); - case 176: - return emitTemplateSpan(node); - case 126: - return emitQualifiedName(node); - case 150: - return emitObjectBindingPattern(node); - case 151: - return emitArrayBindingPattern(node); - case 152: - return emitBindingElement(node); - case 153: - return emitArrayLiteral(node); - case 154: - return emitObjectLiteral(node); - case 224: - return emitPropertyAssignment(node); - case 225: - return emitShorthandPropertyAssignment(node); - case 127: - return emitComputedPropertyName(node); - case 155: - return emitPropertyAccess(node); - case 156: - return emitIndexedAccess(node); - case 157: - return emitCallExpression(node); - case 158: - return emitNewExpression(node); - case 159: - return emitTaggedTemplateExpression(node); - case 160: - return emit(node.expression); - case 161: - return emitParenExpression(node); - case 200: - case 162: - case 163: - return emitFunctionDeclaration(node); - case 164: - return emitDeleteExpression(node); - case 165: - return emitTypeOfExpression(node); - case 166: - return emitVoidExpression(node); - case 167: - return emitPrefixUnaryExpression(node); - case 168: - return emitPostfixUnaryExpression(node); - case 169: - return emitBinaryExpression(node); - case 170: - return emitConditionalExpression(node); - case 173: - return emitSpreadElementExpression(node); case 172: - return emitYieldExpression(node); - case 175: - return; - case 179: - case 206: - return emitBlock(node); - case 180: - return emitVariableStatement(node); - case 181: - return write(";"); - case 182: - return emitExpressionStatement(node); - case 183: - return emitIfStatement(node); - case 184: - return emitDoStatement(node); - case 185: - return emitWhileStatement(node); - case 186: - return emitForStatement(node); - case 188: - case 187: - return emitForInOrForOfStatement(node); - case 189: - case 190: - return emitBreakOrContinueStatement(node); - case 191: - return emitReturnStatement(node); - case 192: - return emitWithStatement(node); - case 193: - return emitSwitchStatement(node); - case 220: - case 221: - return emitCaseOrDefaultClause(node); - case 194: - return emitLabelledStatement(node); - case 195: - return emitThrowStatement(node); - case 196: - return emitTryStatement(node); - case 223: - return emitCatchClause(node); - case 197: - return emitDebuggerStatement(node); - case 198: - return emitVariableDeclaration(node); - case 174: - return emitClassExpression(node); - case 201: - return emitClassDeclaration(node); - case 202: - return emitInterfaceDeclaration(node); - case 204: - return emitEnumDeclaration(node); + return emitTemplateExpression(node); + case 178: + return emitTemplateSpan(node); + case 127: + return emitQualifiedName(node); + case 151: + return emitObjectBindingPattern(node); + case 152: + return emitArrayBindingPattern(node); + case 153: + return emitBindingElement(node); + case 154: + return emitArrayLiteral(node); + case 155: + return emitObjectLiteral(node); + case 225: + return emitPropertyAssignment(node); case 226: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 128: + return emitComputedPropertyName(node); + case 156: + return emitPropertyAccess(node); + case 157: + return emitIndexedAccess(node); + case 158: + return emitCallExpression(node); + case 159: + return emitNewExpression(node); + case 160: + return emitTaggedTemplateExpression(node); + case 161: + return emit(node.expression); + case 162: + return emitParenExpression(node); + case 201: + case 163: + case 164: + return emitFunctionDeclaration(node); + case 165: + return emitDeleteExpression(node); + case 166: + return emitTypeOfExpression(node); + case 167: + return emitVoidExpression(node); + case 168: + return emitPrefixUnaryExpression(node); + case 169: + return emitPostfixUnaryExpression(node); + case 170: + return emitBinaryExpression(node); + case 171: + return emitConditionalExpression(node); + case 174: + return emitSpreadElementExpression(node); + case 173: + return emitYieldExpression(node); + case 176: + return; + case 180: + case 207: + return emitBlock(node); + case 181: + return emitVariableStatement(node); + case 182: + return write(";"); + case 183: + return emitExpressionStatement(node); + case 184: + return emitIfStatement(node); + case 185: + return emitDoStatement(node); + case 186: + return emitWhileStatement(node); + case 187: + return emitForStatement(node); + case 189: + case 188: + return emitForInOrForOfStatement(node); + case 190: + case 191: + return emitBreakOrContinueStatement(node); + case 192: + return emitReturnStatement(node); + case 193: + return emitWithStatement(node); + case 194: + return emitSwitchStatement(node); + case 221: + case 222: + return emitCaseOrDefaultClause(node); + case 195: + return emitLabelledStatement(node); + case 196: + return emitThrowStatement(node); + case 197: + return emitTryStatement(node); + case 224: + return emitCatchClause(node); + case 198: + return emitDebuggerStatement(node); + case 199: + return emitVariableDeclaration(node); + case 175: + return emitClassExpression(node); + case 202: + return emitClassDeclaration(node); + case 203: + return emitInterfaceDeclaration(node); case 205: - return emitModuleDeclaration(node); - case 209: - return emitImportDeclaration(node); - case 208: - return emitImportEqualsDeclaration(node); - case 215: - return emitExportDeclaration(node); - case 214: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 227: + return emitEnumMember(node); + case 206: + return emitModuleDeclaration(node); + case 210: + return emitImportDeclaration(node); + case 209: + return emitImportEqualsDeclaration(node); + case 216: + return emitExportDeclaration(node); + case 215: + return emitExportAssignment(node); + case 228: return emitSourceFileNode(node); } } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -24575,7 +25270,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 227 || node.pos !== node.parent.pos) { + if (node.parent.kind === 228 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -24587,7 +25282,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 227 || node.end !== node.parent.end) { + if (node.parent.kind === 228 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -24636,12 +25331,12 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); } @@ -24682,6 +25377,8 @@ var ts; ts.ioReadTime = 0; ts.ioWriteTime = 0; ts.version = "1.5.0"; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -24752,6 +25449,9 @@ var ts; } } } + var newLine = options.newLine === 0 ? carriageReturnLineFeed : + options.newLine === 1 ? lineFeed : + ts.sys.newLine; return { getSourceFile: getSourceFile, getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, @@ -24759,14 +25459,14 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return ts.sys.newLine; } + getNewLine: function () { return newLine; } }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program) { - var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + function getPreEmitDiagnostics(program, sourceFile) { + var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics()); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -25004,7 +25704,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 209 || node.kind === 208 || node.kind === 215) { + if (node.kind === 210 || node.kind === 209 || node.kind === 216) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -25024,7 +25724,7 @@ var ts; } } } - else if (node.kind === 205 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 206 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -25107,6 +25807,22 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); } } + if (options.inlineSourceMap) { + if (options.sourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.mapRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.sourceRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { if (options.mapRoot) { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option)); @@ -25125,15 +25841,15 @@ var ts; var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } if (options.module && languageVersion >= 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } if (options.outDir || options.sourceRoot || @@ -25202,98 +25918,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 184) { + if (node.parent.kind === 185) { return spanInPreviousNode(node); } - if (node.parent.kind === 186) { + if (node.parent.kind === 187) { return textSpan(node); } - if (node.parent.kind === 169 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 170 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind == 163 && node.parent.body == node) { + if (node.parent.kind == 164 && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 180: + case 181: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 198: - case 132: - case 131: - return spanInVariableDeclaration(node); - case 129: - return spanInParameterDeclaration(node); - case 200: - case 134: + case 199: case 133: - case 136: - case 137: + case 132: + return spanInVariableDeclaration(node); + case 130: + return spanInParameterDeclaration(node); + case 201: case 135: - case 162: + case 134: + case 137: + case 138: + case 136: case 163: + case 164: return spanInFunctionDeclaration(node); - case 179: + case 180: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 206: + case 207: return spanInBlock(node); - case 223: + case 224: return spanInBlock(node.block); - case 182: - return textSpan(node.expression); - case 191: - return textSpan(node.getChildAt(0), node.expression); - case 185: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 184: - return spanInNode(node.statement); - case 197: - return textSpan(node.getChildAt(0)); case 183: + return textSpan(node.expression); + case 192: + return textSpan(node.getChildAt(0), node.expression); + case 186: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 185: + return spanInNode(node.statement); + case 198: + return textSpan(node.getChildAt(0)); + case 184: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 195: + return spanInNode(node.statement); + case 191: + case 190: + return textSpan(node.getChildAt(0), node.label); + case 187: + return spanInForStatement(node); + case 188: + case 189: return textSpan(node, ts.findNextToken(node.expression, node)); case 194: - return spanInNode(node.statement); - case 190: - case 189: - return textSpan(node.getChildAt(0), node.label); - case 186: - return spanInForStatement(node); - case 187: - case 188: return textSpan(node, ts.findNextToken(node.expression, node)); - case 193: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 220: case 221: + case 222: return spanInNode(node.statements[0]); - case 196: + case 197: return spanInBlock(node.tryBlock); - case 195: + case 196: return textSpan(node, node.expression); - case 214: - return textSpan(node, node.expression); - case 208: - return textSpan(node, node.moduleReference); - case 209: - return textSpan(node, node.moduleSpecifier); case 215: + return textSpan(node, node.expression); + case 209: + return textSpan(node, node.moduleReference); + case 210: return textSpan(node, node.moduleSpecifier); - case 205: + case 216: + return textSpan(node, node.moduleSpecifier); + case 206: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 201: - case 204: - case 226: - case 157: - case 158: - return textSpan(node); - case 192: - return spanInNode(node.statement); case 202: + case 205: + case 227: + case 158: + case 159: + return textSpan(node); + case 193: + return spanInNode(node.statement); case 203: + case 204: return undefined; case 22: case 1: @@ -25320,10 +26036,10 @@ var ts; case 81: return spanInNextNode(node); default: - if (node.parent.kind === 224 && node.parent.name === node) { + if (node.parent.kind === 225 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 160 && node.parent.type === node) { + if (node.parent.kind === 161 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -25333,12 +26049,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 187 || - variableDeclaration.parent.parent.kind === 188) { + if (variableDeclaration.parent.parent.kind === 188 || + variableDeclaration.parent.parent.kind === 189) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 180; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 186 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -25384,7 +26100,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 201 && functionDeclaration.kind !== 135); + (functionDeclaration.parent.kind === 202 && functionDeclaration.kind !== 136); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -25404,23 +26120,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 205: + case 206: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 185: - case 183: - case 187: - case 188: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 186: + case 184: + case 188: + case 189: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 187: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 199) { + if (forStatement.initializer.kind === 200) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -25439,38 +26155,38 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 204: + case 205: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 201: + case 202: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 207: + case 208: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 206: + case 207: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 204: - case 201: + case 205: + case 202: return textSpan(node); - case 179: + case 180: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 223: - return spanInNode(node.parent.statements[node.parent.statements.length - 1]); + case 224: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 207: + case 208: var caseBlock = node.parent; - var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { - return spanInNode(lastClause.statements[lastClause.statements.length - 1]); + return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; default: @@ -25478,24 +26194,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 184) { + if (node.parent.kind === 185) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 162: - case 200: case 163: - case 134: - case 133: - case 136: - case 137: + case 201: + case 164: case 135: - case 185: - case 184: + case 134: + case 137: + case 138: + case 136: case 186: + case 185: + case 187: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -25503,19 +26219,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 224) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 225) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 160) { + if (node.parent.kind === 161) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 184) { + if (node.parent.kind === 185) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -25593,7 +26309,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 163; + return ts.isFunctionBlock(node) && node.parent.kind !== 164; } var depth = 0; var maxDepth = 20; @@ -25605,23 +26321,23 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 179: + case 180: if (!ts.isFunctionBlock(n)) { var parent_6 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_6.kind === 184 || - parent_6.kind === 187 || + if (parent_6.kind === 185 || parent_6.kind === 188 || + parent_6.kind === 189 || + parent_6.kind === 187 || + parent_6.kind === 184 || parent_6.kind === 186 || - parent_6.kind === 183 || - parent_6.kind === 185 || - parent_6.kind === 192 || - parent_6.kind === 223) { + parent_6.kind === 193 || + parent_6.kind === 224) { addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_6.kind === 196) { + if (parent_6.kind === 197) { var tryStatement = parent_6; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); @@ -25644,23 +26360,23 @@ var ts; }); break; } - case 206: { + case 207: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 201: case 202: - case 204: - case 154: - case 207: { + case 203: + case 205: + case 155: + case 208: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 153: + case 154: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -25686,10 +26402,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_21 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_21); + for (var name_22 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_22); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_21); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_22); if (!matches) { continue; } @@ -25700,14 +26416,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_21); + matches = patternMatcher.getMatches(containers, name_22); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_21, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_22, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -25744,7 +26460,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 127) { + else if (declaration.name.kind === 128) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -25761,7 +26477,7 @@ var ts; } return true; } - if (expression.kind === 155) { + if (expression.kind === 156) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -25772,7 +26488,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 127) { + if (declaration.name.kind === 128) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -25836,14 +26552,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 205: + case 206: do { current = current.parent; - } while (current.kind === 205); - case 201: - case 204: + } while (current.kind === 206); case 202: - case 200: + case 205: + case 203: + case 201: indent++; } current = current.parent; @@ -25854,26 +26570,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 180: + case 181: ts.forEach(node.declarationList.declarations, visit); break; - case 150: case 151: + case 152: ts.forEach(node.elements, visit); break; - case 215: + case 216: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 209: + case 210: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211) { + if (importClause.namedBindings.kind === 212) { childNodes.push(importClause.namedBindings); } else { @@ -25882,20 +26598,20 @@ var ts; } } break; - case 152: - case 198: + case 153: + case 199: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 201: - case 204: case 202: case 205: - case 200: - case 208: - case 213: - case 217: + case 203: + case 206: + case 201: + case 209: + case 214: + case 218: childNodes.push(node); break; } @@ -25930,17 +26646,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 201: - case 204: case 202: + case 205: + case 203: topLevelNodes.push(node); break; - case 205: + case 206: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 200: + case 201: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -25951,9 +26667,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 200) { - if (functionDeclaration.body && functionDeclaration.body.kind === 179) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 200 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 201) { + if (functionDeclaration.body && functionDeclaration.body.kind === 180) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -26006,7 +26722,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 129: + case 130: if (ts.isBindingPattern(node.name)) { break; } @@ -26014,34 +26730,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 135: case 134: - case 133: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 136: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 137: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 140: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 226: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 138: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 139: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 132: - case 131: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 141: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 227: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 200: + case 139: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 140: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 133: + case 132: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 201: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 198: - case 152: + case 199: + case 153: var variableDeclarationNode; - var name_22; - if (node.kind === 152) { - name_22 = node.name; + var name_23; + if (node.kind === 153) { + name_23 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 198) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 199) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -26049,24 +26765,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_22 = node.name; + name_23 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.variableElement); } - case 135: + case 136: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 217: - case 213: - case 208: - case 210: + case 218: + case 214: + case 209: case 211: + case 212: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -26096,17 +26812,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 227: + case 228: return createSourceFileItem(node); - case 201: - return createClassItem(node); - case 204: - return createEnumItem(node); case 202: - return createIterfaceItem(node); + return createClassItem(node); case 205: + return createEnumItem(node); + case 203: + return createIterfaceItem(node); + case 206: return createModuleItem(node); - case 200: + case 201: return createFunctionItem(node); } return undefined; @@ -26116,7 +26832,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 205) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 206) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -26128,7 +26844,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 === 179) { + if (node.body && node.body.kind === 180) { 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)); } @@ -26149,7 +26865,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 135 && member; + return member.kind === 136 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -26170,19 +26886,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 127; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 205) { + while (node.body.kind === 206) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 227 + return node.kind === 228 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -26673,14 +27389,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 157) { + if (argumentInfo.invocation.kind !== 158) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 65 ? expression - : expression.kind === 155 + : expression.kind === 156 ? expression.name : undefined; if (!name || !name.text) { @@ -26709,7 +27425,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 157 || node.parent.kind === 158) { + if (node.parent.kind === 158 || node.parent.kind === 159) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -26740,23 +27456,23 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 159) { + else if (node.kind === 10 && node.parent.kind === 160) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 159) { + else if (node.kind === 11 && node.parent.parent.kind === 160) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 171); + ts.Debug.assert(templateExpression.kind === 172); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 176 && node.parent.parent.parent.kind === 159) { + else if (node.parent.kind === 178 && node.parent.parent.parent.kind === 160) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 171); + ts.Debug.assert(templateExpression.kind === 172); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -26820,7 +27536,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 171) { + if (template.kind === 172) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -26829,7 +27545,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 227; n = n.parent) { + for (var n = node; n.kind !== 228; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -27010,39 +27726,39 @@ var ts; return false; } switch (n.kind) { - case 201: case 202: - case 204: - case 154: - case 150: - case 145: - case 179: - case 206: + case 203: + case 205: + case 155: + case 151: + case 146: + case 180: case 207: + case 208: return nodeEndsWith(n, 15, sourceFile); - case 223: + case 224: return isCompletedNode(n.block, sourceFile); - case 158: + case 159: if (!n.arguments) { return true; } - case 157: - case 161: - case 149: + case 158: + case 162: + case 150: return nodeEndsWith(n, 17, sourceFile); - case 142: case 143: + case 144: return isCompletedNode(n.type, sourceFile); - case 135: case 136: case 137: - case 200: - case 162: - case 134: - case 133: - case 139: case 138: + case 201: case 163: + case 135: + case 134: + case 140: + case 139: + case 164: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -27050,61 +27766,61 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 17, sourceFile); - case 205: + case 206: return n.body && isCompletedNode(n.body, sourceFile); - case 183: + case 184: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 182: + case 183: return isCompletedNode(n.expression, sourceFile); - case 153: - case 151: - case 156: - case 127: - case 147: + case 154: + case 152: + case 157: + case 128: + case 148: return nodeEndsWith(n, 19, sourceFile); - case 140: + case 141: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 220: case 221: + case 222: return false; - case 186: case 187: case 188: - case 185: + case 189: + case 186: return isCompletedNode(n.statement, sourceFile); - case 184: + case 185: var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 144: + case 145: return isCompletedNode(n.exprName, sourceFile); - case 165: - case 164: case 166: - case 172: + case 165: + case 167: case 173: + case 174: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 159: + case 160: return isCompletedNode(n.template, sourceFile); - case 171: + case 172: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 176: + case 178: return ts.nodeIsPresent(n.literal); - case 167: + case 168: return isCompletedNode(n.operand, sourceFile); - case 169: - return isCompletedNode(n.right, sourceFile); case 170: + return isCompletedNode(n.right, sourceFile); + case 171: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -27114,7 +27830,7 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last = children[children.length - 1]; + var last = ts.lastOrUndefined(children); if (last.kind === expectedLastToken) { return true; } @@ -27147,7 +27863,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 228 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 229 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -27253,7 +27969,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 227); + ts.Debug.assert(startNode !== undefined || n.kind === 228); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -27290,17 +28006,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 141 || node.kind === 157) { + if (node.kind === 142 || node.kind === 158) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 201 || node.kind === 202) { + if (ts.isFunctionLike(node) || node.kind === 202 || node.kind === 203) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 125; + return n.kind >= 0 && n.kind <= 126; } ts.isToken = isToken; function isWord(kind) { @@ -27353,7 +28069,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 129; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -27554,7 +28270,7 @@ var ts; if (isStarted) { if (trailingTrivia) { ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === 4; + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; } else { wasNewLine = false; @@ -27957,12 +28673,12 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 120]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 121]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 118]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 117, 106, 108, 120, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 119]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 117, 118, 106, 108, 121, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); @@ -27976,7 +28692,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 120, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 121, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -28050,37 +28766,37 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_23 in o) { - if (o[name_23] === rule) { - return name_23; + for (var name_24 in o) { + if (o[name_24] === rule) { + return name_24; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 186; + return context.contextNode.kind === 187; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 169: case 170: + case 171: return true; - case 152: - case 203: - case 208: - case 198: - case 129: - case 226: + case 153: + case 204: + case 209: + case 199: + case 130: + case 227: + case 133: case 132: - case 131: return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; - case 187: - return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; case 188: - return context.currentTokenSpan.kind === 125 || context.nextTokenSpan.kind === 125; + return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; + case 189: + return context.currentTokenSpan.kind === 126 || context.nextTokenSpan.kind === 126; } return false; }; @@ -28088,7 +28804,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 170; + return context.contextNode.kind === 171; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -28129,26 +28845,26 @@ var ts; return true; } switch (node.kind) { - case 179: + case 180: + case 208: + case 155: case 207: - case 154: - case 206: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 200: + case 201: + case 135: case 134: - case 133: - case 136: case 137: case 138: - case 162: - case 135: + case 139: case 163: - case 202: + case 136: + case 164: + case 203: return true; } return false; @@ -28158,53 +28874,53 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 201: case 202: - case 204: - case 145: + case 203: case 205: + case 146: + case 206: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 201: - case 205: - case 204: - case 179: - case 223: + case 202: case 206: - case 193: + case 205: + case 180: + case 224: + case 207: + case 194: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 183: - case 193: - case 186: + case 184: + case 194: case 187: case 188: + case 189: + case 186: + case 197: case 185: - case 196: - case 184: - case 192: - case 223: + case 193: + case 224: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 154; + return context.contextNode.kind === 155; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 157; + return context.contextNode.kind === 158; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 158; + return context.contextNode.kind === 159; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -28225,38 +28941,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 130; + return node.kind === 131; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 199 && + return context.currentTokenParent.kind === 200 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind != 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 205; + return context.contextNode.kind === 206; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 145; + return context.contextNode.kind === 146; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 && token.kind !== 25) { return false; } switch (parent.kind) { - case 141: - case 201: + case 142: case 202: - case 200: - case 162: + case 203: + case 201: case 163: + case 164: + case 135: case 134: - case 133: - case 138: case 139: - case 157: + case 140: case 158: + case 159: return true; default: return false; @@ -28267,7 +28983,7 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 166; + return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 167; }; return Rules; })(); @@ -28290,7 +29006,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 125 + 1; + this.mapRowLength = 126 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -28467,7 +29183,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 125; token++) { + for (var token = 0; token <= 126; token++) { result.push(token); } return result; @@ -28509,9 +29225,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(66, 125); + TokenRange.Keywords = TokenRange.FromRange(66, 126); TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 126]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); @@ -28519,7 +29235,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([65, 119, 121, 113, 122, 99, 112]); + TokenRange.TypeNames = TokenRange.FromTokens([65, 120, 122, 113, 123, 99, 112]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -28697,17 +29413,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 201: case 202: + case 203: return ts.rangeContainsRange(parent.members, node); - case 205: - var body = parent.body; - return body && body.kind === 179 && ts.rangeContainsRange(body.statements, node); - case 227: - case 179: case 206: + var body = parent.body; + return body && body.kind === 180 && ts.rangeContainsRange(body.statements, node); + case 228: + case 180: + case 207: return ts.rangeContainsRange(parent.statements, node); - case 223: + case 224: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -28796,6 +29512,8 @@ var ts; var previousRange; var previousParent; var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -28830,9 +29548,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 227 || - parent.kind === 220 || - parent.kind === 221) { + parent.kind === 228 || + parent.kind === 221 || + parent.kind === 222) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -28850,7 +29568,9 @@ var ts; } var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0) ? options.IndentSize : 0; if (effectiveParentStartLine === startLine) { - indentation = parentDynamicIndentation.getIndentation(); + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); } return { @@ -28863,18 +29583,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 201: return 69; - case 202: return 103; - case 200: return 83; - case 204: return 204; - case 136: return 116; - case 137: return 120; - case 134: + case 202: return 69; + case 203: return 103; + case 201: return 83; + case 205: return 205; + case 137: return 116; + case 138: return 121; + case 135: if (node.asteriskToken) { return 35; } - case 132: - case 129: + case 133: + case 130: return node.name.kind; } } @@ -28981,7 +29701,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 130 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 131 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -29060,7 +29780,6 @@ var ts; if (!ts.rangeContainsRange(originalRange, triviaItem)) { continue; } - var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line; switch (triviaItem.kind) { case 3: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); @@ -29083,6 +29802,8 @@ var ts; if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; } } formattingScanner.advance(); @@ -29270,20 +29991,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 179: - case 206: + case 180: + case 207: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 135: - case 200: - case 162: - case 134: - case 133: + case 136: + case 201: case 163: + case 135: + case 134: + case 164: if (node.typeParameters === list) { return 24; } @@ -29291,8 +30012,8 @@ var ts; return 16; } break; - case 157: case 158: + case 159: if (node.typeArguments === list) { return 24; } @@ -29300,7 +30021,7 @@ var ts; return 16; } break; - case 141: + case 142: if (node.typeArguments === list) { return 24; } @@ -29392,7 +30113,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 169) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 170) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -29482,7 +30203,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 227 || !parentAndChildShareLine); + (parent.kind === 228 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -29506,7 +30227,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 183 && parent.elseStatement === child) { + if (parent.kind === 184 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -29518,23 +30239,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 141: + case 142: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 154: + case 155: return node.parent.properties; - case 153: + case 154: return node.parent.elements; - case 200: - case 162: + case 201: case 163: + case 164: + case 135: case 134: - case 133: - case 138: - case 139: { + case 139: + case 140: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -29545,8 +30266,8 @@ var ts; } break; } - case 158: - case 157: { + case 159: + case 158: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -29615,28 +30336,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 201: case 202: - case 204: - case 153: - case 179: - case 206: + case 203: + case 205: case 154: - case 145: - case 147: - case 207: - case 221: - case 220: - case 161: - case 157: - case 158: case 180: - case 198: - case 214: - case 191: - case 170: + case 207: + case 155: + case 146: + case 148: + case 208: + case 222: + case 221: + case 162: + case 158: + case 159: + case 181: + case 199: + case 215: + case 192: + case 171: + case 152: case 151: - case 150: return true; } return false; @@ -29646,22 +30367,22 @@ var ts; return true; } switch (parent) { - case 184: case 185: - case 187: - case 188: case 186: - case 183: - case 200: - case 162: - case 134: - case 133: - case 138: + case 188: + case 189: + case 187: + case 184: + case 201: case 163: case 135: + case 134: + case 139: + case 164: case 136: case 137: - return child !== 179; + case 138: + return child !== 180; default: return false; } @@ -29671,7 +30392,7 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -29763,7 +30484,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(228, nodes.pos, nodes.end, 1024, this); + var list = createNode(229, nodes.pos, nodes.end, 1024, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -29782,7 +30503,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 126) { + if (this.kind >= 127) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -29827,7 +30548,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 126) { + if (child.kind < 127) { return child; } return child.getFirstToken(sourceFile); @@ -29837,7 +30558,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 126) { + if (child.kind < 127) { return child; } return child.getLastToken(sourceFile); @@ -29883,7 +30604,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 129) { + if (canUseParsedParamTagComments && declaration.kind === 130) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -29891,13 +30612,13 @@ var ts; } }); } - if (declaration.kind === 205 && declaration.body.kind === 205) { + if (declaration.kind === 206 && declaration.body.kind === 206) { return; } - while (declaration.kind === 205 && declaration.parent.kind === 205) { + while (declaration.kind === 206 && declaration.parent.kind === 206) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 198 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -30202,9 +30923,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 127) { + if (declaration.name.kind === 128) { var expr = declaration.name.expression; - if (expr.kind === 155) { + if (expr.kind === 156) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -30224,9 +30945,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 200: + case 201: + case 135: case 134: - case 133: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -30243,62 +30964,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 201: case 202: case 203: case 204: case 205: - case 208: - case 217: - case 213: - case 208: - case 210: - case 211: - case 136: - case 137: - case 145: - addDeclaration(node); - case 135: - case 180: - case 199: - case 150: - case 151: case 206: + case 209: + case 218: + case 214: + case 209: + case 211: + case 212: + case 137: + case 138: + case 146: + addDeclaration(node); + case 136: + case 181: + case 200: + case 151: + case 152: + case 207: ts.forEachChild(node, visit); break; - case 179: + case 180: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 129: + case 130: if (!(node.flags & 112)) { break; } - case 198: - case 152: + case 199: + case 153: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 226: + case 227: + case 133: case 132: - case 131: addDeclaration(node); break; - case 215: + case 216: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 209: + case 210: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211) { + if (importClause.namedBindings.kind === 212) { addDeclaration(importClause.namedBindings); } else { @@ -30420,7 +31141,8 @@ var ts; ClassificationTypeNames.interfaceName = "interface name"; ClassificationTypeNames.moduleName = "module name"; ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAlias = "type alias name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; return ClassificationTypeNames; })(); ts.ClassificationTypeNames = ClassificationTypeNames; @@ -30436,14 +31158,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 162) { + if (declaration.kind === 163) { return true; } - if (declaration.kind !== 198 && declaration.kind !== 200) { + if (declaration.kind !== 199 && declaration.kind !== 201) { return false; } for (var parent_7 = declaration.parent; !ts.isFunctionBlock(parent_7); parent_7 = parent_7.parent) { - if (parent_7.kind === 227 || parent_7.kind === 206) { + if (parent_7.kind === 228 || parent_7.kind === 207) { return false; } } @@ -30741,7 +31463,7 @@ var ts; else { if (token === 65) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -30750,7 +31472,7 @@ var ts; } else if (token === 53) { token = scanner.scan(); - if (token === 118) { + if (token === 119) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -30775,7 +31497,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -30789,7 +31511,7 @@ var ts; token = scanner.scan(); if (token === 65) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -30809,7 +31531,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -30819,7 +31541,7 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -30840,7 +31562,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 194 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 195 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -30849,16 +31571,16 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 && - (node.parent.kind === 190 || node.parent.kind === 189) && + (node.parent.kind === 191 || node.parent.kind === 190) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 && - node.parent.kind === 194 && + node.parent.kind === 195 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 194; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 195; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -30869,25 +31591,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 126 && node.parent.right === node; + return node.parent.kind === 127 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 155 && node.parent.name === node; + return node && node.parent && node.parent.kind === 156 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 157 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 159 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 205 && node.parent.name === node; + return node.parent.kind === 206 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 && @@ -30895,22 +31617,22 @@ var ts; } function isNameOfPropertyAssignment(node) { return (node.kind === 65 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 224 || node.parent.kind === 225) && node.parent.name === node; + (node.parent.kind === 225 || node.parent.kind === 226) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 132: - case 131: - case 224: - case 226: - case 134: case 133: - case 136: + case 132: + case 225: + case 227: + case 135: + case 134: case 137: - case 205: + case 138: + case 206: return node.parent.name === node; - case 156: + case 157: return node.parent.argumentExpression === node; } } @@ -30948,7 +31670,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 66; i <= 125; i++) { + for (var i = 66; i <= 126; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -30963,17 +31685,17 @@ var ts; return undefined; } switch (node.kind) { - case 227: + case 228: + case 135: case 134: - case 133: - case 200: - case 162: - case 136: - case 137: case 201: + case 163: + case 137: + case 138: case 202: - case 204: + case 203: case 205: + case 206: return node; } } @@ -30981,38 +31703,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 205: return ScriptElementKind.moduleElement; - case 201: return ScriptElementKind.classElement; - case 202: return ScriptElementKind.interfaceElement; - case 203: return ScriptElementKind.typeElement; - case 204: return ScriptElementKind.enumElement; - case 198: + case 206: return ScriptElementKind.moduleElement; + case 202: return ScriptElementKind.classElement; + case 203: return ScriptElementKind.interfaceElement; + case 204: return ScriptElementKind.typeElement; + case 205: return ScriptElementKind.enumElement; + case 199: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 200: return ScriptElementKind.functionElement; - case 136: return ScriptElementKind.memberGetAccessorElement; - case 137: return ScriptElementKind.memberSetAccessorElement; + case 201: return ScriptElementKind.functionElement; + case 137: return ScriptElementKind.memberGetAccessorElement; + case 138: return ScriptElementKind.memberSetAccessorElement; + case 135: case 134: - case 133: return ScriptElementKind.memberFunctionElement; + case 133: case 132: - case 131: return ScriptElementKind.memberVariableElement; - case 140: return ScriptElementKind.indexSignatureElement; - case 139: return ScriptElementKind.constructSignatureElement; - case 138: return ScriptElementKind.callSignatureElement; - case 135: return ScriptElementKind.constructorImplementationElement; - case 128: return ScriptElementKind.typeParameterElement; - case 226: return ScriptElementKind.variableElement; - case 129: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 208: - case 213: - case 210: - case 217: + case 141: return ScriptElementKind.indexSignatureElement; + case 140: return ScriptElementKind.constructSignatureElement; + case 139: return ScriptElementKind.callSignatureElement; + case 136: return ScriptElementKind.constructorImplementationElement; + case 129: return ScriptElementKind.typeParameterElement; + case 227: return ScriptElementKind.variableElement; + case 130: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 209: + case 214: case 211: + case 218: + case 212: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -31154,44 +31876,44 @@ var ts; return false; } switch (node.kind) { - case 208: + case 209: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 201: + case 202: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 222: + case 223: var heritageClause = node; if (heritageClause.token === 102) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 202: + case 203: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205: + case 206: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 203: + case 204: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 134: - case 133: case 135: + case 134: case 136: case 137: - case 162: - case 200: + case 138: case 163: - case 200: + case 201: + case 164: + case 201: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -31199,20 +31921,20 @@ var ts; return true; } break; - case 180: + case 181: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 198: + case 199: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 157: case 158: + case 159: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -31220,7 +31942,7 @@ var ts; return true; } break; - case 129: + case 130: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -31236,17 +31958,17 @@ var ts; return true; } break; - case 132: + case 133: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204: + case 205: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 160: + case 161: 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 130: + case 131: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -31362,11 +32084,11 @@ var ts; } var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 155) { + if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 156) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 126) { + else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 127) { node = contextToken.parent.left; isRightOfDot = true; } @@ -31389,7 +32111,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 || node.kind === 126 || node.kind === 155) { + if (node.kind === 65 || node.kind === 127 || node.kind === 156) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -31426,11 +32148,11 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 210)) { + else if (ts.getAncestor(contextToken, 211)) { isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 209); + var importDeclaration = ts.getAncestor(contextToken, 210); ts.Debug.assert(importDeclaration !== undefined); var exports_2; if (importDeclaration.moduleSpecifier) { @@ -31475,7 +32197,7 @@ var ts; function showCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 212; + return node.parent.kind === 213; } } return false; @@ -31485,35 +32207,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 157 - || containingNodeKind === 135 - || containingNodeKind === 158 - || containingNodeKind === 153 - || containingNodeKind === 169; + return containingNodeKind === 158 + || containingNodeKind === 136 + || containingNodeKind === 159 + || containingNodeKind === 154 + || containingNodeKind === 170; case 16: - return containingNodeKind === 157 - || containingNodeKind === 135 - || containingNodeKind === 158 - || containingNodeKind === 161; + return containingNodeKind === 158 + || containingNodeKind === 136 + || containingNodeKind === 159 + || containingNodeKind === 162; case 18: - return containingNodeKind === 153; + return containingNodeKind === 154; case 117: + case 118: return true; case 20: - return containingNodeKind === 205; + return containingNodeKind === 206; case 14: - return containingNodeKind === 201; + return containingNodeKind === 202; case 53: - return containingNodeKind === 198 - || containingNodeKind === 169; + return containingNodeKind === 199 + || containingNodeKind === 170; case 11: - return containingNodeKind === 171; + return containingNodeKind === 172; case 12: - return containingNodeKind === 176; + return containingNodeKind === 178; case 108: case 106: case 107: - return containingNodeKind === 132; + return containingNodeKind === 133; } switch (previousToken.getText()) { case "public": @@ -31546,7 +32269,7 @@ var ts; switch (previousToken.kind) { case 14: case 23: - if (parent_8 && parent_8.kind === 154) { + if (parent_8 && parent_8.kind === 155) { return parent_8; } break; @@ -31556,16 +32279,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 162: case 163: - case 200: + case 164: + case 201: + case 135: case 134: - case 133: - case 136: case 137: case 138: case 139: case 140: + case 141: return true; } return false; @@ -31575,56 +32298,56 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 198 || - containingNodeKind === 199 || - containingNodeKind === 180 || - containingNodeKind === 204 || - isFunction(containingNodeKind) || - containingNodeKind === 201 || + return containingNodeKind === 199 || containingNodeKind === 200 || + containingNodeKind === 181 || + containingNodeKind === 205 || + isFunction(containingNodeKind) || containingNodeKind === 202 || - containingNodeKind === 151 || - containingNodeKind === 150; + containingNodeKind === 201 || + containingNodeKind === 203 || + containingNodeKind === 152 || + containingNodeKind === 151; case 20: - return containingNodeKind === 151; + return containingNodeKind === 152; case 18: - return containingNodeKind === 151; + return containingNodeKind === 152; case 16: - return containingNodeKind === 223 || + return containingNodeKind === 224 || isFunction(containingNodeKind); case 14: - return containingNodeKind === 204 || - containingNodeKind === 202 || - containingNodeKind === 145 || - containingNodeKind === 150; + return containingNodeKind === 205 || + containingNodeKind === 203 || + containingNodeKind === 146 || + containingNodeKind === 151; case 22: - return containingNodeKind === 131 && + return containingNodeKind === 132 && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 202 || - previousToken.parent.parent.kind === 145); + (previousToken.parent.parent.kind === 203 || + previousToken.parent.parent.kind === 146); case 24: - return containingNodeKind === 201 || - containingNodeKind === 200 || - containingNodeKind === 202 || + return containingNodeKind === 202 || + containingNodeKind === 201 || + containingNodeKind === 203 || isFunction(containingNodeKind); case 109: - return containingNodeKind === 132; + return containingNodeKind === 133; case 21: - return containingNodeKind === 129 || - containingNodeKind === 135 || + return containingNodeKind === 130 || + containingNodeKind === 136 || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 151); + previousToken.parent.parent.kind === 152); case 108: case 106: case 107: - return containingNodeKind === 129; + return containingNodeKind === 130; case 69: case 77: case 103: case 83: case 98: case 116: - case 120: + case 121: case 85: case 104: case 70: @@ -31659,7 +32382,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 212) { + importDeclaration.importClause.namedBindings.kind === 213) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -31676,7 +32399,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 224 && m.kind !== 225) { + if (m.kind !== 225 && m.kind !== 226) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -31722,10 +32445,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_24 in nameTable) { - if (!allNames[name_24]) { - allNames[name_24] = name_24; - var displayName = getCompletionEntryDisplayName(name_24, target, true); + for (var name_25 in nameTable) { + if (!allNames[name_25]) { + allNames[name_25] = name_25; + var displayName = getCompletionEntryDisplayName(name_25, target, true); if (displayName) { var entry = { name: displayName, @@ -31880,22 +32603,6 @@ var ts; } return ScriptElementKind.unknown; } - function getTypeKind(type) { - var flags = type.getFlags(); - if (flags & 128) - return ScriptElementKind.enumElement; - if (flags & 1024) - return ScriptElementKind.classElement; - if (flags & 2048) - return ScriptElementKind.interfaceElement; - if (flags & 512) - return ScriptElementKind.typeParameterElement; - if (flags & 1048703) - return ScriptElementKind.primitiveType; - if (flags & 256) - return ScriptElementKind.primitiveType; - return ScriptElementKind.unknown; - } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) @@ -31917,14 +32624,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 155) { + if (location.parent && location.parent.kind === 156) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 157 || location.kind === 158) { + if (location.kind === 158 || location.kind === 159) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -31936,7 +32643,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 158 || callExpression.expression.kind === 91; + var useConstructSignatures = callExpression.kind === 159 || callExpression.expression.kind === 91; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -31984,21 +32691,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 114 && location.parent.kind === 135)) { + (location.kind === 114 && location.parent.kind === 136)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 135 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 136 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 135) { + if (functionDeclaration.kind === 136) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 138 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -32021,7 +32728,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(123)); + displayParts.push(ts.keywordPart(124)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -32041,7 +32748,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(117)); + var declaration = ts.getDeclarationOfKind(symbol, 206); + var isNamespace = declaration && declaration.name && declaration.name.kind === 65; + displayParts.push(ts.keywordPart(isNamespace ? 118 : 117)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -32060,13 +32769,13 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 139) { + if (signatureDeclaration.kind === 140) { displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 138 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 139 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); @@ -32075,7 +32784,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 226) { + if (declaration.kind === 227) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -32091,13 +32800,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 208) { + if (declaration.kind === 209) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(118)); + displayParts.push(ts.keywordPart(119)); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); @@ -32221,8 +32930,8 @@ var ts; if (!symbol) { switch (node.kind) { case 65: - case 155: - case 126: + case 156: + case 127: case 93: case 91: var type = typeChecker.getTypeAtLocation(node); @@ -32257,6 +32966,59 @@ var ts; containerName: containerName }; } + function getDefinitionFromSymbol(symbol, node) { + var typeChecker = program.getTypeChecker(); + var result = []; + var declarations = symbol.getDeclarations(); + var symbolName = typeChecker.symbolToString(symbol); + var symbolKind = getSymbolKind(symbol, node); + var containerSymbol = symbol.parent; + var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isNewExpressionTarget(location) || location.kind === 114) { + if (symbol.flags & 32) { + var classDeclaration = symbol.getDeclarations()[0]; + ts.Debug.assert(classDeclaration && classDeclaration.kind === 202); + return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + } + } + return false; + } + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + } + return false; + } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 136) || + (!selectConstructors && (d.kind === 201 || d.kind === 135 || d.kind === 134))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; + } + } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -32295,7 +33057,7 @@ var ts; symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 225) { + if (node.parent.kind === 226) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -32306,56 +33068,37 @@ var ts; var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); } - var result = []; - var declarations = symbol.getDeclarations(); - var symbolName = typeChecker.symbolToString(symbol); - var symbolKind = getSymbolKind(symbol, node); - var containerSymbol = symbol.parent; - var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - ts.forEach(declarations, function (declaration) { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); + return getDefinitionFromSymbol(symbol, node); + } + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; } - return result; - function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 114) { - if (symbol.flags & 32) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 201); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); - } - } - return false; + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; } - function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); - } - return false; + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 135) || - (!selectConstructors && (d.kind === 200 || d.kind === 134 || d.kind === 133))) { - declarations.push(d); - if (d.body) - definition = d; + if (type.flags & 16384) { + var result = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); } }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - return false; + return result; } + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(type.symbol, node); } function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); @@ -32438,74 +33181,74 @@ var ts; switch (node.kind) { case 84: case 76: - if (hasKind(node.parent, 183)) { + if (hasKind(node.parent, 184)) { return getIfElseOccurrences(node.parent); } break; case 90: - if (hasKind(node.parent, 191)) { + if (hasKind(node.parent, 192)) { return getReturnOccurrences(node.parent); } break; case 94: - if (hasKind(node.parent, 195)) { + if (hasKind(node.parent, 196)) { return getThrowOccurrences(node.parent); } break; case 68: - if (hasKind(parent(parent(node)), 196)) { + if (hasKind(parent(parent(node)), 197)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96: case 81: - if (hasKind(parent(node), 196)) { + if (hasKind(parent(node), 197)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92: - if (hasKind(node.parent, 193)) { + if (hasKind(node.parent, 194)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67: case 73: - if (hasKind(parent(parent(parent(node))), 193)) { + if (hasKind(parent(parent(parent(node))), 194)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66: case 71: - if (hasKind(node.parent, 190) || hasKind(node.parent, 189)) { + if (hasKind(node.parent, 191) || hasKind(node.parent, 190)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82: - if (hasKind(node.parent, 186) || - hasKind(node.parent, 187) || - hasKind(node.parent, 188)) { + if (hasKind(node.parent, 187) || + hasKind(node.parent, 188) || + hasKind(node.parent, 189)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100: case 75: - if (hasKind(node.parent, 185) || hasKind(node.parent, 184)) { + if (hasKind(node.parent, 186) || hasKind(node.parent, 185)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114: - if (hasKind(node.parent, 135)) { + if (hasKind(node.parent, 136)) { return getConstructorOccurrences(node.parent); } break; case 116: - case 120: - if (hasKind(node.parent, 136) || hasKind(node.parent, 137)) { + case 121: + if (hasKind(node.parent, 137) || hasKind(node.parent, 138)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 180)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 181)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -32517,10 +33260,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 195) { + if (node.kind === 196) { statementAccumulator.push(node); } - else if (node.kind === 196) { + else if (node.kind === 197) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -32542,10 +33285,10 @@ var ts; var child = throwStatement; while (child.parent) { var parent_9 = child.parent; - if (ts.isFunctionBlock(parent_9) || parent_9.kind === 227) { + if (ts.isFunctionBlock(parent_9) || parent_9.kind === 228) { return parent_9; } - if (parent_9.kind === 196) { + if (parent_9.kind === 197) { var tryStatement = parent_9; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -32560,7 +33303,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 190 || node.kind === 189) { + if (node.kind === 191 || node.kind === 190) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -32576,15 +33319,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 193: - if (statement.kind === 189) { + case 194: + if (statement.kind === 190) { continue; } - case 186: case 187: case 188: + case 189: + case 186: case 185: - case 184: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -32601,18 +33344,18 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 201 || - (declaration.kind === 129 && hasKind(container, 135)))) { + if (!(container.kind === 202 || + (declaration.kind === 130 && hasKind(container, 136)))) { return undefined; } } else if (modifier === 109) { - if (container.kind !== 201) { + if (container.kind !== 202) { return undefined; } } else if (modifier === 78 || modifier === 115) { - if (!(container.kind === 206 || container.kind === 227)) { + if (!(container.kind === 207 || container.kind === 228)) { return undefined; } } @@ -32623,18 +33366,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 206: - case 227: + case 207: + case 228: nodes = container.statements; break; - case 135: + case 136: nodes = container.parameters.concat(container.parent.members); break; - case 201: + case 202: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 135 && member; + return member.kind === 136 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -32682,13 +33425,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 136); tryPushAccessorKeyword(accessorDeclaration.symbol, 137); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 120); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 121); }); } } } @@ -32705,7 +33448,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { - if (loopNode.kind === 184) { + if (loopNode.kind === 185) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100)) { @@ -32726,13 +33469,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 186: case 187: case 188: - case 184: + case 189: case 185: + case 186: return getLoopBreakContinueOccurrences(owner); - case 193: + case 194: return getSwitchCaseDefaultOccurrences(owner); } } @@ -32782,7 +33525,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 179))) { + if (!(func && hasKind(func.body, 180))) { return undefined; } var keywords = []; @@ -32796,7 +33539,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 183) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 184) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -32807,7 +33550,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 183)) { + if (!hasKind(ifStatement.elseStatement, 184)) { break; } ifStatement = ifStatement.elseStatement; @@ -32965,16 +33708,16 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 213 || location.parent.kind === 217) && + (location.parent.kind === 214 || location.parent.kind === 218) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 213 || declaration.kind === 217; + return declaration.kind === 214 || declaration.kind === 218; }); } function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 ? d : undefined; }); var name; if (functionExpression && functionExpression.name) { name = functionExpression.name.text; @@ -32989,7 +33732,7 @@ var ts; if (isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 162 ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 ? d : undefined; }); var name = functionExpression && functionExpression.name ? functionExpression.name.text : symbol.name; @@ -33007,7 +33750,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 201); + return ts.getAncestor(privateDeclaration, 202); } } if (symbol.flags & 8388608) { @@ -33028,7 +33771,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 227 && !ts.isExternalModule(container)) { + if (container.kind === 228 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -33187,13 +33930,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 132: - case 131: - case 134: case 133: + case 132: case 135: + case 134: case 136: case 137: + case 138: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -33221,32 +33964,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { + case 135: case 134: - case 133: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 133: case 132: - case 131: - case 135: case 136: case 137: + case 138: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 227: + case 228: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 200: - case 162: + case 201: + case 163: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 227) { + if (searchSpaceNode.kind === 228) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -33277,25 +34020,25 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 162: - case 200: + case 163: + case 201: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 135: case 134: - case 133: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 201: + case 202: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 227: - if (container.kind === 227 && !ts.isExternalModule(container)) { + case 228: + if (container.kind === 228 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -33330,11 +34073,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 201) { + if (declaration.kind === 202) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 202) { + else if (declaration.kind === 203) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -33384,17 +34127,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_25 = node.text; + var name_26 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_25); + var unionProperty = contextualType.getProperty(name_26); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_25); + var symbol = t.getProperty(name_26); if (symbol) { result_4.push(symbol); } @@ -33403,7 +34146,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_25); + var symbol_1 = contextualType.getProperty(name_26); if (symbol_1) { return [symbol_1]; } @@ -33448,10 +34191,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 168 || parent.kind === 167) { + if (parent.kind === 169 || parent.kind === 168) { return true; } - else if (parent.kind === 169 && parent.left === node) { + else if (parent.kind === 170 && parent.left === node) { var operator = parent.operatorToken.kind; return 53 <= operator && operator <= 64; } @@ -33484,33 +34227,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 129: - case 198: - case 152: + case 130: + case 199: + case 153: + case 133: case 132: - case 131: - case 224: case 225: case 226: - case 134: - case 133: + case 227: case 135: + case 134: case 136: case 137: - case 200: - case 162: - case 163: - case 223: - return 1; - case 128: - case 202: - case 203: - case 145: - return 2; + case 138: case 201: + case 163: + case 164: + case 224: + return 1; + case 129: + case 203: case 204: - return 1 | 2; + case 146: + return 2; + case 202: case 205: + return 1 | 2; + case 206: if (node.name.kind === 8) { return 4 | 1; } @@ -33520,14 +34263,14 @@ var ts; else { return 4; } - case 212: case 213: - case 208: - case 209: case 214: + case 209: + case 210: case 215: + case 216: return 1 | 2 | 4; - case 227: + case 228: return 4 | 1; } return 1 | 2 | 4; @@ -33537,7 +34280,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 141 || node.parent.kind === 177; + return node.parent.kind === 142 || node.parent.kind === 177; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -33545,47 +34288,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 155) { - while (root.parent && root.parent.kind === 155) { + if (root.parent.kind === 156) { + while (root.parent && root.parent.kind === 156) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 && root.parent.parent.kind === 222) { + if (!isLastClause && root.parent.kind === 177 && root.parent.parent.kind === 223) { var decl = root.parent.parent.parent; - return (decl.kind === 201 && root.parent.parent.token === 102) || - (decl.kind === 202 && root.parent.parent.token === 79); + return (decl.kind === 202 && root.parent.parent.token === 102) || + (decl.kind === 203 && root.parent.parent.token === 79); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 126) { - while (root.parent && root.parent.kind === 126) { + if (root.parent.kind === 127) { + while (root.parent && root.parent.kind === 127) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 141 && !isLastClause; + return root.parent.kind === 142 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 126) { + while (node.parent.kind === 127) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 65); - if (node.parent.kind === 126 && + if (node.parent.kind === 127 && node.parent.right === node && - node.parent.parent.kind === 208) { + node.parent.parent.kind === 209) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 214) { + if (node.parent.kind === 215) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -33619,8 +34362,8 @@ var ts; return; } switch (node.kind) { - case 155: - case 126: + case 156: + case 127: case 8: case 80: case 95: @@ -33638,7 +34381,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 205 && + if (nodeForStartPos.parent.parent.kind === 206 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -33661,41 +34404,49 @@ var ts; return ts.NavigationBar.getNavigationBarItems(sourceFile); } function getSemanticClassifications(fileName, span) { + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + function getEncodedSemanticClassifications(fileName, span) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; processNode(sourceFile); - return result; + return { spans: result, endOfLineState: 0 }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); if (flags & 32) { - return ClassificationTypeNames.className; + return 11; } else if (flags & 384) { - return ClassificationTypeNames.enumName; + return 12; } else if (flags & 524288) { - return ClassificationTypeNames.typeAlias; + return 16; } else if (meaningAtPosition & 2) { if (flags & 64) { - return ClassificationTypeNames.interfaceName; + return 13; } else if (flags & 262144) { - return ClassificationTypeNames.typeParameterName; + return 15; } } else if (flags & 1536) { if (meaningAtPosition & 4 || (meaningAtPosition & 1 && hasValueSideModule(symbol))) { - return ClassificationTypeNames.moduleName; + return 14; } } return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 205 && ts.getModuleInstanceState(declaration) == 1; + return declaration.kind === 206 && ts.getModuleInstanceState(declaration) == 1; }); } } @@ -33706,10 +34457,7 @@ var ts; if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { - result.push({ - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - classificationType: type - }); + pushClassification(node.getStart(), node.getWidth(), type); } } } @@ -33717,13 +34465,53 @@ var ts; } } } + function getClassificationTypeName(type) { + switch (type) { + case 1: return ClassificationTypeNames.comment; + case 2: return ClassificationTypeNames.identifier; + case 3: return ClassificationTypeNames.keyword; + case 4: return ClassificationTypeNames.numericLiteral; + case 5: return ClassificationTypeNames.operator; + case 6: return ClassificationTypeNames.stringLiteral; + case 8: return ClassificationTypeNames.whiteSpace; + case 9: return ClassificationTypeNames.text; + case 10: return ClassificationTypeNames.punctuation; + case 11: return ClassificationTypeNames.className; + case 12: return ClassificationTypeNames.enumName; + case 13: return ClassificationTypeNames.interfaceName; + case 14: return ClassificationTypeNames.moduleName; + case 15: return ClassificationTypeNames.typeParameterName; + case 16: return ClassificationTypeNames.typeAliasName; + case 17: return ClassificationTypeNames.parameterName; + } + } + function convertClassifications(classifications) { + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } function getSyntacticClassifications(fileName, span) { + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + function getEncodedSyntacticClassifications(fileName, span) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var triviaScanner = ts.createScanner(2, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2, false, sourceFile.text); var result = []; processElement(sourceFile); - return result; + return { spans: result, endOfLineState: 0 }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } function classifyLeadingTrivia(token) { var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); if (tokenStart === token.pos) { @@ -33740,20 +34528,14 @@ var ts; return; } if (ts.isComment(kind)) { - result.push({ - textSpan: ts.createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, 1); continue; } if (kind === 6) { var text = sourceFile.text; var ch = text.charCodeAt(start); if (ch === 60 || ch === 62) { - result.push({ - textSpan: ts.createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, 1); continue; } ts.Debug.assert(ch === 61); @@ -33768,10 +34550,7 @@ var ts; break; } } - result.push({ - textSpan: ts.createTextSpanFromBounds(start, i), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, i - start, 1); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -33783,10 +34562,7 @@ var ts; var end = mergeConflictScanner.getTextPos(); var type = classifyTokenType(tokenKind); if (type) { - result.push({ - textSpan: ts.createTextSpanFromBounds(start, end), - classificationType: type - }); + pushClassification(start, end - start, type); } } function classifyToken(token) { @@ -33794,83 +34570,85 @@ var ts; if (token.getWidth() > 0) { var type = classifyTokenType(token.kind, token); if (type) { - result.push({ - textSpan: ts.createTextSpan(token.getStart(), token.getWidth()), - classificationType: type - }); + pushClassification(token.getStart(), token.getWidth(), type); } } } function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return ClassificationTypeNames.keyword; + return 3; } if (tokenKind === 24 || tokenKind === 25) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return ClassificationTypeNames.punctuation; + return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 53) { - if (token.parent.kind === 198 || - token.parent.kind === 132 || - token.parent.kind === 129) { - return ClassificationTypeNames.operator; + if (token.parent.kind === 199 || + token.parent.kind === 133 || + token.parent.kind === 130) { + return 5; } } - if (token.parent.kind === 169 || - token.parent.kind === 167 || + if (token.parent.kind === 170 || token.parent.kind === 168 || - token.parent.kind === 170) { - return ClassificationTypeNames.operator; + token.parent.kind === 169 || + token.parent.kind === 171) { + return 5; } } - return ClassificationTypeNames.punctuation; + return 10; } else if (tokenKind === 7) { - return ClassificationTypeNames.numericLiteral; + return 4; } else if (tokenKind === 8) { - return ClassificationTypeNames.stringLiteral; + return 6; } else if (tokenKind === 9) { - return ClassificationTypeNames.stringLiteral; + return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { - return ClassificationTypeNames.stringLiteral; + return 6; } else if (tokenKind === 65) { if (token) { switch (token.parent.kind) { - case 201: - if (token.parent.name === token) { - return ClassificationTypeNames.className; - } - return; - case 128: - if (token.parent.name === token) { - return ClassificationTypeNames.typeParameterName; - } - return; case 202: if (token.parent.name === token) { - return ClassificationTypeNames.interfaceName; + return 11; } return; - case 204: + case 129: if (token.parent.name === token) { - return ClassificationTypeNames.enumName; + return 15; + } + return; + case 203: + if (token.parent.name === token) { + return 13; } return; case 205: if (token.parent.name === token) { - return ClassificationTypeNames.moduleName; + return 12; + } + return; + case 206: + if (token.parent.name === token) { + return 14; + } + return; + case 130: + if (token.parent.name === token) { + return 17; } return; } } - return ClassificationTypeNames.text; + return 9; } } function processElement(element) { @@ -34079,11 +34857,14 @@ var ts; getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getSyntacticClassifications: getSyntacticClassifications, getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, getCompletionsAtPosition: getCompletionsAtPosition, getCompletionEntryDetails: getCompletionEntryDetails, getSignatureHelpItems: getSignatureHelpItems, getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, findReferences: findReferences, getOccurrencesAtPosition: getOccurrencesAtPosition, @@ -34126,7 +34907,7 @@ var ts; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 219 || + node.parent.kind === 220 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -34139,7 +34920,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 156 && + node.parent.kind === 157 && node.parent.argumentExpression === node; } function createClassifier() { @@ -34161,7 +34942,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 || - keyword2 === 120 || + keyword2 === 121 || keyword2 === 114 || keyword2 === 109) { return true; @@ -34170,7 +34951,55 @@ var ts; } return true; } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_1 = dense[i + 1]; + var type = dense[i + 2]; + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + } + } + entries.push({ length: length_1, classification: convertClassification(type) }); + lastEnd = start + length_1; + } + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + return { entries: entries, finalLexState: classifications.endOfLineState }; + } + function convertClassification(type) { + switch (type) { + case 1: return TokenClass.Comment; + case 3: return TokenClass.Keyword; + case 4: return TokenClass.NumberLiteral; + case 5: return TokenClass.Operator; + case 6: return TokenClass.StringLiteral; + case 8: return TokenClass.Whitespace; + case 10: return TokenClass.Punctuation; + case 2: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 9: + case 17: + default: + return TokenClass.Identifier; + } + } function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { var offset = 0; var token = 0; var lastNonTriviaToken = 0; @@ -34203,8 +35032,8 @@ var ts; } scanner.setText(text); var result = { - finalLexState: 0, - entries: [] + endOfLineState: 0, + spans: [] }; var angleBracketStack = 0; do { @@ -34229,10 +35058,10 @@ var ts; angleBracketStack--; } else if (token === 112 || - token === 121 || - token === 119 || + token === 122 || + token === 120 || token === 113 || - token === 122) { + token === 123) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 65; } @@ -34271,7 +35100,7 @@ var ts; function processToken() { var start = scanner.getTokenPos(); var end = scanner.getTextPos(); - addResult(end - start, classFromKind(token)); + addResult(start, end, classFromKind(token)); if (end >= text.length) { if (token === 8) { var tokenText = scanner.getTokenText(); @@ -34283,7 +35112,7 @@ var ts; } if (numBackslashes & 1) { var quoteChar = tokenText.charCodeAt(0); - result.finalLexState = quoteChar === 34 + result.endOfLineState = quoteChar === 34 ? 3 : 2; } @@ -34291,16 +35120,16 @@ var ts; } else if (token === 3) { if (scanner.isUnterminated()) { - result.finalLexState = 1; + result.endOfLineState = 1; } } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { if (token === 13) { - result.finalLexState = 5; + result.endOfLineState = 5; } else if (token === 10) { - result.finalLexState = 4; + result.endOfLineState = 4; } else { ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); @@ -34308,16 +35137,24 @@ var ts; } } else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11) { - result.finalLexState = 6; + result.endOfLineState = 6; } } } - function addResult(length, classification) { + function addResult(start, end, classification) { + if (classification === 8) { + return; + } + if (start === 0 && offset > 0) { + start += offset; + } + start -= offset; + end -= offset; + var length = end - start; if (length > 0) { - if (result.entries.length === 0) { - length -= offset; - } - result.entries.push({ length: length, classification: classification }); + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); } } } @@ -34378,41 +35215,44 @@ var ts; } } function isKeyword(token) { - return token >= 66 && token <= 125; + return token >= 66 && token <= 126; } function classFromKind(token) { if (isKeyword(token)) { - return TokenClass.Keyword; + return 3; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return TokenClass.Operator; + return 5; } else if (token >= 14 && token <= 64) { - return TokenClass.Punctuation; + return 10; } switch (token) { case 7: - return TokenClass.NumberLiteral; + return 4; case 8: - return TokenClass.StringLiteral; + return 6; case 9: - return TokenClass.RegExpLiteral; + return 7; case 6: case 3: case 2: - return TokenClass.Comment; + return 1; case 5: case 4: - return TokenClass.Whitespace; + return 8; case 65: default: if (ts.isTemplateLiteralKind(token)) { - return TokenClass.StringLiteral; + return 6; } - return TokenClass.Identifier; + return 2; } } - return { getClassificationsForLine: getClassificationsForLine }; + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; } ts.createClassifier = createClassifier; function getDefaultLibFilePath(options) { @@ -34427,7 +35267,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 227 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 228 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -34528,6 +35368,7 @@ var ts; CommandNames.Rename = "rename"; CommandNames.Saveto = "saveto"; CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.TypeDefinition = "typeDefinition"; CommandNames.Unknown = "unknown"; })(CommandNames = server.CommandNames || (server.CommandNames = {})); var Errors; @@ -34699,6 +35540,24 @@ var ts; end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) }); }); }; + Session.prototype.getTypeDefinition = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { return ({ + file: def.fileName, + start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), + end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) + }); }); + }; Session.prototype.getOccurrences = function (line, offset, fileName) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -34893,7 +35752,7 @@ var ts; IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: "\n", - ConvertTabsToSpaces: true + ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces }; var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); for (var i = 0, len = lineText.length; i < len; i++) { @@ -35155,6 +36014,11 @@ var ts; response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); break; } + case CommandNames.TypeDefinition: { + var defArgs = request.arguments; + response = this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file); + break; + } case CommandNames.References: { var refArgs = request.arguments; response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); @@ -35882,6 +36746,7 @@ var ts; if (content !== undefined) { var indentSize; info = new ScriptInfo(this.host, fileName, content, openedByClient); + info.setFormatOptions(this.getFormatCodeOptions()); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); }); @@ -35898,7 +36763,7 @@ var ts; ProjectService.prototype.findConfigFile = function (searchPath) { while (true) { var fileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (ts.sys.fileExists(fileName)) { + if (this.host.fileExists(fileName)) { return fileName; } var parentPath = ts.getDirectoryPath(searchPath); @@ -36015,11 +36880,11 @@ var ts; configFilename = ts.normalizePath(configFilename); var dirPath = ts.getDirectoryPath(configFilename); var rawConfig = ts.readConfigFile(configFilename); - if (!rawConfig) { - return { errorMsg: "tsconfig syntax error" }; + if (rawConfig.error) { + return rawConfig.error; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig, dirPath); + var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } @@ -36031,7 +36896,7 @@ var ts; var proj = this.createProject(configFilename, projectOptions); for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { var rootFilename = parsedCommandLine.fileNames[i]; - if (ts.sys.fileExists(rootFilename)) { + if (this.host.fileExists(rootFilename)) { var info = this.openFile(rootFilename, clientFileName == rootFilename); proj.addRoot(info); } diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index 00ddd433179..3e765a33f01 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -140,132 +140,133 @@ declare module "typescript" { DeclareKeyword = 115, GetKeyword = 116, ModuleKeyword = 117, - RequireKeyword = 118, - NumberKeyword = 119, - SetKeyword = 120, - StringKeyword = 121, - SymbolKeyword = 122, - TypeKeyword = 123, - FromKeyword = 124, - OfKeyword = 125, - QualifiedName = 126, - ComputedPropertyName = 127, - TypeParameter = 128, - Parameter = 129, - Decorator = 130, - PropertySignature = 131, - PropertyDeclaration = 132, - MethodSignature = 133, - MethodDeclaration = 134, - Constructor = 135, - GetAccessor = 136, - SetAccessor = 137, - CallSignature = 138, - ConstructSignature = 139, - IndexSignature = 140, - TypeReference = 141, - FunctionType = 142, - ConstructorType = 143, - TypeQuery = 144, - TypeLiteral = 145, - ArrayType = 146, - TupleType = 147, - UnionType = 148, - ParenthesizedType = 149, - ObjectBindingPattern = 150, - ArrayBindingPattern = 151, - BindingElement = 152, - ArrayLiteralExpression = 153, - ObjectLiteralExpression = 154, - PropertyAccessExpression = 155, - ElementAccessExpression = 156, - CallExpression = 157, - NewExpression = 158, - TaggedTemplateExpression = 159, - TypeAssertionExpression = 160, - ParenthesizedExpression = 161, - FunctionExpression = 162, - ArrowFunction = 163, - DeleteExpression = 164, - TypeOfExpression = 165, - VoidExpression = 166, - PrefixUnaryExpression = 167, - PostfixUnaryExpression = 168, - BinaryExpression = 169, - ConditionalExpression = 170, - TemplateExpression = 171, - YieldExpression = 172, - SpreadElementExpression = 173, - ClassExpression = 174, - OmittedExpression = 175, - TemplateSpan = 176, - HeritageClauseElement = 177, - SemicolonClassElement = 178, - Block = 179, - VariableStatement = 180, - EmptyStatement = 181, - ExpressionStatement = 182, - IfStatement = 183, - DoStatement = 184, - WhileStatement = 185, - ForStatement = 186, - ForInStatement = 187, - ForOfStatement = 188, - ContinueStatement = 189, - BreakStatement = 190, - ReturnStatement = 191, - WithStatement = 192, - SwitchStatement = 193, - LabeledStatement = 194, - ThrowStatement = 195, - TryStatement = 196, - DebuggerStatement = 197, - VariableDeclaration = 198, - VariableDeclarationList = 199, - FunctionDeclaration = 200, - ClassDeclaration = 201, - InterfaceDeclaration = 202, - TypeAliasDeclaration = 203, - EnumDeclaration = 204, - ModuleDeclaration = 205, - ModuleBlock = 206, - CaseBlock = 207, - ImportEqualsDeclaration = 208, - ImportDeclaration = 209, - ImportClause = 210, - NamespaceImport = 211, - NamedImports = 212, - ImportSpecifier = 213, - ExportAssignment = 214, - ExportDeclaration = 215, - NamedExports = 216, - ExportSpecifier = 217, - MissingDeclaration = 218, - ExternalModuleReference = 219, - CaseClause = 220, - DefaultClause = 221, - HeritageClause = 222, - CatchClause = 223, - PropertyAssignment = 224, - ShorthandPropertyAssignment = 225, - EnumMember = 226, - SourceFile = 227, - SyntaxList = 228, - Count = 229, + NamespaceKeyword = 118, + RequireKeyword = 119, + NumberKeyword = 120, + SetKeyword = 121, + StringKeyword = 122, + SymbolKeyword = 123, + TypeKeyword = 124, + FromKeyword = 125, + OfKeyword = 126, + QualifiedName = 127, + ComputedPropertyName = 128, + TypeParameter = 129, + Parameter = 130, + Decorator = 131, + PropertySignature = 132, + PropertyDeclaration = 133, + MethodSignature = 134, + MethodDeclaration = 135, + Constructor = 136, + GetAccessor = 137, + SetAccessor = 138, + CallSignature = 139, + ConstructSignature = 140, + IndexSignature = 141, + TypeReference = 142, + FunctionType = 143, + ConstructorType = 144, + TypeQuery = 145, + TypeLiteral = 146, + ArrayType = 147, + TupleType = 148, + UnionType = 149, + ParenthesizedType = 150, + ObjectBindingPattern = 151, + ArrayBindingPattern = 152, + BindingElement = 153, + ArrayLiteralExpression = 154, + ObjectLiteralExpression = 155, + PropertyAccessExpression = 156, + ElementAccessExpression = 157, + CallExpression = 158, + NewExpression = 159, + TaggedTemplateExpression = 160, + TypeAssertionExpression = 161, + ParenthesizedExpression = 162, + FunctionExpression = 163, + ArrowFunction = 164, + DeleteExpression = 165, + TypeOfExpression = 166, + VoidExpression = 167, + PrefixUnaryExpression = 168, + PostfixUnaryExpression = 169, + BinaryExpression = 170, + ConditionalExpression = 171, + TemplateExpression = 172, + YieldExpression = 173, + SpreadElementExpression = 174, + ClassExpression = 175, + OmittedExpression = 176, + ExpressionWithTypeArguments = 177, + TemplateSpan = 178, + SemicolonClassElement = 179, + Block = 180, + VariableStatement = 181, + EmptyStatement = 182, + ExpressionStatement = 183, + IfStatement = 184, + DoStatement = 185, + WhileStatement = 186, + ForStatement = 187, + ForInStatement = 188, + ForOfStatement = 189, + ContinueStatement = 190, + BreakStatement = 191, + ReturnStatement = 192, + WithStatement = 193, + SwitchStatement = 194, + LabeledStatement = 195, + ThrowStatement = 196, + TryStatement = 197, + DebuggerStatement = 198, + VariableDeclaration = 199, + VariableDeclarationList = 200, + FunctionDeclaration = 201, + ClassDeclaration = 202, + InterfaceDeclaration = 203, + TypeAliasDeclaration = 204, + EnumDeclaration = 205, + ModuleDeclaration = 206, + ModuleBlock = 207, + CaseBlock = 208, + ImportEqualsDeclaration = 209, + ImportDeclaration = 210, + ImportClause = 211, + NamespaceImport = 212, + NamedImports = 213, + ImportSpecifier = 214, + ExportAssignment = 215, + ExportDeclaration = 216, + NamedExports = 217, + ExportSpecifier = 218, + MissingDeclaration = 219, + ExternalModuleReference = 220, + CaseClause = 221, + DefaultClause = 222, + HeritageClause = 223, + CatchClause = 224, + PropertyAssignment = 225, + ShorthandPropertyAssignment = 226, + EnumMember = 227, + SourceFile = 228, + SyntaxList = 229, + Count = 230, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, LastReservedWord = 101, FirstKeyword = 66, - LastKeyword = 125, + LastKeyword = 126, FirstFutureReservedWord = 102, LastFutureReservedWord = 110, - FirstTypeNode = 141, - LastTypeNode = 149, + FirstTypeNode = 142, + LastTypeNode = 150, FirstPunctuation = 14, LastPunctuation = 64, FirstToken = 0, - LastToken = 125, + LastToken = 126, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -274,7 +275,7 @@ declare module "typescript" { LastTemplateToken = 13, FirstBinaryOperator = 24, LastBinaryOperator = 64, - FirstNode = 126, + FirstNode = 127, } const enum NodeFlags { Export = 1, @@ -290,7 +291,8 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, - ExportContext = 32768, + Namespace = 32768, + ExportContext = 65536, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -553,7 +555,7 @@ declare module "typescript" { typeArguments?: NodeArray; arguments: NodeArray; } - interface HeritageClauseElement extends TypeNode { + interface ExpressionWithTypeArguments extends TypeNode { expression: LeftHandSideExpression; typeArguments?: NodeArray; } @@ -672,7 +674,7 @@ declare module "typescript" { } interface HeritageClause extends Node { token: SyntaxKind; - types?: NodeArray; + types?: NodeArray; } interface TypeAliasDeclaration extends Declaration, ModuleElement { name: Identifier; @@ -756,6 +758,9 @@ declare module "typescript" { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } + interface ParseConfigHost { + readDirectory(rootDir: string, extension: string): string[]; + } interface WriteFileCallback { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } @@ -804,6 +809,7 @@ declare module "typescript" { sourceMapFile: string; sourceMapSourceRoot: string; sourceMapSources: string[]; + sourceMapSourcesContent?: string[]; inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; @@ -1082,11 +1088,15 @@ declare module "typescript" { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; listFiles?: boolean; locale?: string; mapRoot?: string; module?: ModuleKind; + newLine?: NewLineKind; noEmit?: boolean; + noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; noImplicitAny?: boolean; @@ -1113,6 +1123,11 @@ declare module "typescript" { CommonJS = 1, AMD = 2, UMD = 3, + System = 4, + } + const enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, } interface LineAndCharacter { line: number; @@ -1176,6 +1191,32 @@ declare module "typescript" { var sys: System; } declare module "typescript" { + interface ErrorCallback { + (message: DiagnosticMessage, length: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasExtendedUnicodeEscape(): boolean; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string, start?: number, length?: number): void; + setOnError(onError: ErrorCallback): void; + setScriptTarget(scriptTarget: ScriptTarget): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } function tokenToString(t: SyntaxKind): string; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; @@ -1185,6 +1226,8 @@ declare module "typescript" { function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + /** Creates a scanner over a (possibly unspecified) range of a piece of text. */ + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare module "typescript" { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1226,7 +1269,7 @@ declare module "typescript" { const version: string; function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; } @@ -1236,14 +1279,26 @@ declare module "typescript" { * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string): any; + function readConfigFile(fileName: string): { + config?: any; + error?: Diagnostic; + }; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileText(fileName: string, jsonText: string): { + config?: any; + error?: Diagnostic; + }; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseConfigFile(json: any, basePath?: string): ParsedCommandLine; + function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; } declare module "typescript" { /** The version of the language service API */ @@ -1340,8 +1395,16 @@ declare module "typescript" { getSyntacticDiagnostics(fileName: string): Diagnostic[]; getSemanticDiagnostics(fileName: string): Diagnostic[]; getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; @@ -1351,6 +1414,7 @@ declare module "typescript" { getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; findReferences(fileName: string, position: number): ReferencedSymbol[]; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; @@ -1370,6 +1434,10 @@ declare module "typescript" { getSourceFile(fileName: string): SourceFile; dispose(): void; } + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; + } interface ClassifiedSpan { textSpan: TextSpan; classificationType: string; @@ -1581,7 +1649,7 @@ declare module "typescript" { text: string; } const enum EndOfLineState { - Start = 0, + None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, InDoubleQuoteStringLiteral = 3, @@ -1627,8 +1695,10 @@ declare module "typescript" { * classifications which may be incorrectly categorized will be given * back as Identifiers in order to allow the syntactic classifier to * subsume the classification. + * @deprecated Use getLexicalClassifications instead. */ getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } /** * The document registry represents a store of SourceFile objects that can be shared between @@ -1739,7 +1809,27 @@ declare module "typescript" { static interfaceName: string; static moduleName: string; static typeParameterName: string; - static typeAlias: string; + static typeAliasName: string; + static parameterName: string; + } + const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, } interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; diff --git a/bin/typescript.js b/bin/typescript.js index fefe3658fb4..ba375bc4096 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -145,149 +145,150 @@ var ts; SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 118] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 119] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 120] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 121] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 122] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 123] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 124] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 125] = "OfKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 118] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 119] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 120] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 121] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 122] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 123] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 124] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 125] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 126] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 126] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 127] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 127] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 128] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 128] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 129] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 130] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 129] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 130] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 131] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 131] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 132] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 133] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 134] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 135] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 136] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 137] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 138] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 139] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 140] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 132] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 133] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 134] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 135] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 136] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 137] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 138] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 139] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 140] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 141] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypeReference"] = 141] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 142] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 143] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 144] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 145] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 146] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 147] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 148] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 149] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypeReference"] = 142] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 143] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 144] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 145] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 146] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 147] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 148] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 149] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 150] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 150] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 151] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 152] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 151] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 152] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 153] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 153] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 154] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 155] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 156] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 157] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 158] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 159] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 160] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 161] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 162] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 163] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 164] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 165] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 166] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 167] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 168] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 169] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 170] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 171] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 172] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 173] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 174] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 175] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 154] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 155] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 156] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 157] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 158] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 159] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 160] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 161] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 162] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 163] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 164] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 165] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 166] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 167] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 168] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 169] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 170] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 171] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 172] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 173] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 174] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 175] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 176] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 177] = "ExpressionWithTypeArguments"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 176] = "TemplateSpan"; - SyntaxKind[SyntaxKind["HeritageClauseElement"] = 177] = "HeritageClauseElement"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 178] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 178] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 179] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 179] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 180] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 181] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 182] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 183] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 184] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 185] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 186] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 187] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 188] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 189] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 190] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 191] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 192] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 193] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 194] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 195] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 196] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 197] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 198] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 199] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 200] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 201] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 202] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 203] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 204] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 205] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 206] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 207] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 208] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 209] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 210] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 211] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 212] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 213] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 214] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 215] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 216] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 217] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 218] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 180] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 181] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 182] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 183] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 184] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 185] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 186] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 187] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 188] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 189] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 190] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 191] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 192] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 193] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 194] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 195] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 196] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 197] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 198] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 199] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 200] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 201] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 202] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 203] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 204] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 205] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 206] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 207] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 208] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 209] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 210] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 211] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 212] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 213] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 214] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 215] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 216] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 217] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 218] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 219] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 219] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 220] = "ExternalModuleReference"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 220] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 221] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 222] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 223] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 221] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 222] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 223] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 224] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 224] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 225] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 225] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 226] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 226] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 227] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 227] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 228] = "SourceFile"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 228] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 229] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 229] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 230] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 125] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 126] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 141] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 149] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 142] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 150] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 125] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 126] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -296,7 +297,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 126] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 127] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -313,7 +314,8 @@ var ts; NodeFlags[NodeFlags["Let"] = 4096] = "Let"; NodeFlags[NodeFlags["Const"] = 8192] = "Const"; NodeFlags[NodeFlags["OctalLiteral"] = 16384] = "OctalLiteral"; - NodeFlags[NodeFlags["ExportContext"] = 32768] = "ExportContext"; + NodeFlags[NodeFlags["Namespace"] = 32768] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 65536] = "ExportContext"; NodeFlags[NodeFlags["Modifier"] = 499] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 12288] = "BlockScoped"; @@ -542,8 +544,14 @@ var ts; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; + ModuleKind[ModuleKind["System"] = 4] = "System"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; @@ -1134,7 +1142,7 @@ var ts; for (var _i = 0; _i < parts.length; _i++) { var part = parts[_i]; if (part !== ".") { - if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); } else { @@ -1241,7 +1249,7 @@ var ts; function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name // that is ["test", "cases", ""] needs to be actually ["test", "cases"] directoryComponents.length--; @@ -1695,7 +1703,7 @@ var ts; A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, @@ -1756,8 +1764,8 @@ var ts; or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, @@ -1799,9 +1807,9 @@ var ts; The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, @@ -1810,28 +1818,27 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, + Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, @@ -1854,7 +1861,7 @@ var ts; Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, @@ -1946,15 +1953,15 @@ var ts; Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, @@ -2008,11 +2015,13 @@ var ts; Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "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}'." }, 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}'." }, @@ -2088,6 +2097,7 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, @@ -2101,6 +2111,10 @@ var ts; Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, + Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2112,7 +2126,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -2133,7 +2147,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -2147,6 +2161,9 @@ var ts; Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2159,7 +2176,6 @@ var ts; 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." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, @@ -2215,7 +2231,7 @@ var ts; "false": 80 /* FalseKeyword */, "finally": 81 /* FinallyKeyword */, "for": 82 /* ForKeyword */, - "from": 124 /* FromKeyword */, + "from": 125 /* FromKeyword */, "function": 83 /* FunctionKeyword */, "get": 116 /* GetKeyword */, "if": 84 /* IfKeyword */, @@ -2226,33 +2242,34 @@ var ts; "interface": 103 /* InterfaceKeyword */, "let": 104 /* LetKeyword */, "module": 117 /* ModuleKeyword */, + "namespace": 118 /* NamespaceKeyword */, "new": 88 /* NewKeyword */, "null": 89 /* NullKeyword */, - "number": 119 /* NumberKeyword */, + "number": 120 /* NumberKeyword */, "package": 105 /* PackageKeyword */, "private": 106 /* PrivateKeyword */, "protected": 107 /* ProtectedKeyword */, "public": 108 /* PublicKeyword */, - "require": 118 /* RequireKeyword */, + "require": 119 /* RequireKeyword */, "return": 90 /* ReturnKeyword */, - "set": 120 /* SetKeyword */, + "set": 121 /* SetKeyword */, "static": 109 /* StaticKeyword */, - "string": 121 /* StringKeyword */, + "string": 122 /* StringKeyword */, "super": 91 /* SuperKeyword */, "switch": 92 /* SwitchKeyword */, - "symbol": 122 /* SymbolKeyword */, + "symbol": 123 /* SymbolKeyword */, "this": 93 /* ThisKeyword */, "throw": 94 /* ThrowKeyword */, "true": 95 /* TrueKeyword */, "try": 96 /* TryKeyword */, - "type": 123 /* TypeKeyword */, + "type": 124 /* TypeKeyword */, "typeof": 97 /* TypeOfKeyword */, "var": 98 /* VarKeyword */, "void": 99 /* VoidKeyword */, "while": 100 /* WhileKeyword */, "with": 101 /* WithKeyword */, "yield": 110 /* YieldKeyword */, - "of": 125 /* OfKeyword */, + "of": 126 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2644,7 +2661,7 @@ var ts; } collecting = true; if (result && result.length) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } continue; case 9 /* tab */: @@ -2690,7 +2707,7 @@ var ts; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { if (result && result.length && isLineBreak(ch)) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } pos++; continue; @@ -2720,8 +2737,7 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - // Creates a scanner over a (possibly unspecified) range of a piece of text. - /* @internal */ + /** Creates a scanner over a (possibly unspecified) range of a piece of text. */ function createScanner(languageVersion, skipTrivia, text, onError, start, length) { var pos; // Current position (end position of text of current token) var end; // end of text @@ -3570,16 +3586,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 202 /* InterfaceDeclaration */ || node.kind === 203 /* TypeAliasDeclaration */) { + if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 204 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 209 /* ImportDeclaration */ || node.kind === 208 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 206 /* ModuleBlock */) { + else if (node.kind === 207 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3598,7 +3614,7 @@ var ts; }); return state; } - else if (node.kind === 205 /* ModuleDeclaration */) { + else if (node.kind === 206 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3653,10 +3669,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 205 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3664,22 +3680,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 143 /* ConstructorType */: - case 135 /* Constructor */: + case 144 /* ConstructorType */: + case 136 /* Constructor */: return "__constructor"; - case 142 /* FunctionType */: - case 138 /* CallSignature */: + case 143 /* FunctionType */: + case 139 /* CallSignature */: return "__call"; - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: return "__new"; - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: return "__index"; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return "__export"; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 200 /* FunctionDeclaration */: - case 201 /* ClassDeclaration */: + case 201 /* FunctionDeclaration */: + case 202 /* ClassDeclaration */: return node.flags & 256 /* Default */ ? "default" : undefined; } } @@ -3714,7 +3730,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if ((node.kind === 201 /* ClassDeclaration */ || node.kind === 174 /* ClassExpression */) && symbol.exports) { + if ((node.kind === 202 /* ClassDeclaration */ || node.kind === 175 /* ClassExpression */) && symbol.exports) { // 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. @@ -3734,7 +3750,7 @@ var ts; function declareModuleMember(node, symbolKind, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolKind & 8388608 /* Alias */) { - if (node.kind === 217 /* ExportSpecifier */ || (node.kind === 208 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 218 /* ExportSpecifier */ || (node.kind === 209 /* ImportEqualsDeclaration */ && hasExportModifier)) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); } else { @@ -3753,7 +3769,7 @@ 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 & 32768 /* ExportContext */) { + if (hasExportModifier || container.flags & 65536 /* ExportContext */) { var exportKind = (symbolKind & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolKind & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolKind & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -3787,7 +3803,7 @@ var ts; // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, (symbolKind & 255504 /* HasLocals */) === 0 && node.kind !== 227 /* SourceFile */); + setBlockScopeContainer(node, (symbolKind & 255504 /* HasLocals */) === 0 && node.kind !== 228 /* SourceFile */); } ts.forEachChild(node, bind); container = saveContainer; @@ -3802,41 +3818,41 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 174 /* ClassExpression */: - case 201 /* ClassDeclaration */: + case 175 /* ClassExpression */: + case 202 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 145 /* TypeLiteral */: - case 154 /* ObjectLiteralExpression */: - case 202 /* InterfaceDeclaration */: + case 146 /* TypeLiteral */: + case 155 /* ObjectLiteralExpression */: + case 203 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -3851,11 +3867,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 227 /* SourceFile */ ? node : node.body; - if (body.kind === 227 /* SourceFile */ || body.kind === 206 /* ModuleBlock */) { + var body = node.kind === 228 /* SourceFile */ ? node : node.body; + if (body.kind === 228 /* SourceFile */ || body.kind === 207 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 215 /* ExportDeclaration */ || stat.kind === 214 /* ExportAssignment */) { + if (stat.kind === 216 /* ExportDeclaration */ || stat.kind === 215 /* ExportAssignment */) { return true; } } @@ -3866,10 +3882,10 @@ var ts; // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 32768 /* ExportContext */; + node.flags |= 65536 /* ExportContext */; } else { - node.flags &= ~32768 /* ExportContext */; + node.flags &= ~65536 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -3909,7 +3925,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 142 /* FunctionType */ ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 143 /* FunctionType */ ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -3921,10 +3937,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolKind, symbolExcludes) { switch (blockScopeContainer.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; @@ -3948,14 +3964,14 @@ var ts; function bind(node) { node.parent = parent; switch (node.kind) { - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: bindDeclaration(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */, false); break; - case 129 /* Parameter */: + case 130 /* Parameter */: bindParameter(node); break; - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: if (ts.isBindingPattern(node.name)) { bindChildren(node, 0, false); } @@ -3966,72 +3982,72 @@ var ts; bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); } break; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0), 107455 /* PropertyExcludes */, false); break; - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 226 /* EnumMember */: + case 227 /* EnumMember */: bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: bindDeclaration(node, 131072 /* Signature */, 0, false); break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* 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. bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); break; - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; - case 135 /* Constructor */: + case 136 /* Constructor */: bindDeclaration(node, 16384 /* Constructor */, 0, true); break; - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); break; - case 137 /* SetAccessor */: + case 138 /* SetAccessor */: bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); break; - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: bindFunctionOrConstructorType(node); break; - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: bindAnonymousDeclaration(node, 32 /* Class */, "__class", false); break; - case 223 /* CatchClause */: + case 224 /* CatchClause */: bindCatchVariableDeclaration(node); break; - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); break; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: bindDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */, false); break; - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: bindDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */, false); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: if (ts.isConst(node)) { bindDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */, false); } @@ -4039,16 +4055,16 @@ var ts; bindDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */, false); } break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 208 /* ImportEqualsDeclaration */: - case 211 /* NamespaceImport */: - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 212 /* NamespaceImport */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: bindDeclaration(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */, false); break; - case 210 /* ImportClause */: + case 211 /* ImportClause */: if (node.name) { bindDeclaration(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */, false); } @@ -4056,14 +4072,14 @@ var ts; bindChildren(node, 0, false); } break; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0); } bindChildren(node, 0, false); break; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: if (node.expression.kind === 65 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); @@ -4074,13 +4090,13 @@ var ts; } bindChildren(node, 0, false); break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: setExportContextFlag(node); if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.fileName) + '"', true); break; } - case 179 /* Block */: + case 180 /* Block */: // do not treat function block a block-scope container // all block-scope locals that reside in this block should go to the function locals. // Otherwise this won't be considered as redeclaration of a block scoped local: @@ -4091,11 +4107,11 @@ var ts; // 'let x' will be placed into the function locals and 'let x' - into the locals of the block bindChildren(node, 0, !ts.isFunctionLike(node.parent)); break; - case 223 /* CatchClause */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 207 /* CaseBlock */: + case 224 /* CatchClause */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 208 /* CaseBlock */: bindChildren(node, 0, true); break; default: @@ -4115,8 +4131,8 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 135 /* Constructor */ && - (node.parent.parent.kind === 201 /* ClassDeclaration */ || node.parent.parent.kind === 174 /* ClassExpression */)) { + node.parent.kind === 136 /* Constructor */ && + (node.parent.parent.kind === 202 /* ClassDeclaration */ || node.parent.parent.kind === 175 /* ClassExpression */)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -4206,7 +4222,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 227 /* SourceFile */) { + while (node && node.kind !== 228 /* SourceFile */) { node = node.parent; } return node; @@ -4316,15 +4332,15 @@ var ts; return current; } switch (current.kind) { - case 227 /* SourceFile */: - case 207 /* CaseBlock */: - case 223 /* CatchClause */: - case 205 /* ModuleDeclaration */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 228 /* SourceFile */: + case 208 /* CaseBlock */: + case 224 /* CatchClause */: + case 206 /* ModuleDeclaration */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: return current; - case 179 /* Block */: + case 180 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4337,9 +4353,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 198 /* VariableDeclaration */ && + declaration.kind === 199 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 223 /* CatchClause */; + declaration.parent.kind === 224 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4378,7 +4394,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4387,16 +4403,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 202 /* ClassDeclaration */: + case 175 /* ClassExpression */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: errorNode = node.name; break; } @@ -4420,11 +4436,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 204 /* EnumDeclaration */ && isConst(node); + return node.kind === 205 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 152 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 153 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4439,14 +4455,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 198 /* VariableDeclaration */) { + if (node.kind === 199 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 199 /* VariableDeclarationList */) { + if (node && node.kind === 200 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 180 /* VariableStatement */) { + if (node && node.kind === 181 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4461,12 +4477,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 182 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 183 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 129 /* Parameter */ || node.kind === 128 /* TypeParameter */) { + if (node.kind === 130 /* Parameter */ || node.kind === 129 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -4495,23 +4511,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return visitor(node); - case 207 /* CaseBlock */: - case 179 /* Block */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 192 /* WithStatement */: - case 193 /* SwitchStatement */: - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - case 194 /* LabeledStatement */: - case 196 /* TryStatement */: - case 223 /* CatchClause */: + case 208 /* CaseBlock */: + case 180 /* Block */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 193 /* WithStatement */: + case 194 /* SwitchStatement */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: + case 195 /* LabeledStatement */: + case 197 /* TryStatement */: + case 224 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4520,14 +4536,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 152 /* BindingElement */: - case 226 /* EnumMember */: - case 129 /* Parameter */: - case 224 /* PropertyAssignment */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 225 /* ShorthandPropertyAssignment */: - case 198 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 227 /* EnumMember */: + case 130 /* Parameter */: + case 225 /* PropertyAssignment */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 226 /* ShorthandPropertyAssignment */: + case 199 /* VariableDeclaration */: return true; } } @@ -4537,8 +4553,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return true; } } @@ -4548,22 +4564,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 135 /* Constructor */: - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 200 /* FunctionDeclaration */: + case 136 /* Constructor */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: return true; } } @@ -4571,11 +4587,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 179 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 180 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 134 /* MethodDeclaration */ && node.parent.kind === 154 /* ObjectLiteralExpression */; + return node && node.kind === 135 /* MethodDeclaration */ && node.parent.kind === 155 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4594,12 +4610,12 @@ var ts; return undefined; } switch (node.kind) { - case 127 /* ComputedPropertyName */: + case 128 /* 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 // so that we can error on it. - if (node.parent.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.parent.kind === 202 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4609,9 +4625,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 130 /* Decorator */: + case 131 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 129 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 130 /* 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; @@ -4622,23 +4638,23 @@ var ts; node = node.parent; } break; - case 163 /* ArrowFunction */: + case 164 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 205 /* ModuleDeclaration */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 204 /* EnumDeclaration */: - case 227 /* SourceFile */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 206 /* ModuleDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 205 /* EnumDeclaration */: + case 228 /* SourceFile */: return node; } } @@ -4650,12 +4666,12 @@ var ts; if (!node) return node; switch (node.kind) { - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.parent.kind === 202 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4665,9 +4681,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 130 /* Decorator */: + case 131 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 129 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 130 /* 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; @@ -4678,26 +4694,26 @@ var ts; node = node.parent; } break; - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression or NewExpression. @@ -4706,44 +4722,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: // classes are valid targets return true; - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 201 /* ClassDeclaration */; - case 129 /* Parameter */: + return node.parent.kind === 202 /* ClassDeclaration */; + case 130 /* 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 === 201 /* ClassDeclaration */; - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 134 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 202 /* ClassDeclaration */; + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 135 /* 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 === 201 /* ClassDeclaration */; + return node.body && node.parent.kind === 202 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 132 /* PropertyDeclaration */: - case 129 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 130 /* Parameter */: if (node.decorators) { return true; } return false; - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 138 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -4754,10 +4770,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 138 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4775,37 +4791,37 @@ var ts; case 95 /* TrueKeyword */: case 80 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 153 /* ArrayLiteralExpression */: - case 154 /* ObjectLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 159 /* TaggedTemplateExpression */: - case 160 /* TypeAssertionExpression */: - case 161 /* ParenthesizedExpression */: - case 162 /* FunctionExpression */: - case 174 /* ClassExpression */: - case 163 /* ArrowFunction */: - case 166 /* VoidExpression */: - case 164 /* DeleteExpression */: - case 165 /* TypeOfExpression */: - case 167 /* PrefixUnaryExpression */: - case 168 /* PostfixUnaryExpression */: - case 169 /* BinaryExpression */: - case 170 /* ConditionalExpression */: - case 173 /* SpreadElementExpression */: - case 171 /* TemplateExpression */: + case 154 /* ArrayLiteralExpression */: + case 155 /* ObjectLiteralExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 160 /* TaggedTemplateExpression */: + case 161 /* TypeAssertionExpression */: + case 162 /* ParenthesizedExpression */: + case 163 /* FunctionExpression */: + case 175 /* ClassExpression */: + case 164 /* ArrowFunction */: + case 167 /* VoidExpression */: + case 165 /* DeleteExpression */: + case 166 /* TypeOfExpression */: + case 168 /* PrefixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: + case 170 /* BinaryExpression */: + case 171 /* ConditionalExpression */: + case 174 /* SpreadElementExpression */: + case 172 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 175 /* OmittedExpression */: + case 176 /* OmittedExpression */: return true; - case 126 /* QualifiedName */: - while (node.parent.kind === 126 /* QualifiedName */) { + case 127 /* QualifiedName */: + while (node.parent.kind === 127 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 144 /* TypeQuery */; + return node.parent.kind === 145 /* TypeQuery */; case 65 /* Identifier */: - if (node.parent.kind === 144 /* TypeQuery */) { + if (node.parent.kind === 145 /* TypeQuery */) { return true; } // fall through @@ -4813,42 +4829,42 @@ var ts; case 8 /* StringLiteral */: var parent_1 = node.parent; switch (parent_1.kind) { - case 198 /* VariableDeclaration */: - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 226 /* EnumMember */: - case 224 /* PropertyAssignment */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 227 /* EnumMember */: + case 225 /* PropertyAssignment */: + case 153 /* BindingElement */: return parent_1.initializer === node; - case 182 /* ExpressionStatement */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 191 /* ReturnStatement */: - case 192 /* WithStatement */: - case 193 /* SwitchStatement */: - case 220 /* CaseClause */: - case 195 /* ThrowStatement */: - case 193 /* SwitchStatement */: + case 183 /* ExpressionStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 192 /* ReturnStatement */: + case 193 /* WithStatement */: + case 194 /* SwitchStatement */: + case 221 /* CaseClause */: + case 196 /* ThrowStatement */: + case 194 /* SwitchStatement */: return parent_1.expression === node; - case 186 /* ForStatement */: + case 187 /* ForStatement */: var forStatement = parent_1; - return (forStatement.initializer === node && forStatement.initializer.kind !== 199 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 200 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: var forInStatement = parent_1; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 199 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200 /* VariableDeclarationList */) || forInStatement.expression === node; - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return node === parent_1.expression; - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return node === parent_1.expression; - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: return node === parent_1.expression; - case 130 /* Decorator */: + case 131 /* Decorator */: return true; default: if (isExpression(parent_1)) { @@ -4866,7 +4882,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 219 /* ExternalModuleReference */; + return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4875,40 +4891,40 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 219 /* ExternalModuleReference */; + return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 220 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 209 /* ImportDeclaration */) { + if (node.kind === 210 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 208 /* ImportEqualsDeclaration */) { + if (node.kind === 209 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 219 /* ExternalModuleReference */) { + if (reference.kind === 220 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 215 /* ExportDeclaration */) { + if (node.kind === 216 /* ExportDeclaration */) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 129 /* Parameter */ && node.dotDotDotToken !== undefined; + return node && node.kind === 130 /* Parameter */ && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 129 /* Parameter */: + case 130 /* Parameter */: return node.questionToken !== undefined; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return node.questionToken !== undefined; - case 225 /* ShorthandPropertyAssignment */: - case 224 /* PropertyAssignment */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 226 /* ShorthandPropertyAssignment */: + case 225 /* PropertyAssignment */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -4916,7 +4932,7 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; + return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { @@ -4932,7 +4948,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 151 /* ArrayBindingPattern */ || node.kind === 150 /* ObjectBindingPattern */); + return !!node && (node.kind === 152 /* ArrayBindingPattern */ || node.kind === 151 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4947,33 +4963,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 163 /* ArrowFunction */: - case 152 /* BindingElement */: - case 201 /* ClassDeclaration */: - case 135 /* Constructor */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 217 /* ExportSpecifier */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 136 /* GetAccessor */: - case 210 /* ImportClause */: - case 208 /* ImportEqualsDeclaration */: - case 213 /* ImportSpecifier */: - case 202 /* InterfaceDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 205 /* ModuleDeclaration */: - case 211 /* NamespaceImport */: - case 129 /* Parameter */: - case 224 /* PropertyAssignment */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 137 /* SetAccessor */: - case 225 /* ShorthandPropertyAssignment */: - case 203 /* TypeAliasDeclaration */: - case 128 /* TypeParameter */: - case 198 /* VariableDeclaration */: + case 164 /* ArrowFunction */: + case 153 /* BindingElement */: + case 202 /* ClassDeclaration */: + case 136 /* Constructor */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 218 /* ExportSpecifier */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 137 /* GetAccessor */: + case 211 /* ImportClause */: + case 209 /* ImportEqualsDeclaration */: + case 214 /* ImportSpecifier */: + case 203 /* InterfaceDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 206 /* ModuleDeclaration */: + case 212 /* NamespaceImport */: + case 130 /* Parameter */: + case 225 /* PropertyAssignment */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 138 /* SetAccessor */: + case 226 /* ShorthandPropertyAssignment */: + case 204 /* TypeAliasDeclaration */: + case 129 /* TypeParameter */: + case 199 /* VariableDeclaration */: return true; } return false; @@ -4981,25 +4997,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 197 /* DebuggerStatement */: - case 184 /* DoStatement */: - case 182 /* ExpressionStatement */: - case 181 /* EmptyStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 186 /* ForStatement */: - case 183 /* IfStatement */: - case 194 /* LabeledStatement */: - case 191 /* ReturnStatement */: - case 193 /* SwitchStatement */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 198 /* DebuggerStatement */: + case 185 /* DoStatement */: + case 183 /* ExpressionStatement */: + case 182 /* EmptyStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 187 /* ForStatement */: + case 184 /* IfStatement */: + case 195 /* LabeledStatement */: + case 192 /* ReturnStatement */: + case 194 /* SwitchStatement */: case 94 /* ThrowKeyword */: - case 196 /* TryStatement */: - case 180 /* VariableStatement */: - case 185 /* WhileStatement */: - case 192 /* WithStatement */: - case 214 /* ExportAssignment */: + case 197 /* TryStatement */: + case 181 /* VariableStatement */: + case 186 /* WhileStatement */: + case 193 /* WithStatement */: + case 215 /* ExportAssignment */: return true; default: return false; @@ -5008,13 +5024,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 135 /* Constructor */: - case 132 /* PropertyDeclaration */: - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 133 /* MethodSignature */: - case 140 /* IndexSignature */: + case 136 /* Constructor */: + case 133 /* PropertyDeclaration */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 134 /* MethodSignature */: + case 141 /* IndexSignature */: return true; default: return false; @@ -5027,7 +5043,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 213 /* ImportSpecifier */ || parent.kind === 217 /* ExportSpecifier */) { + if (parent.kind === 214 /* ImportSpecifier */ || parent.kind === 218 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5047,12 +5063,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 208 /* ImportEqualsDeclaration */ || - node.kind === 210 /* ImportClause */ && !!node.name || - node.kind === 211 /* NamespaceImport */ || - node.kind === 213 /* ImportSpecifier */ || - node.kind === 217 /* ExportSpecifier */ || - node.kind === 214 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 209 /* ImportEqualsDeclaration */ || + node.kind === 211 /* ImportClause */ && !!node.name || + node.kind === 212 /* NamespaceImport */ || + node.kind === 214 /* ImportSpecifier */ || + node.kind === 218 /* ExportSpecifier */ || + node.kind === 215 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5135,7 +5151,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 125 /* LastKeyword */; + return 66 /* FirstKeyword */ <= token && token <= 126 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5151,7 +5167,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 127 /* ComputedPropertyName */ && + declaration.name.kind === 128 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5161,14 +5177,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 155 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 156 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 127 /* ComputedPropertyName */) { + if (name.kind === 128 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5205,7 +5221,7 @@ var ts; } ts.isModifier = isModifier; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 205 /* ModuleDeclaration */ || n.kind === 227 /* SourceFile */; + return isFunctionLike(n) || n.kind === 206 /* ModuleDeclaration */ || n.kind === 228 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5380,7 +5396,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); } } } @@ -5441,7 +5457,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 135 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 136 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -5449,8 +5465,10 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; + if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + // 1. in-browser single file compilation scenario + // 2. non .js file + return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -5464,10 +5482,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 136 /* GetAccessor */) { + if (accessor.kind === 137 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 137 /* SetAccessor */) { + else if (accessor.kind === 138 /* SetAccessor */) { setAccessor = accessor; } else { @@ -5476,7 +5494,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 136 /* GetAccessor */ || member.kind === 137 /* SetAccessor */) + if ((member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5487,10 +5505,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 136 /* GetAccessor */ && !getAccessor) { + if (member.kind === 137 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 137 /* SetAccessor */ && !setAccessor) { + if (member.kind === 138 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -5638,22 +5656,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 158 /* NewExpression */: - case 157 /* CallExpression */: - case 159 /* TaggedTemplateExpression */: - case 153 /* ArrayLiteralExpression */: - case 161 /* ParenthesizedExpression */: - case 154 /* ObjectLiteralExpression */: - case 174 /* ClassExpression */: - case 162 /* FunctionExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 159 /* NewExpression */: + case 158 /* CallExpression */: + case 160 /* TaggedTemplateExpression */: + case 154 /* ArrayLiteralExpression */: + case 162 /* ParenthesizedExpression */: + case 155 /* ObjectLiteralExpression */: + case 175 /* ClassExpression */: + case 163 /* FunctionExpression */: case 65 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: case 80 /* FalseKeyword */: case 89 /* NullKeyword */: case 93 /* ThisKeyword */: @@ -5671,30 +5689,97 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). - function isSupportedHeritageClauseElement(node) { - return isSupportedHeritageClauseElementExpression(node.expression); + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } - ts.isSupportedHeritageClauseElement = isSupportedHeritageClauseElement; - function isSupportedHeritageClauseElementExpression(node) { + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { if (node.kind === 65 /* Identifier */) { return true; } - else if (node.kind === 155 /* PropertyAccessExpression */) { - return isSupportedHeritageClauseElementExpression(node.expression); + else if (node.kind === 156 /* PropertyAccessExpression */) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { return false; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 126 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + /** + * Replace each instance of non-ascii characters by one, two, three, or four escape sequences + * representing the UTF-8 encoding of the character, and return the expanded char code list. + */ + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + var leadSurrogate = undefined; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + // handel utf8 + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + /** + * Converts a string to a base-64 encoded ASCII string. + */ + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + // Convert every 6-bits in the input 3 character points + // into a base64 digit + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + // We are out of characters in the input, set the extra + // digits to 64 (padding character). + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + // Write to the ouput + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; })(ts || (ts = {})); var ts; (function (ts) { @@ -5906,7 +5991,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(229 /* Count */); + var nodeConstructors = new Array(230 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5951,20 +6036,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5973,24 +6058,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6001,220 +6086,220 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 141 /* TypeReference */: + case 142 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 147 /* TupleType */: + case 148 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 148 /* UnionType */: + case 149 /* UnionType */: return visitNodes(cbNodes, node.types); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 155 /* PropertyAccessExpression */: + case 156 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 164 /* DeleteExpression */: + case 165 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 165 /* TypeOfExpression */: + case 166 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 166 /* VoidExpression */: + case 167 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 172 /* YieldExpression */: + case 173 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 168 /* PostfixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 173 /* SpreadElementExpression */: + case 174 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 227 /* SourceFile */: + case 228 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 199 /* VariableDeclarationList */: + case 200 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 183 /* IfStatement */: + case 184 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 184 /* DoStatement */: + case 185 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 187 /* ForInStatement */: + case 188 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 188 /* ForOfStatement */: + case 189 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: return visitNode(cbNode, node.label); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 192 /* WithStatement */: + case 193 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 207 /* CaseBlock */: + case 208 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 220 /* CaseClause */: + case 221 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 221 /* DefaultClause */: + case 222 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 196 /* TryStatement */: + case 197 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 130 /* Decorator */: + case 131 /* Decorator */: return visitNode(cbNode, node.expression); - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: + case 202 /* ClassDeclaration */: + case 175 /* 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 202 /* InterfaceDeclaration */: + case 203 /* 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 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 210 /* ImportClause */: + case 211 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 211 /* NamespaceImport */: + case 212 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 212 /* NamedImports */: - case 216 /* NamedExports */: + case 213 /* NamedImports */: + case 217 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 222 /* HeritageClause */: + case 223 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 177 /* HeritageClauseElement */: + case 177 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 219 /* ExternalModuleReference */: + case 220 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 218 /* MissingDeclaration */: + case 219 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); } } @@ -6393,7 +6478,7 @@ var ts; } } function createSourceFile(fileName, languageVersion) { - sourceFile = createNode(227 /* SourceFile */, 0); + sourceFile = createNode(228 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6735,7 +6820,7 @@ var ts; // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] // - var node = createNode(127 /* ComputedPropertyName */); + var node = createNode(128 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -7127,14 +7212,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 215 /* ExportDeclaration */: - case 214 /* ExportAssignment */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 216 /* ExportDeclaration */: + case 215 /* ExportAssignment */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: return true; } return isReusableStatement(node); @@ -7144,13 +7229,13 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 135 /* Constructor */: - case 140 /* IndexSignature */: - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 132 /* PropertyDeclaration */: - case 178 /* SemicolonClassElement */: + case 136 /* Constructor */: + case 141 /* IndexSignature */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 179 /* SemicolonClassElement */: return true; } } @@ -7159,8 +7244,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: return true; } } @@ -7169,49 +7254,49 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 180 /* VariableStatement */: - case 179 /* Block */: - case 183 /* IfStatement */: - case 182 /* ExpressionStatement */: - case 195 /* ThrowStatement */: - case 191 /* ReturnStatement */: - case 193 /* SwitchStatement */: - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 186 /* ForStatement */: - case 185 /* WhileStatement */: - case 192 /* WithStatement */: - case 181 /* EmptyStatement */: - case 196 /* TryStatement */: - case 194 /* LabeledStatement */: - case 184 /* DoStatement */: - case 197 /* DebuggerStatement */: + case 201 /* FunctionDeclaration */: + case 181 /* VariableStatement */: + case 180 /* Block */: + case 184 /* IfStatement */: + case 183 /* ExpressionStatement */: + case 196 /* ThrowStatement */: + case 192 /* ReturnStatement */: + case 194 /* SwitchStatement */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 187 /* ForStatement */: + case 186 /* WhileStatement */: + case 193 /* WithStatement */: + case 182 /* EmptyStatement */: + case 197 /* TryStatement */: + case 195 /* LabeledStatement */: + case 185 /* DoStatement */: + case 198 /* DebuggerStatement */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 226 /* EnumMember */; + return node.kind === 227 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 139 /* ConstructSignature */: - case 133 /* MethodSignature */: - case 140 /* IndexSignature */: - case 131 /* PropertySignature */: - case 138 /* CallSignature */: + case 140 /* ConstructSignature */: + case 134 /* MethodSignature */: + case 141 /* IndexSignature */: + case 132 /* PropertySignature */: + case 139 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 198 /* VariableDeclaration */) { + if (node.kind !== 199 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -7232,7 +7317,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 129 /* Parameter */) { + if (node.kind !== 130 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -7344,7 +7429,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(126 /* QualifiedName */, entity.pos); + var node = createNode(127 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7383,20 +7468,20 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(171 /* TemplateExpression */); + var template = createNode(172 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(176 /* TemplateSpan */); + var span = createNode(178 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -7437,7 +7522,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(141 /* TypeReference */); + var node = createNode(142 /* TypeReference */); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); @@ -7445,13 +7530,13 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(144 /* TypeQuery */); + var node = createNode(145 /* TypeQuery */); parseExpected(97 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(128 /* TypeParameter */); + var node = createNode(129 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(79 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -7497,7 +7582,7 @@ var ts; } } function parseParameter() { - var node = createNode(129 /* Parameter */); + var node = createNode(130 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); @@ -7594,7 +7679,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 139 /* ConstructSignature */) { + if (kind === 140 /* ConstructSignature */) { parseExpected(88 /* NewKeyword */); } fillSignature(51 /* ColonToken */, false, false, node); @@ -7658,7 +7743,7 @@ var ts; return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(140 /* IndexSignature */, fullStart); + var node = createNode(141 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); @@ -7671,7 +7756,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(133 /* MethodSignature */, fullStart); + var method = createNode(134 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -7681,7 +7766,7 @@ var ts; return finishNode(method); } else { - var property = createNode(131 /* PropertySignature */, fullStart); + var property = createNode(132 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7723,7 +7808,7 @@ var ts; switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(138 /* CallSignature */); + return parseSignatureMember(139 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -7731,7 +7816,7 @@ var ts; : parsePropertyOrMethodSignature(); case 88 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(139 /* ConstructSignature */); + return parseSignatureMember(140 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -7768,7 +7853,7 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(145 /* TypeLiteral */); + var node = createNode(146 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7784,12 +7869,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(147 /* TupleType */); + var node = createNode(148 /* TupleType */); node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(149 /* ParenthesizedType */); + var node = createNode(150 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -7797,7 +7882,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 143 /* ConstructorType */) { + if (kind === 144 /* ConstructorType */) { parseExpected(88 /* NewKeyword */); } fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); @@ -7810,10 +7895,10 @@ var ts; function parseNonArrayType() { switch (token) { case 112 /* AnyKeyword */: - case 121 /* StringKeyword */: - case 119 /* NumberKeyword */: + case 122 /* StringKeyword */: + case 120 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -7834,10 +7919,10 @@ var ts; function isStartOfType() { switch (token) { case 112 /* AnyKeyword */: - case 121 /* StringKeyword */: - case 119 /* NumberKeyword */: + case 122 /* StringKeyword */: + case 120 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 97 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: @@ -7861,7 +7946,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(146 /* ArrayType */, type.pos); + var node = createNode(147 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -7876,7 +7961,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(148 /* UnionType */, type.pos); + var node = createNode(149 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } @@ -7931,10 +8016,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(142 /* FunctionType */); + return parseFunctionOrConstructorType(143 /* FunctionType */); } if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(143 /* ConstructorType */); + return parseFunctionOrConstructorType(144 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -8136,7 +8221,7 @@ var ts; (isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */); } function parseYieldExpression() { - var node = createNode(172 /* YieldExpression */); + var node = createNode(173 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -8156,8 +8241,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(163 /* ArrowFunction */, identifier.pos); - var parameter = createNode(129 /* Parameter */, identifier.pos); + var node = createNode(164 /* ArrowFunction */, identifier.pos); + var parameter = createNode(130 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8275,7 +8360,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(163 /* ArrowFunction */); + var node = createNode(164 /* ArrowFunction */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -8336,7 +8421,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(170 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(171 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8349,7 +8434,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 125 /* OfKeyword */; + return t === 86 /* InKeyword */ || t === 126 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -8415,33 +8500,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(169 /* BinaryExpression */, left.pos); + var node = createNode(170 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(167 /* PrefixUnaryExpression */); + var node = createNode(168 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(164 /* DeleteExpression */); + var node = createNode(165 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(165 /* TypeOfExpression */); + var node = createNode(166 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(166 /* VoidExpression */); + var node = createNode(167 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -8471,7 +8556,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(168 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(169 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -8575,14 +8660,14 @@ 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(155 /* PropertyAccessExpression */, expression.pos); + var node = createNode(156 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(160 /* TypeAssertionExpression */); + var node = createNode(161 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); parseExpected(25 /* GreaterThanToken */); @@ -8593,7 +8678,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(155 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(156 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8602,7 +8687,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(156 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(157 /* 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. @@ -8618,7 +8703,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(159 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(160 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -8641,7 +8726,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(157 /* CallExpression */, expression.pos); + var callExpr = createNode(158 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8649,7 +8734,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(157 /* CallExpression */, expression.pos); + var callExpr = createNode(158 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8751,28 +8836,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(161 /* ParenthesizedExpression */); + var node = createNode(162 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(173 /* SpreadElementExpression */); + var node = createNode(174 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(175 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(176 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(153 /* ArrayLiteralExpression */); + var node = createNode(154 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 512 /* MultiLine */; @@ -8782,10 +8867,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(136 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(137 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(120 /* SetKeyword */)) { - return parseAccessorDeclaration(137 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(121 /* SetKeyword */)) { + return parseAccessorDeclaration(138 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -8808,13 +8893,13 @@ var ts; } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(225 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(226 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(224 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(225 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51 /* ColonToken */); @@ -8823,7 +8908,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(154 /* ObjectLiteralExpression */); + var node = createNode(155 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512 /* MultiLine */; @@ -8841,7 +8926,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(162 /* FunctionExpression */); + var node = createNode(163 /* FunctionExpression */); parseExpected(83 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -8856,7 +8941,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(158 /* NewExpression */); + var node = createNode(159 /* NewExpression */); parseExpected(88 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -8867,7 +8952,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(179 /* Block */); + var node = createNode(180 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); parseExpected(15 /* CloseBraceToken */); @@ -8894,12 +8979,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(181 /* EmptyStatement */); + var node = createNode(182 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(183 /* IfStatement */); + var node = createNode(184 /* IfStatement */); parseExpected(84 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -8909,7 +8994,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(184 /* DoStatement */); + var node = createNode(185 /* DoStatement */); parseExpected(75 /* DoKeyword */); node.statement = parseStatement(); parseExpected(100 /* WhileKeyword */); @@ -8924,7 +9009,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(185 /* WhileStatement */); + var node = createNode(186 /* WhileStatement */); parseExpected(100 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -8947,21 +9032,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(187 /* ForInStatement */, pos); + var forInStatement = createNode(188 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(125 /* OfKeyword */)) { - var forOfStatement = createNode(188 /* ForOfStatement */, pos); + else if (parseOptional(126 /* OfKeyword */)) { + var forOfStatement = createNode(189 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(186 /* ForStatement */, pos); + var forStatement = createNode(187 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -8979,7 +9064,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 190 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8987,7 +9072,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(191 /* ReturnStatement */); + var node = createNode(192 /* ReturnStatement */); parseExpected(90 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -8996,7 +9081,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(192 /* WithStatement */); + var node = createNode(193 /* WithStatement */); parseExpected(101 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9005,7 +9090,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(220 /* CaseClause */); + var node = createNode(221 /* CaseClause */); parseExpected(67 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(51 /* ColonToken */); @@ -9013,7 +9098,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(221 /* DefaultClause */); + var node = createNode(222 /* DefaultClause */); parseExpected(73 /* DefaultKeyword */); parseExpected(51 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); @@ -9023,12 +9108,12 @@ var ts; return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(193 /* SwitchStatement */); + var node = createNode(194 /* SwitchStatement */); parseExpected(92 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(207 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(208 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); caseBlock.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); @@ -9043,7 +9128,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(195 /* ThrowStatement */); + var node = createNode(196 /* ThrowStatement */); parseExpected(94 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -9051,7 +9136,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(196 /* TryStatement */); + var node = createNode(197 /* TryStatement */); parseExpected(96 /* TryKeyword */); node.tryBlock = parseBlock(false, false); node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -9064,7 +9149,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(223 /* CatchClause */); + var result = createNode(224 /* CatchClause */); parseExpected(68 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -9074,7 +9159,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(197 /* DebuggerStatement */); + var node = createNode(198 /* DebuggerStatement */); parseExpected(72 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -9086,13 +9171,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(194 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(195 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(182 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(183 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -9150,8 +9235,9 @@ var ts; return !isConstEnum; case 103 /* InterfaceKeyword */: case 117 /* ModuleKeyword */: + case 118 /* NamespaceKeyword */: case 77 /* EnumKeyword */: - case 123 /* TypeKeyword */: + case 124 /* TypeKeyword */: // When followed by an identifier, these do not start a statement but might // instead be following declarations if (isDeclarationStart()) { @@ -9201,9 +9287,9 @@ var ts; case 82 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(189 /* ContinueStatement */); + return parseBreakOrContinueStatement(190 /* ContinueStatement */); case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(190 /* BreakStatement */); + return parseBreakOrContinueStatement(191 /* BreakStatement */); case 90 /* ReturnKeyword */: return parseReturnStatement(); case 101 /* WithKeyword */: @@ -9278,16 +9364,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(175 /* OmittedExpression */); + return createNode(176 /* OmittedExpression */); } - var node = createNode(152 /* BindingElement */); + var node = createNode(153 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(152 /* BindingElement */); + var node = createNode(153 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -9303,14 +9389,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(150 /* ObjectBindingPattern */); + var node = createNode(151 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); node.elements = parseDelimitedList(10 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(151 /* ArrayBindingPattern */); + var node = createNode(152 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); node.elements = parseDelimitedList(11 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); @@ -9329,7 +9415,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(198 /* VariableDeclaration */); + var node = createNode(199 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -9338,7 +9424,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(199 /* VariableDeclarationList */); + var node = createNode(200 /* VariableDeclarationList */); switch (token) { case 98 /* VarKeyword */: break; @@ -9361,7 +9447,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 === 125 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 126 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -9376,7 +9462,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(180 /* VariableStatement */, fullStart); + var node = createNode(181 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -9384,7 +9470,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(200 /* FunctionDeclaration */, fullStart); + var node = createNode(201 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83 /* FunctionKeyword */); @@ -9395,7 +9481,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(135 /* Constructor */, pos); + var node = createNode(136 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114 /* ConstructorKeyword */); @@ -9404,7 +9490,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(134 /* MethodDeclaration */, fullStart); + var method = createNode(135 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -9415,7 +9501,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(132 /* PropertyDeclaration */, fullStart); + var property = createNode(133 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -9496,7 +9582,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 120 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 121 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -9530,7 +9616,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(130 /* Decorator */, decoratorStart); + var decorator = createNode(131 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -9563,7 +9649,7 @@ var ts; } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(178 /* SemicolonClassElement */); + var result = createNode(179 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -9601,10 +9687,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart:*/ scanner.getStartPos(), /*decorators:*/ undefined, - /*modifiers:*/ undefined, 174 /* ClassExpression */); + /*modifiers:*/ undefined, 175 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 201 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code @@ -9649,16 +9735,16 @@ var ts; } function parseHeritageClause() { if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(222 /* HeritageClause */); + var node = createNode(223 /* HeritageClause */); node.token = token; nextToken(); - node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseHeritageClauseElement); + node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } - function parseHeritageClauseElement() { - var node = createNode(177 /* HeritageClauseElement */); + function parseExpressionWithTypeArguments() { + var node = createNode(177 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); @@ -9672,7 +9758,7 @@ var ts; return parseList(6 /* ClassMembers */, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(202 /* InterfaceDeclaration */, fullStart); + var node = createNode(203 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103 /* InterfaceKeyword */); @@ -9683,10 +9769,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* TypeAliasDeclaration */, fullStart); + var node = createNode(204 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(123 /* TypeKeyword */); + parseExpected(124 /* TypeKeyword */); node.name = parseIdentifier(); parseExpected(53 /* EqualsToken */); node.type = parseType(); @@ -9698,13 +9784,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(226 /* EnumMember */, scanner.getStartPos()); + var node = createNode(227 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204 /* EnumDeclaration */, fullStart); + var node = createNode(205 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77 /* EnumKeyword */); @@ -9719,7 +9805,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(206 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(207 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); parseExpected(15 /* CloseBraceToken */); @@ -9729,19 +9815,19 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { - var node = createNode(205 /* ModuleDeclaration */, fullStart); + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(206 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20 /* DotToken */) - ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1 /* Export */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* ModuleDeclaration */, fullStart); + var node = createNode(206 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9749,13 +9835,20 @@ var ts; return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { - parseExpected(117 /* ModuleKeyword */); - return token === 8 /* StringLiteral */ - ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) - : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(118 /* NamespaceKeyword */)) { + flags |= 32768 /* Namespace */; + } + else { + parseExpected(117 /* ModuleKeyword */); + if (token === 8 /* StringLiteral */) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 118 /* RequireKeyword */ && + return token === 119 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -9764,7 +9857,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 124 /* FromKeyword */; + token === 125 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85 /* ImportKeyword */); @@ -9772,11 +9865,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 124 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 125 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(208 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(209 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -9787,7 +9880,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(209 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(210 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -9797,7 +9890,7 @@ var ts; token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(124 /* FromKeyword */); + parseExpected(125 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -9810,7 +9903,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(210 /* ImportClause */, fullStart); + var importClause = createNode(211 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -9820,7 +9913,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(212 /* NamedImports */); + importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(213 /* NamedImports */); } return finishNode(importClause); } @@ -9830,8 +9923,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(219 /* ExternalModuleReference */); - parseExpected(118 /* RequireKeyword */); + var node = createNode(220 /* ExternalModuleReference */); + parseExpected(119 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -9852,7 +9945,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(211 /* NamespaceImport */); + var namespaceImport = createNode(212 /* NamespaceImport */); parseExpected(35 /* AsteriskToken */); parseExpected(111 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -9867,14 +9960,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 212 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 213 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(217 /* ExportSpecifier */); + return parseImportOrExportSpecifier(218 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(213 /* ImportSpecifier */); + return parseImportOrExportSpecifier(214 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9899,23 +9992,23 @@ var ts; else { node.name = identifierName; } - if (kind === 213 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 214 /* 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(215 /* ExportDeclaration */, fullStart); + var node = createNode(216 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(124 /* FromKeyword */); + parseExpected(125 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(216 /* NamedExports */); - if (parseOptional(124 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(217 /* NamedExports */); + if (parseOptional(125 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9923,7 +10016,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(214 /* ExportAssignment */, fullStart); + var node = createNode(215 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53 /* EqualsToken */)) { @@ -9952,13 +10045,14 @@ var ts; case 69 /* ClassKeyword */: case 103 /* InterfaceKeyword */: case 77 /* EnumKeyword */: - case 123 /* TypeKeyword */: + case 124 /* TypeKeyword */: // Not true keywords so ensure an identifier follows return lookAhead(nextTokenIsIdentifierOrKeyword); case 85 /* ImportKeyword */: // Not true keywords so ensure an identifier follows or is string literal or asterisk or open brace return lookAhead(nextTokenCanFollowImportKeyword); case 117 /* ModuleKeyword */: + case 118 /* NamespaceKeyword */: // Not a true keyword so ensure an identifier or string literal follows return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); case 78 /* ExportKeyword */: @@ -10029,11 +10123,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 123 /* TypeKeyword */: + case 124 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); case 117 /* ModuleKeyword */: + case 118 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -10041,7 +10136,7 @@ var ts; if (decorators) { // We reached this point because we encountered an AtToken and assumed a declaration would // follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(218 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(219 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10124,10 +10219,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 208 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 219 /* ExternalModuleReference */ - || node.kind === 209 /* ImportDeclaration */ - || node.kind === 214 /* ExportAssignment */ - || node.kind === 215 /* ExportDeclaration */ + || node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */ + || node.kind === 210 /* ImportDeclaration */ + || node.kind === 215 /* ExportAssignment */ + || node.kind === 216 /* ExportDeclaration */ ? node : undefined; }); @@ -10710,7 +10805,6 @@ var ts; var undefinedType = createIntrinsicType(32 /* Undefined */ | 262144 /* ContainsUndefinedOrNull */, "undefined"); var nullType = createIntrinsicType(64 /* Null */ | 262144 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var resolvingType = createIntrinsicType(1 /* Any */, "__resolving__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -10740,6 +10834,8 @@ var ts; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var resolutionTargets = []; + var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10905,10 +11001,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 227 /* SourceFile */); + return ts.getAncestor(node, 228 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 227 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 228 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10957,40 +11053,40 @@ var ts; } } switch (location.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { - if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 217 /* ExportSpecifier */)) { + if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 218 /* ExportSpecifier */)) { break loop; } result = undefined; } - else if (location.kind === 227 /* SourceFile */ || - (location.kind === 205 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { - result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & 8914931 /* ModuleMember */); + else if (location.kind === 228 /* SourceFile */ || + (location.kind === 206 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + result = getSymbolOfNode(location).exports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) { + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* 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 // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === 201 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (location.parent.kind === 202 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -11000,8 +11096,8 @@ var ts; } } break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -11021,9 +11117,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (grandparent.kind === 201 /* ClassDeclaration */ || grandparent.kind === 202 /* InterfaceDeclaration */) { + if (grandparent.kind === 202 /* ClassDeclaration */ || grandparent.kind === 203 /* 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); @@ -11031,19 +11127,19 @@ var ts; } } break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 162 /* FunctionExpression */: + case 163 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -11054,14 +11150,14 @@ var ts; break loop; } break; - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: var className = location.name; if (className && name === className.text) { result = location.symbol; break loop; } break; - case 130 /* Decorator */: + case 131 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -11070,7 +11166,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 === 129 /* Parameter */) { + if (location.parent && location.parent.kind === 130 /* Parameter */) { location = location.parent; } // @@ -11126,16 +11222,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 198 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 199 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 180 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 186 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 181 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 187 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 188 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 187 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 188 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -11162,10 +11258,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 208 /* ImportEqualsDeclaration */) { + if (node.kind === 209 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 209 /* ImportDeclaration */) { + while (node && node.kind !== 210 /* ImportDeclaration */) { node = node.parent; } return node; @@ -11175,7 +11271,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 219 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 220 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11185,7 +11281,7 @@ var ts; if (moduleSymbol) { var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } return exportDefaultSymbol; } @@ -11282,17 +11378,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 210 /* ImportClause */: + case 211 /* ImportClause */: return getTargetOfImportClause(node); - case 211 /* NamespaceImport */: + case 212 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 213 /* ImportSpecifier */: + case 214 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 217 /* ExportSpecifier */: + case 218 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -11337,11 +11433,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 214 /* ExportAssignment */) { + if (node.kind === 215 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 217 /* ExportSpecifier */) { + else if (node.kind === 218 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -11354,7 +11450,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 208 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 209 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -11367,13 +11463,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 126 /* QualifiedName */) { + if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 127 /* 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 === 208 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 209 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -11387,14 +11483,15 @@ var ts; } var symbol; if (name.kind === 65 /* Identifier */) { - symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); + var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, message, name); if (!symbol) { return undefined; } } - else if (name.kind === 126 /* QualifiedName */ || name.kind === 155 /* PropertyAccessExpression */) { - var left = name.kind === 126 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 126 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 127 /* QualifiedName */ || name.kind === 156 /* PropertyAccessExpression */) { + var left = name.kind === 127 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 127 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11451,10 +11548,10 @@ var ts; if (sourceFile.symbol) { return sourceFile.symbol; } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.fileName); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); return; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); } // 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. @@ -11467,7 +11564,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { - error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } return symbol; @@ -11554,7 +11651,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 135 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 136 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -11624,17 +11721,17 @@ var ts; } } switch (location_1.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11783,8 +11880,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 205 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 227 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 206 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 228 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11820,12 +11917,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 144 /* TypeQuery */) { + if (entityName.parent.kind === 145 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 126 /* QualifiedName */ || entityName.kind === 155 /* PropertyAccessExpression */ || - entityName.parent.kind === 208 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 127 /* QualifiedName */ || entityName.kind === 156 /* PropertyAccessExpression */ || + entityName.parent.kind === 209 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -11873,10 +11970,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 149 /* ParenthesizedType */) { + while (node.kind === 150 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 203 /* TypeAliasDeclaration */) { + if (node.kind === 204 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -12080,7 +12177,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 227 /* SourceFile */ || declaration.parent.kind === 206 /* ModuleBlock */; + return declaration.parent.kind === 228 /* SourceFile */ || declaration.parent.kind === 207 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -12159,7 +12256,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 121 /* StringKeyword */); + writeKeyword(writer, 122 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -12173,7 +12270,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 119 /* NumberKeyword */); + writeKeyword(writer, 120 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -12319,12 +12416,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 205 /* ModuleDeclaration */) { + if (node.kind === 206 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 227 /* SourceFile */) { + else if (node.kind === 228 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -12373,69 +12470,69 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 152 /* BindingElement */: + case 153 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 198 /* VariableDeclaration */: + case 199 /* 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 205 /* ModuleDeclaration */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 200 /* FunctionDeclaration */: - case 204 /* EnumDeclaration */: - case 208 /* ImportEqualsDeclaration */: + case 206 /* ModuleDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 201 /* FunctionDeclaration */: + case 205 /* EnumDeclaration */: + case 209 /* ImportEqualsDeclaration */: var parent_2 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 208 /* ImportEqualsDeclaration */ && parent_2.kind !== 227 /* SourceFile */ && ts.isInAmbientContext(parent_2))) { + !(node.kind !== 209 /* ImportEqualsDeclaration */ && parent_2.kind !== 228 /* SourceFile */ && ts.isInAmbientContext(parent_2))) { return isGlobalSourceFile(parent_2); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_2); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 135 /* Constructor */: - case 139 /* ConstructSignature */: - case 138 /* CallSignature */: - case 140 /* IndexSignature */: - case 129 /* Parameter */: - case 206 /* ModuleBlock */: - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 145 /* TypeLiteral */: - case 141 /* TypeReference */: - case 146 /* ArrayType */: - case 147 /* TupleType */: - case 148 /* UnionType */: - case 149 /* ParenthesizedType */: + case 136 /* Constructor */: + case 140 /* ConstructSignature */: + case 139 /* CallSignature */: + case 141 /* IndexSignature */: + case 130 /* Parameter */: + case 207 /* ModuleBlock */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 146 /* TypeLiteral */: + case 142 /* TypeReference */: + case 147 /* ArrayType */: + case 148 /* TupleType */: + case 149 /* UnionType */: + case 150 /* 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 210 /* ImportClause */: - case 211 /* NamespaceImport */: - case 213 /* ImportSpecifier */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: + case 214 /* ImportSpecifier */: return false; // Type parameters are always visible - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: // Source file is always visible - case 227 /* SourceFile */: + case 228 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -12451,10 +12548,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 214 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 215 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 217 /* ExportSpecifier */) { + else if (node.parent.kind === 218 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -12479,8 +12576,37 @@ var ts; }); } } + // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, + // a new entry with that target and an associated result value of true is pushed on the stack, and the value + // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and + // all entries pushed after it are changed to false, and the value false is returned. The target object provides + // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of + // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and + // Signature instances are used to track resolution of Signature.resolvedReturnType. + function pushTypeResolution(target) { + var i = 0; + var count = resolutionTargets.length; + while (i < count && resolutionTargets[i] !== target) { + i++; + } + if (i < count) { + do { + resolutionResults[i++] = false; + } while (i < count); + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + return true; + } + // Pop an entry from the type resolution stack and return its associated result value. The result value will + // be true if no circularities were detected, or false if a circularity was found. + function popTypeResolution() { + resolutionTargets.pop(); + return resolutionResults.pop(); + } function getRootDeclaration(node) { - while (node.kind === 152 /* BindingElement */) { + while (node.kind === 153 /* BindingElement */) { node = node.parent.parent; } return node; @@ -12489,7 +12615,7 @@ var ts; node = getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 198 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 199 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -12522,7 +12648,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 150 /* ObjectBindingPattern */) { + if (pattern.kind === 151 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_5 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -12569,10 +12695,10 @@ 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 === 187 /* ForInStatement */) { + if (declaration.parent.parent.kind === 188 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 188 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 189 /* 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, @@ -12586,11 +12712,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129 /* Parameter */) { + if (declaration.kind === 130 /* 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 === 137 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136 /* GetAccessor */); + if (func.kind === 138 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12606,7 +12732,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 225 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 226 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -12641,7 +12767,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 175 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 176 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -12664,7 +12790,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) { - return pattern.kind === 150 /* ObjectBindingPattern */ + return pattern.kind === 151 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -12686,7 +12812,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 224 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 225 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -12698,7 +12824,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 129 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 130 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12713,28 +12839,33 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 223 /* CatchClause */) { + if (declaration.parent.kind === 224 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 214 /* ExportAssignment */) { + if (declaration.kind === 215 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - links.type = resolvingType; + if (!pushTypeResolution(symbol)) { + return unknownType; + } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var diagnostic = symbol.valueDeclaration.type ? - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation : - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer; - error(symbol.valueDeclaration, diagnostic, symbolToString(symbol)); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + // Variable has type annotation that circularly references the variable itself + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + // Variable has initializer that circularly references the variable itself + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } } + links.type = type; } return links.type; } @@ -12743,7 +12874,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 136 /* GetAccessor */) { + if (accessor.kind === 137 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12755,15 +12886,12 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - checkAndStoreTypeOfAccessors(symbol, links); - return links.type; - } - function checkAndStoreTypeOfAccessors(symbol, links) { - links = links || getSymbolLinks(symbol); if (!links.type) { - links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 136 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 137 /* SetAccessor */); + if (!pushTypeResolution(symbol)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 138 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -12789,17 +12917,16 @@ var ts; } } } - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 136 /* GetAccessor */); - error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 137 /* 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)); + } } + links.type = type; } + return links.type; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -12866,7 +12993,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 202 /* InterfaceDeclaration */ || node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 202 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -12900,10 +13027,10 @@ var ts; } function resolveBaseTypesOfClass(type) { type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 201 /* ClassDeclaration */); + var declaration = ts.getDeclarationOfKind(type.symbol, 202 /* ClassDeclaration */); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); if (baseTypeNode) { - var baseType = getTypeFromHeritageClauseElement(baseTypeNode); + var baseType = getTypeFromTypeNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024 /* Class */) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -12923,10 +13050,10 @@ var ts; type.baseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 202 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 203 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; - var baseType = getTypeFromHeritageClauseElement(node); + var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -12964,17 +13091,18 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 203 /* TypeAliasDeclaration */); - var type = getTypeFromTypeNode(declaration.type); - if (links.declaredType === resolvingType) { - links.declaredType = type; + // Note that we use the links object as the target here because the symbol object is used as the unique + // identity for resolution of the 'type' property in SymbolLinks. + if (!pushTypeResolution(links)) { + return unknownType; } - } - else if (links.declaredType === resolvingType) { - links.declaredType = unknownType; - var declaration = ts.getDeclarationOfKind(symbol, 203 /* TypeAliasDeclaration */); - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 204 /* TypeAliasDeclaration */); + var type = getTypeFromTypeNode(declaration.type); + if (!popTypeResolution()) { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; } return links.declaredType; } @@ -12992,7 +13120,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 128 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -13461,7 +13589,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 136 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13492,8 +13620,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 === 136 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 137 /* SetAccessor */); + if (declaration.kind === 137 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 138 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13511,19 +13639,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 164 /* 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). @@ -13540,7 +13668,9 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - signature.resolvedReturnType = resolvingType; + if (!pushTypeResolution(signature)) { + return unknownType; + } var type; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); @@ -13551,27 +13681,25 @@ var ts; else { type = getReturnTypeFromBody(signature.declaration); } - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = type; - } - } - else if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + } } } + signature.resolvedReturnType = type; } return signature.resolvedReturnType; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -13600,7 +13728,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 === 135 /* Constructor */ || signature.declaration.kind === 139 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 136 /* Constructor */ || signature.declaration.kind === 140 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -13614,7 +13742,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 119 /* NumberKeyword */ : 121 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 120 /* NumberKeyword */ : 122 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -13644,7 +13772,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -13700,13 +13828,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 141 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 142 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -13732,20 +13860,14 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReference(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromHeritageClauseElement(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromTypeReferenceOrHeritageClauseElement(node) { + function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var type; // We don't currently support heritage clauses with complex expressions in them. // For these cases, we just set the type to be the unknownType. - if (node.kind !== 177 /* HeritageClauseElement */ || ts.isSupportedHeritageClauseElement(node)) { - var typeNameOrExpression = node.kind === 141 /* TypeReference */ + if (node.kind !== 177 /* ExpressionWithTypeArguments */ || ts.isSupportedExpressionWithTypeArguments(node)) { + var typeNameOrExpression = node.kind === 142 /* TypeReference */ ? node.typeName : node.expression; var symbol = resolveEntityName(typeNameOrExpression, 793056 /* Type */); @@ -13799,9 +13921,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: return declaration; } } @@ -13999,40 +14121,40 @@ var ts; switch (node.kind) { case 112 /* AnyKeyword */: return anyType; - case 121 /* StringKeyword */: + case 122 /* StringKeyword */: return stringType; - case 119 /* NumberKeyword */: + case 120 /* NumberKeyword */: return numberType; case 113 /* BooleanKeyword */: return booleanType; - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: return esSymbolType; case 99 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 141 /* TypeReference */: - return getTypeFromTypeReference(node); - case 177 /* HeritageClauseElement */: - return getTypeFromHeritageClauseElement(node); - case 144 /* TypeQuery */: + case 142 /* TypeReference */: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + case 177 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + case 145 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 147 /* TupleType */: + case 148 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 148 /* UnionType */: + case 149 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 145 /* TypeLiteral */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 146 /* 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 65 /* Identifier */: - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -14190,27 +14312,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 !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return node.operatorToken.kind === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 224 /* PropertyAssignment */: + case 225 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -15046,22 +15168,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 129 /* Parameter */: + case 130 /* 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 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -15330,10 +15452,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 144 /* TypeQuery */: + case 145 /* TypeQuery */: return true; case 65 /* Identifier */: - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: node = node.parent; continue; default: @@ -15381,7 +15503,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { var n = node.left; - while (n.kind === 161 /* ParenthesizedExpression */) { + while (n.kind === 162 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -15398,46 +15520,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: - case 153 /* ArrayLiteralExpression */: - case 154 /* ObjectLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 160 /* TypeAssertionExpression */: - case 161 /* ParenthesizedExpression */: - case 167 /* PrefixUnaryExpression */: - case 164 /* DeleteExpression */: - case 165 /* TypeOfExpression */: - case 166 /* VoidExpression */: - case 168 /* PostfixUnaryExpression */: - case 170 /* ConditionalExpression */: - case 173 /* SpreadElementExpression */: - case 179 /* Block */: - case 180 /* VariableStatement */: - case 182 /* ExpressionStatement */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 191 /* ReturnStatement */: - case 192 /* WithStatement */: - case 193 /* SwitchStatement */: - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - case 194 /* LabeledStatement */: - case 195 /* ThrowStatement */: - case 196 /* TryStatement */: - case 223 /* CatchClause */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: + case 154 /* ArrayLiteralExpression */: + case 155 /* ObjectLiteralExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 161 /* TypeAssertionExpression */: + case 162 /* ParenthesizedExpression */: + case 168 /* PrefixUnaryExpression */: + case 165 /* DeleteExpression */: + case 166 /* TypeOfExpression */: + case 167 /* VoidExpression */: + case 169 /* PostfixUnaryExpression */: + case 171 /* ConditionalExpression */: + case 174 /* SpreadElementExpression */: + case 180 /* Block */: + case 181 /* VariableStatement */: + case 183 /* ExpressionStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 192 /* ReturnStatement */: + case 193 /* WithStatement */: + case 194 /* SwitchStatement */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: + case 195 /* LabeledStatement */: + case 196 /* ThrowStatement */: + case 197 /* TryStatement */: + case 224 /* CatchClause */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15489,19 +15611,19 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 183 /* IfStatement */: + case 184 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { @@ -15512,14 +15634,14 @@ var ts; } } break; - case 227 /* SourceFile */: - case 205 /* ModuleDeclaration */: - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: + case 228 /* SourceFile */: + case 206 /* ModuleDeclaration */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -15535,7 +15657,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 !== 165 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 166 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; @@ -15610,17 +15732,34 @@ var ts; } // Target type is type of prototype property var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (!prototypeProperty) { - return type; + if (prototypeProperty) { + var targetType = getTypeOfSymbol(prototypeProperty); + if (targetType !== anyType) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + } + } } - var targetType = getTypeOfSymbol(prototypeProperty); - // Narrow to target type if it is a subtype of current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; + // Target type is type of construct signature + var constructSignatures; + if (rightType.flags & 2048 /* Interface */) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - // If current type is a union type, remove all constituents that aren't subtypes of target type - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + else if (rightType.flags & 32768 /* Anonymous */) { + constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + } + if (constructSignatures && constructSignatures.length !== 0) { + var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + // Pickup type from union types + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + } + return instanceType; } return type; } @@ -15628,9 +15767,9 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -15645,7 +15784,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -15662,7 +15801,7 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 /* ArrowFunction */ && 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); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -15686,7 +15825,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 223 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 224 /* CatchClause */) { return; } // - check if binding is used in some function @@ -15695,12 +15834,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 199 /* VariableDeclarationList */) { + while (container.kind !== 200 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 180 /* VariableStatement */) { + if (container.kind === 181 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -15719,9 +15858,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 201 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 132 /* PropertyDeclaration */ || container.kind === 135 /* Constructor */) { + if (container.kind === 133 /* PropertyDeclaration */ || container.kind === 136 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -15734,39 +15873,39 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 163 /* ArrowFunction */) { + if (container.kind === 164 /* ArrowFunction */) { container = ts.getThisContainer(container, 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 205 /* ModuleDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); + case 206 /* 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 204 /* EnumDeclaration */: + case 205 /* 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 135 /* Constructor */: + case 136 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 201 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -15775,15 +15914,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 129 /* Parameter */) { + if (n.kind === 130 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 157 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 201 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); var baseClass; if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -15801,7 +15940,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 135 /* Constructor */; + canUseSuperExpression = container.kind === 136 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -15810,28 +15949,28 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 163 /* ArrowFunction */) { + while (container && container.kind === 164 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === 201 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 202 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 134 /* MethodDeclaration */ || - container.kind === 133 /* MethodSignature */ || - container.kind === 136 /* GetAccessor */ || - container.kind === 137 /* SetAccessor */; + container.kind === 135 /* MethodDeclaration */ || + container.kind === 134 /* MethodSignature */ || + container.kind === 137 /* GetAccessor */ || + container.kind === 138 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 134 /* MethodDeclaration */ || - container.kind === 133 /* MethodSignature */ || - container.kind === 136 /* GetAccessor */ || - container.kind === 137 /* SetAccessor */ || - container.kind === 132 /* PropertyDeclaration */ || - container.kind === 131 /* PropertySignature */ || - container.kind === 135 /* Constructor */; + container.kind === 135 /* MethodDeclaration */ || + container.kind === 134 /* MethodSignature */ || + container.kind === 137 /* GetAccessor */ || + container.kind === 138 /* SetAccessor */ || + container.kind === 133 /* PropertyDeclaration */ || + container.kind === 132 /* PropertySignature */ || + container.kind === 136 /* Constructor */; } } } @@ -15845,7 +15984,7 @@ var ts; getNodeLinks(node).flags |= 16 /* SuperInstance */; returnType = baseClass; } - if (container.kind === 135 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 136 /* 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); returnType = unknownType; @@ -15859,7 +15998,7 @@ var ts; return returnType; } } - if (container && container.kind === 127 /* ComputedPropertyName */) { + if (container && container.kind === 128 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15886,7 +16025,7 @@ var ts; // If last parameter is contextually rest parameter get its type if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); } } } @@ -15904,7 +16043,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129 /* Parameter */) { + if (declaration.kind === 130 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15921,7 +16060,7 @@ var ts; if (func) { // 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 (func.type || func.kind === 135 /* Constructor */ || func.kind === 136 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137 /* SetAccessor */))) { + if (func.type || func.kind === 136 /* Constructor */ || func.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 138 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -15944,7 +16083,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 159 /* TaggedTemplateExpression */) { + if (template.parent.kind === 160 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -16075,32 +16214,32 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 198 /* VariableDeclaration */: - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 153 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 163 /* ArrowFunction */: - case 191 /* ReturnStatement */: + case 164 /* ArrowFunction */: + case 192 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 224 /* PropertyAssignment */: + case 225 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 176 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 171 /* TemplateExpression */); + case 178 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 172 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return getContextualType(parent); } return undefined; @@ -16117,7 +16256,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 162 /* FunctionExpression */ || node.kind === 163 /* ArrowFunction */; + return node.kind === 163 /* FunctionExpression */ || node.kind === 164 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions and arrow functions are contextually typed. @@ -16129,7 +16268,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 !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -16185,13 +16324,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 === 169 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 170 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 224 /* PropertyAssignment */) { + if (parent.kind === 225 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 153 /* ArrayLiteralExpression */) { + if (parent.kind === 154 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -16216,7 +16355,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 173 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 174 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -16240,7 +16379,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 173 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 174 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -16251,7 +16390,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 127 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 128 /* 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, @@ -16307,18 +16446,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 224 /* PropertyAssignment */ || - memberDecl.kind === 225 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 225 /* PropertyAssignment */ || + memberDecl.kind === 226 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 224 /* PropertyAssignment */) { + if (memberDecl.kind === 225 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 134 /* MethodDeclaration */) { + else if (memberDecl.kind === 135 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 225 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 226 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -16338,7 +16477,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 === 136 /* GetAccessor */ || memberDecl.kind === 137 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 137 /* GetAccessor */ || memberDecl.kind === 138 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16377,7 +16516,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 : 132 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 133 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -16390,7 +16529,7 @@ var ts; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getAncestor(node, 201 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 202 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -16451,7 +16590,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 (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 134 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -16463,14 +16602,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 155 /* PropertyAccessExpression */ + var left = node.kind === 156 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 134 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { return false; } else { @@ -16486,7 +16625,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 158 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 159 /* 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); @@ -16615,7 +16754,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -16683,7 +16822,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 173 /* SpreadElementExpression */) { + if (args[i].kind === 174 /* SpreadElementExpression */) { return i; } } @@ -16693,13 +16832,13 @@ var ts; var adjustedArgCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* 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 === 171 /* TemplateExpression */) { + if (tagExpression.template.kind === 172 /* 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; @@ -16720,7 +16859,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 === 158 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 159 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -16797,10 +16936,10 @@ var ts; // wildcards for all context sensitive function expressions. for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175 /* OmittedExpression */) { + if (arg.kind !== 176 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 159 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 160 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { @@ -16847,12 +16986,12 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175 /* OmittedExpression */) { + if (arg.kind !== 176 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // A tagged template expression provides a special first argument, and string literals get string literal types // unless we're reporting errors - var argType = i === 0 && node.kind === 159 /* TaggedTemplateExpression */ + var argType = i === 0 && node.kind === 160 /* TaggedTemplateExpression */ ? globalTemplateStringsArrayType : arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) @@ -16874,10 +17013,10 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 171 /* TemplateExpression */) { + if (template.kind === 172 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -16900,7 +17039,7 @@ var ts; */ function getEffectiveTypeArguments(callExpression) { if (callExpression.expression.kind === 91 /* SuperKeyword */) { - var containingClass = ts.getAncestor(callExpression, 201 /* ClassDeclaration */); + var containingClass = ts.getAncestor(callExpression, 202 /* ClassDeclaration */); var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -16910,7 +17049,7 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 159 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 160 /* TaggedTemplateExpression */; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); @@ -17223,13 +17362,13 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 157 /* CallExpression */) { + if (node.kind === 158 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 158 /* NewExpression */) { + else if (node.kind === 159 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 159 /* TaggedTemplateExpression */) { + else if (node.kind === 160 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -17245,12 +17384,12 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { return voidType; } - if (node.kind === 158 /* NewExpression */) { + if (node.kind === 159 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 135 /* Constructor */ && - declaration.kind !== 139 /* ConstructSignature */ && - declaration.kind !== 143 /* ConstructorType */) { + declaration.kind !== 136 /* Constructor */ && + declaration.kind !== 140 /* ConstructSignature */ && + declaration.kind !== 144 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -17287,9 +17426,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var parameter = signature.parameters[signature.parameters.length - 1]; + var parameter = ts.lastOrUndefined(signature.parameters); var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -17298,7 +17437,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 179 /* Block */) { + if (func.body.kind !== 180 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -17340,7 +17479,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 195 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 196 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -17355,7 +17494,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 179 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 180 /* Block */) { return; } var bodyBlock = func.body; @@ -17373,10 +17512,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 162 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 163 /* FunctionExpression */) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -17398,10 +17537,9 @@ var ts; if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type) { - signature.resolvedReturnType = resolvingType; + if (!node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); - if (signature.resolvedReturnType === resolvingType) { + if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } @@ -17409,19 +17547,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 179 /* Block */) { + if (node.body.kind === 180 /* Block */) { checkSourceElement(node.body); } else { @@ -17463,17 +17601,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 155 /* PropertyAccessExpression */: { + case 156 /* 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 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17482,11 +17620,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65 /* Identifier */: - case 155 /* PropertyAccessExpression */: { + case 156 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; } - case 156 /* ElementAccessExpression */: { + case 157 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { @@ -17496,7 +17634,7 @@ var ts; } return false; } - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -17647,7 +17785,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 224 /* PropertyAssignment */ || p.kind === 225 /* ShorthandPropertyAssignment */) { + if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_8 = p.name; var type = sourceType.flags & 1 /* Any */ ? sourceType : @@ -17675,8 +17813,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175 /* OmittedExpression */) { - if (e.kind !== 173 /* SpreadElementExpression */) { + if (e.kind !== 176 /* OmittedExpression */) { + if (e.kind !== 174 /* SpreadElementExpression */) { var propName = "" + i; var type = sourceType.flags & 1 /* Any */ ? sourceType : isTupleLikeType(sourceType) @@ -17700,7 +17838,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 169 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 170 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17713,14 +17851,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 169 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 154 /* ObjectLiteralExpression */) { + if (target.kind === 155 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 153 /* ArrayLiteralExpression */) { + if (target.kind === 154 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17740,7 +17878,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 154 /* ObjectLiteralExpression */ || node.left.kind === 153 /* ArrayLiteralExpression */)) { + if (operator === 53 /* EqualsToken */ && (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -17952,7 +18090,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -17963,7 +18101,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -17997,7 +18135,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 126 /* QualifiedName */) { + if (node.kind == 127 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -18009,9 +18147,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 156 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 65 /* Identifier */ || node.kind === 127 /* 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); } @@ -18038,54 +18176,54 @@ var ts; return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 155 /* PropertyAccessExpression */: + case 156 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return checkCallExpression(node); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: return checkClassExpression(node); - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 165 /* TypeOfExpression */: + case 166 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 164 /* DeleteExpression */: + case 165 /* DeleteExpression */: return checkDeleteExpression(node); - case 166 /* VoidExpression */: + case 167 /* VoidExpression */: return checkVoidExpression(node); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 168 /* PostfixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 173 /* SpreadElementExpression */: + case 174 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 175 /* OmittedExpression */: + case 176 /* OmittedExpression */: return undefinedType; - case 172 /* YieldExpression */: + case 173 /* YieldExpression */: checkYieldExpression(node); return unknownType; } @@ -18118,7 +18256,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 135 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 136 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18133,12 +18271,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 140 /* IndexSignature */) { + if (node.kind === 141 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 142 /* FunctionType */ || node.kind === 200 /* FunctionDeclaration */ || node.kind === 143 /* ConstructorType */ || - node.kind === 138 /* CallSignature */ || node.kind === 135 /* Constructor */ || - node.kind === 139 /* ConstructSignature */) { + else if (node.kind === 143 /* FunctionType */ || node.kind === 201 /* FunctionDeclaration */ || node.kind === 144 /* ConstructorType */ || + node.kind === 139 /* CallSignature */ || node.kind === 136 /* Constructor */ || + node.kind === 140 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -18150,10 +18288,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 138 /* CallSignature */: + case 139 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18162,7 +18300,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 202 /* InterfaceDeclaration */) { + if (node.kind === 203 /* 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 @@ -18182,7 +18320,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 121 /* StringKeyword */: + case 122 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18190,7 +18328,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 119 /* NumberKeyword */: + case 120 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18234,17 +18372,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 157 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 158 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 154 /* ObjectLiteralExpression */: return false; + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 155 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -18252,12 +18390,12 @@ var ts; if (n.kind === 93 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 162 /* FunctionExpression */ && n.kind !== 200 /* FunctionDeclaration */) { + else if (n.kind !== 163 /* FunctionExpression */ && n.kind !== 201 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 132 /* PropertyDeclaration */ && + return n.kind === 133 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -18274,7 +18412,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 182 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 183 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -18292,7 +18430,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 136 /* GetAccessor */) { + if (node.kind === 137 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -18300,7 +18438,7 @@ var ts; 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 === 136 /* GetAccessor */ ? 137 /* SetAccessor */ : 136 /* GetAccessor */; + var otherKind = node.kind === 137 /* GetAccessor */ ? 138 /* SetAccessor */ : 137 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -18317,7 +18455,7 @@ var ts; } } } - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + getTypeOfAccessors(getSymbolOfNode(node)); } checkFunctionLikeDeclaration(node); } @@ -18326,16 +18464,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrHeritageClauseElement(node); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkHeritageClauseElement(node) { - checkGrammarHeritageClauseElementInStrictMode(node.expression); - return checkTypeReferenceOrHeritageClauseElement(node); + function checkExpressionWithTypeArguments(node) { + checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkTypeReferenceOrHeritageClauseElement(node) { + function checkTypeReferenceOrExpressionWithTypeArguments(node) { // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrHeritageClauseElement(node); + var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved var len = node.typeArguments.length; @@ -18397,9 +18535,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 === 202 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 138 /* CallSignature */ || signatureDeclarationNode.kind === 139 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 138 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 139 /* CallSignature */ || signatureDeclarationNode.kind === 140 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 139 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18417,7 +18555,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 202 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 203 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -18500,7 +18638,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */); + ts.Debug.assert(node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18529,7 +18667,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 202 /* InterfaceDeclaration */ || node.parent.kind === 145 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 203 /* InterfaceDeclaration */ || node.parent.kind === 146 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -18540,7 +18678,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 === 200 /* FunctionDeclaration */ || node.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */ || node.kind === 135 /* Constructor */) { + if (node.kind === 201 /* FunctionDeclaration */ || node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */ || node.kind === 136 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18663,16 +18801,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18687,23 +18825,23 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 129 /* Parameter */: + case 130 /* Parameter */: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } @@ -18713,7 +18851,7 @@ 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 === 141 /* TypeReference */) { + if (node && node.kind === 142 /* TypeReference */) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { @@ -18730,19 +18868,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 129 /* Parameter */: + case 130 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 134 /* MethodDeclaration */: + case 135 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 137 /* SetAccessor */: + case 138 /* SetAccessor */: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -18768,25 +18906,25 @@ 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 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 134 /* MethodDeclaration */: + case 135 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 137 /* SetAccessor */: - case 136 /* GetAccessor */: - case 132 /* PropertyDeclaration */: - case 129 /* Parameter */: + case 138 /* SetAccessor */: + case 137 /* GetAccessor */: + case 133 /* PropertyDeclaration */: + case 130 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 129 /* Parameter */) { + if (node.kind === 130 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18809,7 +18947,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 127 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 128 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -18845,11 +18983,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 179 /* Block */) { + if (node.kind === 180 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 206 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 207 /* ModuleBlock */) { checkFunctionExpressionBodies(node); } } @@ -18868,12 +19006,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 132 /* PropertyDeclaration */ || - node.kind === 131 /* PropertySignature */ || - node.kind === 134 /* MethodDeclaration */ || - node.kind === 133 /* MethodSignature */ || - node.kind === 136 /* GetAccessor */ || - node.kind === 137 /* SetAccessor */) { + if (node.kind === 133 /* PropertyDeclaration */ || + node.kind === 132 /* PropertySignature */ || + node.kind === 135 /* MethodDeclaration */ || + node.kind === 134 /* MethodSignature */ || + node.kind === 137 /* GetAccessor */ || + node.kind === 138 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -18882,7 +19020,7 @@ var ts; return false; } var root = getRootDeclaration(node); - if (root.kind === 129 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 130 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -18915,7 +19053,7 @@ var ts; return; } // bubble up and find containing type - var enclosingClass = ts.getAncestor(node, 201 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; @@ -18935,14 +19073,14 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 205 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 206 /* 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 === 227 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 228 /* SourceFile */ && ts.isExternalModule(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_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { @@ -18975,7 +19113,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 === 198 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 199 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -18985,17 +19123,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 199 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 180 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 181 /* 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 === 179 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 206 /* ModuleBlock */ || - container.kind === 205 /* ModuleDeclaration */ || - container.kind === 227 /* SourceFile */); + (container.kind === 180 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 207 /* ModuleBlock */ || + container.kind === 206 /* ModuleDeclaration */ || + container.kind === 228 /* 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 @@ -19009,14 +19147,14 @@ var ts; } } function isParameterDeclaration(node) { - while (node.kind === 152 /* BindingElement */) { + while (node.kind === 153 /* BindingElement */) { node = node.parent.parent; } - return node.kind === 129 /* Parameter */; + return node.kind === 130 /* Parameter */; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 129 /* Parameter */) { + if (getRootDeclaration(node).kind !== 130 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -19027,7 +19165,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 === 129 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 130 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19054,7 +19192,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19065,7 +19203,7 @@ 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 && getRootDeclaration(node).kind === 129 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 130 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19097,10 +19235,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 132 /* PropertyDeclaration */ && node.kind !== 131 /* PropertySignature */) { + if (node.kind !== 133 /* PropertyDeclaration */ && node.kind !== 132 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 198 /* VariableDeclaration */ || node.kind === 152 /* BindingElement */) { + if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19130,7 +19268,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 179 /* Block */ || node.kind === 154 /* ObjectLiteralExpression */) { + if (node.kind === 180 /* Block */ || node.kind === 155 /* ObjectLiteralExpression */) { return true; } node = node.parent; @@ -19163,12 +19301,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 199 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind == 200 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19188,14 +19326,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 === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* 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 === 153 /* ArrayLiteralExpression */ || varExpr.kind === 154 /* ObjectLiteralExpression */) { + if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* 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. @@ -19224,7 +19362,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 === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* 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); @@ -19238,7 +19376,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 === 153 /* ArrayLiteralExpression */ || varExpr.kind === 154 /* ObjectLiteralExpression */) { + if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 /* Any */ | 258 /* StringLike */)) { @@ -19438,7 +19576,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 136 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137 /* SetAccessor */))); + return !!(node.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -19453,11 +19591,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 137 /* SetAccessor */) { + if (func.kind === 138 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 135 /* Constructor */) { + if (func.kind === 136 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19487,7 +19625,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 221 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 222 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19499,7 +19637,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 220 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 221 /* 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. @@ -19520,7 +19658,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 194 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 195 /* 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; @@ -19590,7 +19728,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 201 /* ClassDeclaration */) { + if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 202 /* ClassDeclaration */) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -19628,7 +19766,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 === 127 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 128 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19686,7 +19824,7 @@ var ts; function checkClassDeclaration(node) { checkGrammarDeclarationNameInStrictMode(node); // Grammar checking - if (node.parent.kind !== 206 /* ModuleBlock */ && node.parent.kind !== 227 /* SourceFile */) { + if (node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); } if (!node.name && !(node.flags & 256 /* Default */)) { @@ -19706,11 +19844,11 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedHeritageClauseElement(baseTypeNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkHeritageClauseElement(baseTypeNode); + checkExpressionWithTypeArguments(baseTypeNode); } var baseTypes = getBaseTypes(type); if (baseTypes.length) { @@ -19732,12 +19870,12 @@ var ts; var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { - if (!ts.isSupportedHeritageClauseElement(typeRefNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(typeRefNode); + checkExpressionWithTypeArguments(typeRefNode); if (produceDiagnostics) { - var t = getTypeFromHeritageClauseElement(typeRefNode); + var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { @@ -19823,7 +19961,7 @@ var ts; } } function isAccessor(kind) { - return kind === 136 /* GetAccessor */ || kind === 137 /* SetAccessor */; + return kind === 137 /* GetAccessor */ || kind === 138 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19893,7 +20031,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 202 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203 /* 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); @@ -19912,10 +20050,10 @@ var ts; } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedHeritageClauseElement(heritageElement)) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(heritageElement); + checkExpressionWithTypeArguments(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -19937,7 +20075,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 127 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 128 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -19977,7 +20115,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -19988,7 +20126,7 @@ var ts; case 47 /* TildeToken */: return ~value; } return undefined; - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20013,11 +20151,11 @@ var ts; return undefined; case 7 /* NumericLiteral */: return +e.text; - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return evalConstant(e.expression); case 65 /* Identifier */: - case 156 /* ElementAccessExpression */: - case 155 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 156 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -20030,7 +20168,7 @@ var ts; } else { var expression; - if (e.kind === 156 /* ElementAccessExpression */) { + if (e.kind === 157 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -20048,7 +20186,7 @@ var ts; if (current.kind === 65 /* Identifier */) { break; } - else if (current.kind === 155 /* PropertyAccessExpression */) { + else if (current.kind === 156 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -20117,7 +20255,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 !== 204 /* EnumDeclaration */) { + if (declaration.kind !== 205 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -20140,8 +20278,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 201 /* ClassDeclaration */ || - (declaration.kind === 200 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 202 /* ClassDeclaration */ || + (declaration.kind === 201 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20181,15 +20319,15 @@ var ts; var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); } else if (node.pos < firstNonAmbientClassOrFunc.pos) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } // 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, 201 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 202 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; @@ -20198,10 +20336,10 @@ var ts; // Checks for ambient external modules. if (node.name.kind === 8 /* StringLiteral */) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } if (isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name); + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } } @@ -20209,10 +20347,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 126 /* QualifiedName */) { + if (node.kind === 127 /* QualifiedName */) { node = node.left; } - else if (node.kind === 155 /* PropertyAccessExpression */) { + else if (node.kind === 156 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -20228,11 +20366,11 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 206 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 227 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 215 /* ExportDeclaration */ ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : - ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 216 /* 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 && isExternalModuleNameRelative(moduleName.text)) { @@ -20240,7 +20378,7 @@ var ts; // 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_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } return true; @@ -20253,7 +20391,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 === 217 /* ExportSpecifier */ ? + var message = node.kind === 218 /* 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)); @@ -20276,7 +20414,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -20325,16 +20463,16 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 206 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 227 /* SourceFile */ && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { // export * from "foo" var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } @@ -20346,9 +20484,9 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 227 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 205 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); + var container = node.parent.kind === 228 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 206 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } // Grammar checking @@ -20362,16 +20500,22 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if (node.isExportEquals && languageVersion >= 2 /* ES6 */) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (languageVersion >= 2 /* ES6 */) { + // export assignment is deprecated in es6 or above + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } + else if (compilerOptions.module === 4 /* System */) { + // system modules does not support export assignment + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } } } function getModuleStatements(node) { - if (node.kind === 227 /* SourceFile */) { + if (node.kind === 228 /* SourceFile */) { return node.statements; } - if (node.kind === 205 /* ModuleDeclaration */ && node.body.kind === 206 /* ModuleBlock */) { + if (node.kind === 206 /* ModuleDeclaration */ && node.body.kind === 207 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -20400,107 +20544,107 @@ var ts; if (!node) return; switch (node.kind) { - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: return checkTypeParameter(node); - case 129 /* Parameter */: + case 130 /* Parameter */: return checkParameter(node); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return checkPropertyDeclaration(node); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: return checkSignatureDeclaration(node); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return checkMethodDeclaration(node); - case 135 /* Constructor */: + case 136 /* Constructor */: return checkConstructorDeclaration(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return checkAccessorDeclaration(node); - case 141 /* TypeReference */: + case 142 /* TypeReference */: return checkTypeReferenceNode(node); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return checkTypeQuery(node); - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: return checkTypeLiteral(node); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return checkArrayType(node); - case 147 /* TupleType */: + case 148 /* TupleType */: return checkTupleType(node); - case 148 /* UnionType */: + case 149 /* UnionType */: return checkUnionType(node); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return checkSourceElement(node.type); - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return checkBlock(node); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return checkVariableStatement(node); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return checkExpressionStatement(node); - case 183 /* IfStatement */: + case 184 /* IfStatement */: return checkIfStatement(node); - case 184 /* DoStatement */: + case 185 /* DoStatement */: return checkDoStatement(node); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: return checkWhileStatement(node); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return checkForStatement(node); - case 187 /* ForInStatement */: + case 188 /* ForInStatement */: return checkForInStatement(node); - case 188 /* ForOfStatement */: + case 189 /* ForOfStatement */: return checkForOfStatement(node); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return checkReturnStatement(node); - case 192 /* WithStatement */: + case 193 /* WithStatement */: return checkWithStatement(node); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return checkSwitchStatement(node); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return checkLabeledStatement(node); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: return checkThrowStatement(node); - case 196 /* TryStatement */: + case 197 /* TryStatement */: return checkTryStatement(node); - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 152 /* BindingElement */: + case 153 /* BindingElement */: return checkBindingElement(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return checkClassDeclaration(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return checkImportDeclaration(node); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return checkExportDeclaration(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return checkExportAssignment(node); - case 181 /* EmptyStatement */: + case 182 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 197 /* DebuggerStatement */: + case 198 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 218 /* MissingDeclaration */: + case 219 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -20515,81 +20659,81 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 192 /* WithStatement */: + case 193 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: - case 152 /* BindingElement */: - case 153 /* ArrayLiteralExpression */: - case 154 /* ObjectLiteralExpression */: - case 224 /* PropertyAssignment */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 159 /* TaggedTemplateExpression */: - case 171 /* TemplateExpression */: - case 176 /* TemplateSpan */: - case 160 /* TypeAssertionExpression */: - case 161 /* ParenthesizedExpression */: - case 165 /* TypeOfExpression */: - case 166 /* VoidExpression */: - case 164 /* DeleteExpression */: - case 167 /* PrefixUnaryExpression */: - case 168 /* PostfixUnaryExpression */: - case 169 /* BinaryExpression */: - case 170 /* ConditionalExpression */: - case 173 /* SpreadElementExpression */: - case 179 /* Block */: - case 206 /* ModuleBlock */: - case 180 /* VariableStatement */: - case 182 /* ExpressionStatement */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: - case 191 /* ReturnStatement */: - case 193 /* SwitchStatement */: - case 207 /* CaseBlock */: - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - case 194 /* LabeledStatement */: - case 195 /* ThrowStatement */: - case 196 /* TryStatement */: - case 223 /* CatchClause */: - case 198 /* VariableDeclaration */: - case 199 /* VariableDeclarationList */: - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 214 /* ExportAssignment */: - case 227 /* SourceFile */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: + case 153 /* BindingElement */: + case 154 /* ArrayLiteralExpression */: + case 155 /* ObjectLiteralExpression */: + case 225 /* PropertyAssignment */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 160 /* TaggedTemplateExpression */: + case 172 /* TemplateExpression */: + case 178 /* TemplateSpan */: + case 161 /* TypeAssertionExpression */: + case 162 /* ParenthesizedExpression */: + case 166 /* TypeOfExpression */: + case 167 /* VoidExpression */: + case 165 /* DeleteExpression */: + case 168 /* PrefixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: + case 170 /* BinaryExpression */: + case 171 /* ConditionalExpression */: + case 174 /* SpreadElementExpression */: + case 180 /* Block */: + case 207 /* ModuleBlock */: + case 181 /* VariableStatement */: + case 183 /* ExpressionStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: + case 192 /* ReturnStatement */: + case 194 /* SwitchStatement */: + case 208 /* CaseBlock */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: + case 195 /* LabeledStatement */: + case 196 /* ThrowStatement */: + case 197 /* TryStatement */: + case 224 /* CatchClause */: + case 199 /* VariableDeclaration */: + case 200 /* VariableDeclarationList */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 215 /* ExportAssignment */: + case 228 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -20652,7 +20796,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 192 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 193 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -20675,23 +20819,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 162 /* FunctionExpression */: + case 163 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -20729,22 +20873,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 162 /* FunctionExpression */: + case 163 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -20763,64 +20907,64 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 128 /* TypeParameter */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: + case 129 /* TypeParameter */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* 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 === 126 /* QualifiedName */) { + while (node.parent && node.parent.kind === 127 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 141 /* TypeReference */; + return node.parent && node.parent.kind === 142 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 155 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 156 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 177 /* HeritageClauseElement */; + return node.parent && node.parent.kind === 177 /* ExpressionWithTypeArguments */; } function isTypeNode(node) { - if (141 /* FirstTypeNode */ <= node.kind && node.kind <= 149 /* LastTypeNode */) { + if (142 /* FirstTypeNode */ <= node.kind && node.kind <= 150 /* LastTypeNode */) { return true; } switch (node.kind) { case 112 /* AnyKeyword */: - case 119 /* NumberKeyword */: - case 121 /* StringKeyword */: + case 120 /* NumberKeyword */: + case 122 /* StringKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: return true; case 99 /* VoidKeyword */: - return node.parent.kind !== 166 /* VoidExpression */; + return node.parent.kind !== 167 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 129 /* Parameter */; - case 177 /* HeritageClauseElement */: + return node.parent.kind === 130 /* Parameter */; + case 177 /* ExpressionWithTypeArguments */: return true; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 65 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 126 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 126 /* QualifiedName */: - case 155 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */ || node.kind === 155 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_5 = node.parent; - if (parent_5.kind === 144 /* TypeQuery */) { + if (parent_5.kind === 145 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -20829,38 +20973,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 (141 /* FirstTypeNode */ <= parent_5.kind && parent_5.kind <= 149 /* LastTypeNode */) { + if (142 /* FirstTypeNode */ <= parent_5.kind && parent_5.kind <= 150 /* LastTypeNode */) { return true; } switch (parent_5.kind) { - case 177 /* HeritageClauseElement */: + case 177 /* ExpressionWithTypeArguments */: return true; - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: return node === parent_5.constraint; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: return node === parent_5.type; - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 135 /* Constructor */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 136 /* Constructor */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return node === parent_5.type; - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: return node === parent_5.type; - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return node === parent_5.type; - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -20868,13 +21012,13 @@ var ts; return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 126 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 127 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 208 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 209 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 214 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 215 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20886,11 +21030,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 214 /* ExportAssignment */) { + if (entityName.parent.kind === 215 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 155 /* PropertyAccessExpression */) { + if (entityName.kind !== 156 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -20900,7 +21044,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 /* HeritageClauseElement */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 177 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } @@ -20915,14 +21059,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 155 /* PropertyAccessExpression */) { + else if (entityName.kind === 156 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 126 /* QualifiedName */) { + else if (entityName.kind === 127 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20931,7 +21075,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 141 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 142 /* 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 */; @@ -20950,14 +21094,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 214 /* ExportAssignment */ + return node.parent.kind === 215 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65 /* Identifier */: - case 155 /* PropertyAccessExpression */: - case 126 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: @@ -20966,7 +21110,7 @@ var ts; case 114 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 135 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 136 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -20975,14 +21119,14 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 209 /* ImportDeclaration */ || node.parent.kind === 215 /* ExportDeclaration */) && + ((node.parent.kind === 210 /* ImportDeclaration */ || node.parent.kind === 216 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Intentional fall-through case 7 /* NumericLiteral */: // index access - if (node.parent.kind == 156 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind == 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20999,7 +21143,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 225 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 226 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -21079,7 +21223,7 @@ var ts; } // Emitter support function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 227 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228 /* SourceFile */; } function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { // If this is es6 or higher, just use the name of the export @@ -21089,7 +21233,7 @@ var ts; } var node = getDeclarationOfAliasSymbol(symbol); if (node) { - if (node.kind === 210 /* ImportClause */) { + if (node.kind === 211 /* ImportClause */) { var defaultKeyword; if (languageVersion === 0 /* ES3 */) { defaultKeyword = "[\"default\"]"; @@ -21099,7 +21243,7 @@ var ts; } return getGeneratedNameForNode(node.parent) + defaultKeyword; } - if (node.kind === 213 /* ImportSpecifier */) { + if (node.kind === 214 /* ImportSpecifier */) { var moduleName = getGeneratedNameForNode(node.parent.parent.parent); var propertyName = node.propertyName || node.name; return moduleName + "." + ts.unescapeIdentifier(propertyName.text); @@ -21108,9 +21252,11 @@ var ts; } function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { - // If this is es6 or higher, just use the name of the export + // 1. If this is es6 or higher, just use the name of the export // no need to qualify it. - if (languageVersion >= 2 /* ES6 */) { + // 2. export mechanism for System modules is different from CJS\AMD + // and it does not need qualifications for exports + if (languageVersion >= 2 /* ES6 */ || compilerOptions.module === 4 /* System */) { return undefined; } return "exports." + ts.unescapeIdentifier(symbol.name); @@ -21118,7 +21264,7 @@ var ts; var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 205 /* ModuleDeclaration */ || node.kind === 204 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 206 /* ModuleDeclaration */ || node.kind === 205 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; @@ -21147,22 +21293,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 227 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 228 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -21220,7 +21366,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 226 /* EnumMember */) { + if (node.kind === 227 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21265,7 +21411,7 @@ var ts; // * The serialized type of a TypeReference with a value declaration is its entity name. // * The serialized type of a TypeReference with a call or construct signature is "Function". // * The serialized type of any other type is "Object". - var type = getTypeFromTypeReference(node); + var type = getTypeFromTypeNode(node); if (type.flags & 16 /* Void */) { return "void 0"; } @@ -21313,26 +21459,26 @@ var ts; switch (node.kind) { case 99 /* VoidKeyword */: return "void 0"; - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: return "Function"; - case 146 /* ArrayType */: - case 147 /* TupleType */: + case 147 /* ArrayType */: + case 148 /* TupleType */: return "Array"; case 113 /* BooleanKeyword */: return "Boolean"; - case 121 /* StringKeyword */: + case 122 /* StringKeyword */: case 8 /* StringLiteral */: return "String"; - case 119 /* NumberKeyword */: + case 120 /* NumberKeyword */: return "Number"; - case 141 /* TypeReference */: + case 142 /* TypeReference */: return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 144 /* TypeQuery */: - case 145 /* TypeLiteral */: - case 148 /* UnionType */: + case 145 /* TypeQuery */: + case 146 /* TypeLiteral */: + case 149 /* UnionType */: case 112 /* AnyKeyword */: break; default: @@ -21355,11 +21501,11 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 201 /* ClassDeclaration */: return "Function"; - case 132 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 129 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 136 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 202 /* ClassDeclaration */: return "Function"; + case 133 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 130 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 137 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 138 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); } if (ts.isFunctionLike(node)) { return "Function"; @@ -21376,7 +21522,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -21391,10 +21537,10 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 146 /* ArrayType */) { + if (parameterType.kind === 147 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 141 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 142 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -21442,15 +21588,21 @@ var ts; ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); return !!resolveName(location, name, 107455 /* Value */, undefined, undefined); } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 152 /* BindingElement */ || (n.parent.kind === 198 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 153 /* BindingElement */ || (n.parent.kind === 199 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 223 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 224 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -21489,6 +21641,7 @@ var ts; resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, + getReferencedValueDeclaration: getReferencedValueDeclaration, serializeTypeOfNode: serializeTypeOfNode, serializeParameterTypesOfNode: serializeParameterTypesOfNode, serializeReturnTypeOfNode: serializeReturnTypeOfNode @@ -21545,12 +21698,12 @@ var ts; function isReservedWordInStrictMode(node) { // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word return (node.parserContextFlags & 1 /* StrictMode */) && - (node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); + (102 /* FirstFutureReservedWord */ <= node.originalKeywordKind && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); } function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) // if so, we would like to give more explicit invalid usage error. - if (ts.getAncestor(identifier, 201 /* ClassDeclaration */) || ts.getAncestor(identifier, 174 /* ClassExpression */)) { + if (ts.getAncestor(identifier, 202 /* ClassDeclaration */) || ts.getAncestor(identifier, 175 /* ClassExpression */)) { return grammarErrorOnNode(identifier, message, arg0); } return false; @@ -21561,19 +21714,19 @@ var ts; var impotClause = node.importClause; if (impotClause.namedBindings) { var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 211 /* NamespaceImport */) { + if (nameBindings.kind === 212 /* NamespaceImport */) { var name_11 = nameBindings.name; - if (name_11.originalKeywordKind) { + if (isReservedWordInStrictMode(name_11)) { var nameText = ts.declarationNameToString(name_11); return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } } - else if (nameBindings.kind === 212 /* NamedImports */) { + else if (nameBindings.kind === 213 /* NamedImports */) { var reportError = false; for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { var element = _a[_i]; var name_12 = element.name; - if (name_12.originalKeywordKind) { + if (isReservedWordInStrictMode(name_12)) { var nameText = ts.declarationNameToString(name_12); reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -21589,23 +21742,23 @@ var ts; if (name && name.kind === 65 /* Identifier */ && isReservedWordInStrictMode(name)) { var nameText = ts.declarationNameToString(name); switch (node.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 200 /* FunctionDeclaration */: - case 128 /* TypeParameter */: - case 152 /* BindingElement */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: + case 201 /* FunctionDeclaration */: + case 129 /* TypeParameter */: + case 153 /* BindingElement */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* EnumDeclaration */: return checkGrammarIdentifierInStrictMode(name); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: // Report an error if the class declaration uses strict-mode reserved word. return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: // Report an error if the module declaration uses strict-mode reserved word. // TODO(yuisu): fix this when having external module in strict mode return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: // TODO(yuisu): fix this when having external module in strict mode return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -21621,7 +21774,7 @@ var ts; if (typeName.kind === 65 /* Identifier */) { checkGrammarTypeNameInStrictMode(typeName); } - else if (typeName.kind === 126 /* QualifiedName */) { + else if (typeName.kind === 127 /* QualifiedName */) { // Walk from right to left and report a possible error at each Identifier in QualifiedName // Example: // x1: public.private.package // error at public and private @@ -21635,18 +21788,18 @@ var ts; // public // error at public // public.private.package // error at public // B.private.B // no error - function checkGrammarHeritageClauseElementInStrictMode(expression) { + function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { // Example: // class C extends public // error at public if (expression && expression.kind === 65 /* Identifier */) { return checkGrammarIdentifierInStrictMode(expression); } - else if (expression && expression.kind === 155 /* PropertyAccessExpression */) { + else if (expression && expression.kind === 156 /* PropertyAccessExpression */) { // Walk from left to right in PropertyAccessExpression until we are at the left most expression // in PropertyAccessExpression. According to grammar production of MemberExpression, // the left component expression is a PrimaryExpression (i.e. Identifier) while the other // component after dots can be IdentifierName. - checkGrammarHeritageClauseElementInStrictMode(expression.expression); + checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); } } // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. @@ -21683,7 +21836,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 136 /* GetAccessor */ || node.kind === 137 /* SetAccessor */) { + else if (node.kind === 137 /* GetAccessor */ || node.kind === 138 /* 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); @@ -21693,26 +21846,26 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 140 /* IndexSignature */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: - case 180 /* VariableStatement */: - case 200 /* FunctionDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 215 /* ExportDeclaration */: - case 214 /* ExportAssignment */: - case 129 /* Parameter */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 141 /* IndexSignature */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: + case 181 /* VariableStatement */: + case 201 /* FunctionDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 216 /* ExportDeclaration */: + case 215 /* ExportAssignment */: + case 130 /* Parameter */: break; default: return false; @@ -21746,7 +21899,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 206 /* ModuleBlock */ || node.parent.kind === 227 /* SourceFile */) { + else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -21755,10 +21908,10 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 206 /* ModuleBlock */ || node.parent.kind === 227 /* SourceFile */) { + else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 129 /* Parameter */) { + else if (node.kind === 130 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; @@ -21771,10 +21924,10 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 129 /* Parameter */) { + else if (node.kind === 130 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -21783,13 +21936,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 129 /* Parameter */) { + else if (node.kind === 130 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 206 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -21797,7 +21950,7 @@ var ts; break; } } - if (node.kind === 135 /* Constructor */) { + if (node.kind === 136 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21808,13 +21961,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 209 /* ImportDeclaration */ || node.kind === 208 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 202 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 203 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 129 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 130 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -21878,7 +22031,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 163 /* ArrowFunction */) { + if (node.kind === 164 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21913,7 +22066,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 /* StringKeyword */ && parameter.type.kind !== 119 /* NumberKeyword */) { + if (parameter.type.kind !== 122 /* StringKeyword */ && parameter.type.kind !== 120 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21946,7 +22099,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 175 /* OmittedExpression */) { + if (arg.kind === 176 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -22020,11 +22173,11 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 127 /* ComputedPropertyName */) { + if (node.kind !== 128 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 169 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 170 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -22052,8 +22205,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_13 = prop.name; - if (prop.kind === 175 /* OmittedExpression */ || - name_13.kind === 127 /* ComputedPropertyName */) { + if (prop.kind === 176 /* OmittedExpression */ || + name_13.kind === 128 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_13); continue; @@ -22067,7 +22220,7 @@ 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 === 224 /* PropertyAssignment */ || prop.kind === 225 /* ShorthandPropertyAssignment */) { + if (prop.kind === 225 /* PropertyAssignment */ || prop.kind === 226 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_13.kind === 7 /* NumericLiteral */) { @@ -22075,13 +22228,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 134 /* MethodDeclaration */) { + else if (prop.kind === 135 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 136 /* GetAccessor */) { + else if (prop.kind === 137 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 137 /* SetAccessor */) { + else if (prop.kind === 138 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -22115,24 +22268,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 199 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 200 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 187 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 188 /* 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 = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 187 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 188 /* 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 === 187 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 188 /* 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); @@ -22155,10 +22308,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 136 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 137 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 137 /* SetAccessor */) { + else if (kind === 138 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22183,7 +22336,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 127 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 128 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22193,7 +22346,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 154 /* ObjectLiteralExpression */) { + if (node.parent.kind === 155 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22201,7 +22354,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.kind === 202 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22217,22 +22370,22 @@ 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 === 202 /* InterfaceDeclaration */) { + else if (node.parent.kind === 203 /* 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 === 145 /* TypeLiteral */) { + else if (node.parent.kind === 146 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: return true; - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22244,11 +22397,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 194 /* LabeledStatement */: + case 195 /* 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 === 189 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 190 /* ContinueStatement */ && !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); @@ -22256,8 +22409,8 @@ var ts; return false; } break; - case 193 /* SwitchStatement */: - if (node.kind === 190 /* BreakStatement */ && !node.label) { + case 194 /* SwitchStatement */: + if (node.kind === 191 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -22272,13 +22425,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 190 /* BreakStatement */ + var message = node.kind === 191 /* 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 === 190 /* BreakStatement */ + var message = node.kind === 191 /* 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); @@ -22287,10 +22440,10 @@ var ts; function checkGrammarBindingElement(node) { if (node.dotDotDotToken) { var elements = node.parent.elements; - if (node !== elements[elements.length - 1]) { + 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 === 151 /* ArrayBindingPattern */ || node.name.kind === 150 /* ObjectBindingPattern */) { + if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22303,7 +22456,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 187 /* ForInStatement */ && node.parent.parent.kind !== 188 /* ForOfStatement */) { + if (node.parent.parent.kind !== 188 /* ForInStatement */ && node.parent.parent.kind !== 189 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -22340,7 +22493,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 175 /* OmittedExpression */) { + if (element.kind !== 176 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22357,15 +22510,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 192 /* WithStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 193 /* WithStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: return false; - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22381,7 +22534,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 167 /* PrefixUnaryExpression */) { + if (expression.kind === 168 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; @@ -22410,7 +22563,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -22483,18 +22636,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.kind === 202 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 202 /* InterfaceDeclaration */) { + else if (node.parent.kind === 203 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 145 /* TypeLiteral */) { + else if (node.parent.kind === 146 /* 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; } @@ -22514,11 +22667,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 202 /* InterfaceDeclaration */ || - node.kind === 209 /* ImportDeclaration */ || - node.kind === 208 /* ImportEqualsDeclaration */ || - node.kind === 215 /* ExportDeclaration */ || - node.kind === 214 /* ExportAssignment */ || + if (node.kind === 203 /* InterfaceDeclaration */ || + node.kind === 210 /* ImportDeclaration */ || + node.kind === 209 /* ImportEqualsDeclaration */ || + node.kind === 216 /* ExportDeclaration */ || + node.kind === 215 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 256 /* Default */))) { return false; @@ -22528,7 +22681,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 === 180 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 181 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22554,7 +22707,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 === 179 /* Block */ || node.parent.kind === 206 /* ModuleBlock */ || node.parent.kind === 227 /* SourceFile */) { + if (node.parent.kind === 180 /* Block */ || node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -22644,7 +22797,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 209 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 210 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22720,10 +22873,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 198 /* VariableDeclaration */) { + if (declaration.kind === 199 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 212 /* NamedImports */ || declaration.kind === 213 /* ImportSpecifier */ || declaration.kind === 210 /* ImportClause */) { + else if (declaration.kind === 213 /* NamedImports */ || declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 211 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22741,7 +22894,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 === 209 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 210 /* 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; @@ -22751,12 +22904,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 205 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 205 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22849,41 +23002,41 @@ var ts; function emitType(type) { switch (type.kind) { case 112 /* AnyKeyword */: - case 121 /* StringKeyword */: - case 119 /* NumberKeyword */: + case 122 /* StringKeyword */: + case 120 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 177 /* HeritageClauseElement */: - return emitHeritageClauseElement(type); - case 141 /* TypeReference */: + case 177 /* ExpressionWithTypeArguments */: + return emitExpressionWithTypeArguments(type); + case 142 /* TypeReference */: return emitTypeReference(type); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return emitTypeQuery(type); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return emitArrayType(type); - case 147 /* TupleType */: + case 148 /* TupleType */: return emitTupleType(type); - case 148 /* UnionType */: + case 149 /* UnionType */: return emitUnionType(type); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return emitParenType(type); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: return emitTypeLiteral(type); case 65 /* Identifier */: return emitEntityName(type); - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: return emitEntityName(type); } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 208 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 209 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -22891,17 +23044,17 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 126 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 126 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 127 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 127 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } } - function emitHeritageClauseElement(node) { - if (ts.isSupportedHeritageClauseElement(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 155 /* PropertyAccessExpression */); + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 156 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -23013,10 +23166,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 208 /* ImportEqualsDeclaration */ || - (node.parent.kind === 227 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 209 /* ImportEqualsDeclaration */ || + (node.parent.kind === 228 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 227 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -23026,7 +23179,7 @@ var ts; }); } else { - if (node.kind === 209 /* ImportDeclaration */) { + if (node.kind === 210 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -23044,23 +23197,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return writeVariableStatement(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return writeClassDeclaration(node); - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -23076,7 +23229,7 @@ var ts; if (node.flags & 256 /* Default */) { write("default "); } - else if (node.kind !== 202 /* InterfaceDeclaration */) { + else if (node.kind !== 203 /* InterfaceDeclaration */) { write("declare "); } } @@ -23122,7 +23275,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 211 /* NamespaceImport */) { + if (namedBindings.kind === 212 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -23150,7 +23303,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -23203,7 +23356,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 206 /* ModuleBlock */) { + while (node.body.kind !== 207 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -23264,7 +23417,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 134 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 135 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23275,15 +23428,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 === 142 /* FunctionType */ || - node.parent.kind === 143 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 145 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 134 /* MethodDeclaration */ || - node.parent.kind === 133 /* MethodSignature */ || - node.parent.kind === 142 /* FunctionType */ || - node.parent.kind === 143 /* ConstructorType */ || - node.parent.kind === 138 /* CallSignature */ || - node.parent.kind === 139 /* ConstructSignature */); + if (node.parent.kind === 143 /* FunctionType */ || + node.parent.kind === 144 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 146 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 135 /* MethodDeclaration */ || + node.parent.kind === 134 /* MethodSignature */ || + node.parent.kind === 143 /* FunctionType */ || + node.parent.kind === 144 /* ConstructorType */ || + node.parent.kind === 139 /* CallSignature */ || + node.parent.kind === 140 /* ConstructSignature */); emitType(node.constraint); } else { @@ -23294,31 +23447,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 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 138 /* CallSignature */: + case 139 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.parent.flags & 128 /* 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 === 201 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 202 /* 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 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23343,13 +23496,13 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - if (ts.isSupportedHeritageClauseElement(node)) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.parent.kind === 202 /* 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 : @@ -23430,7 +23583,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 !== 198 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 199 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -23440,10 +23593,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 132 /* PropertyDeclaration */ || node.kind === 131 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 132 /* PropertyDeclaration */ || node.kind === 131 /* PropertySignature */) && node.parent.kind === 145 /* TypeLiteral */) { + if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && node.parent.kind === 146 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -23452,14 +23605,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 198 /* VariableDeclaration */) { + if (node.kind === 199 /* 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 === 132 /* PropertyDeclaration */ || node.kind === 131 /* PropertySignature */) { + else if (node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -23468,7 +23621,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 === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* 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 : @@ -23500,7 +23653,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 175 /* OmittedExpression */) { + if (element.kind !== 176 /* OmittedExpression */) { elements.push(element); } } @@ -23570,7 +23723,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 === 136 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 137 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23583,7 +23736,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 136 /* GetAccessor */ + return accessor.kind === 137 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -23592,7 +23745,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 137 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 138 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -23642,17 +23795,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 200 /* FunctionDeclaration */) { + if (node.kind === 201 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 134 /* MethodDeclaration */) { + else if (node.kind === 135 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 200 /* FunctionDeclaration */) { + if (node.kind === 201 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 135 /* Constructor */) { + else if (node.kind === 136 /* Constructor */) { write("constructor"); } else { @@ -23670,11 +23823,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 139 /* ConstructSignature */ || node.kind === 143 /* ConstructorType */) { + if (node.kind === 140 /* ConstructSignature */ || node.kind === 144 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 140 /* IndexSignature */) { + if (node.kind === 141 /* IndexSignature */) { write("["); } else { @@ -23684,22 +23837,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 140 /* IndexSignature */) { + if (node.kind === 141 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 142 /* FunctionType */ || node.kind === 143 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 145 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 143 /* FunctionType */ || node.kind === 144 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 146 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 135 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 136 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23710,26 +23863,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 139 /* ConstructSignature */: + case 140 /* 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 138 /* CallSignature */: + case 139 /* 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 140 /* IndexSignature */: + case 141 /* 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 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -23737,7 +23890,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 === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* 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 : @@ -23751,7 +23904,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 200 /* FunctionDeclaration */: + case 201 /* 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 : @@ -23786,9 +23939,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 142 /* FunctionType */ || - node.parent.kind === 143 /* ConstructorType */ || - node.parent.parent.kind === 145 /* TypeLiteral */) { + if (node.parent.kind === 143 /* FunctionType */ || + node.parent.kind === 144 /* ConstructorType */ || + node.parent.parent.kind === 146 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -23804,24 +23957,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 135 /* Constructor */: + case 136 /* 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 139 /* ConstructSignature */: + case 140 /* 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 138 /* CallSignature */: + case 139 /* 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 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -23829,7 +23982,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 === 201 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 202 /* 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 : @@ -23842,7 +23995,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 200 /* FunctionDeclaration */: + case 201 /* 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 : @@ -23854,12 +24007,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 === 150 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 151 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 151 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 152 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23878,7 +24031,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 175 /* OmittedExpression */) { + if (bindingElement.kind === 176 /* 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) @@ -23887,7 +24040,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 152 /* BindingElement */) { + else if (bindingElement.kind === 153 /* 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" @@ -23928,40 +24081,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 202 /* InterfaceDeclaration */: - case 201 /* ClassDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: + case 201 /* FunctionDeclaration */: + case 206 /* ModuleDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 203 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return emitExportDeclaration(node); - case 135 /* Constructor */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 136 /* Constructor */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return writeFunctionDeclaration(node); - case 139 /* ConstructSignature */: - case 138 /* CallSignature */: - case 140 /* IndexSignature */: + case 140 /* ConstructSignature */: + case 139 /* CallSignature */: + case 141 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return emitAccessorDeclaration(node); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return emitPropertyDeclaration(node); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return emitExportAssignment(node); - case 227 /* SourceFile */: + case 228 /* SourceFile */: return emitSourceFile(node); } } @@ -24018,21 +24171,20 @@ var ts; TempFlags[TempFlags["Auto"] = 0] = "Auto"; TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; TempFlags[TempFlags["_i"] = 268435456] = "_i"; - TempFlags[TempFlags["_n"] = 536870912] = "_n"; })(TempFlags || (TempFlags = {})); // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; // emit output for the __decorate helper function - var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function - var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\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};"; // emit output for the __param helper function - var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; - var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { @@ -24090,6 +24242,13 @@ var ts; var increaseIndent = writer.increaseIndent; var decreaseIndent = writer.decreaseIndent; var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; var blockScopedVariableToGeneratedName; @@ -24129,7 +24288,7 @@ var ts; var scopeEmitEnd = function () { }; /** Sourcemap data that will get encoded */ var sourceMapData; - if (compilerOptions.sourceMap) { + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } if (root) { @@ -24148,6 +24307,7 @@ var ts; return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; + exportFunctionForFile = undefined; emit(sourceFile); } function isUniqueName(name) { @@ -24234,25 +24394,25 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: + case 201 /* FunctionDeclaration */: + case 202 /* ClassDeclaration */: + case 175 /* ClassExpression */: generateNameForFunctionOrClassDeclaration(node); break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: generateNameForModuleOrEnum(node); generateNameForNode(node.body); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: generateNameForModuleOrEnum(node); break; - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: generateNameForImportDeclaration(node); break; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: generateNameForExportDeclaration(node); break; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: generateNameForExportAssignment(node); break; } @@ -24272,7 +24432,7 @@ var ts; var sourceMapNameIndexMap = {}; var sourceMapNameIndices = []; function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; } // Last recorded and encoded spans var lastRecordedSourceMapSpan; @@ -24408,6 +24568,12 @@ var ts; sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; // The one that can be used from program to get the actual source file sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } } function recordScopeNameOfNode(node, scopeName) { function recordScopeNameIndex(scopeNameIndex) { @@ -24422,7 +24588,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_17 = node.name; - if (!name_17 || name_17.kind !== 127 /* ComputedPropertyName */) { + if (!name_17 || name_17.kind !== 128 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -24440,20 +24606,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 200 /* FunctionDeclaration */ || - node.kind === 162 /* FunctionExpression */ || - node.kind === 134 /* MethodDeclaration */ || - node.kind === 133 /* MethodSignature */ || - node.kind === 136 /* GetAccessor */ || - node.kind === 137 /* SetAccessor */ || - node.kind === 205 /* ModuleDeclaration */ || - node.kind === 201 /* ClassDeclaration */ || - node.kind === 204 /* EnumDeclaration */) { + else if (node.kind === 201 /* FunctionDeclaration */ || + node.kind === 163 /* FunctionExpression */ || + node.kind === 135 /* MethodDeclaration */ || + node.kind === 134 /* MethodSignature */ || + node.kind === 137 /* GetAccessor */ || + node.kind === 138 /* SetAccessor */ || + node.kind === 206 /* ModuleDeclaration */ || + node.kind === 202 /* ClassDeclaration */ || + node.kind === 205 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_18 = node.name; // For computed property names, the text will include the brackets - scopeName = name_18.kind === 127 /* ComputedPropertyName */ + scopeName = name_18.kind === 128 /* ComputedPropertyName */ ? ts.getTextOfNode(name_18) : node.name.text; } @@ -24473,18 +24639,22 @@ var ts; ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { if (typeof JSON !== "undefined") { - return JSON.stringify({ + var map_1 = { version: version, file: file, sourceRoot: sourceRoot, sources: sources, names: names, mappings: mappings - }); + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; function serializeStringArray(list) { var output = ""; for (var i = 0, n = list.length; i < n; i++) { @@ -24497,12 +24667,22 @@ var ts; } } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - // Write source map file encodeLastRecordedSourceMapSpan(); - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + // Write source map file + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); } // Initialize source map data var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); @@ -24515,6 +24695,7 @@ var ts; inputSourceFileNames: [], sourceMapNames: [], sourceMapMappings: "", + sourceMapSourcesContent: undefined, sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -24548,7 +24729,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 227 /* SourceFile */) { + if (node.kind != 228 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); @@ -24722,7 +24903,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if (compilerOptions.sourceMap && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -24811,10 +24992,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 171 /* TemplateExpression */) { + if (node.template.kind === 172 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 169 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 170 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -24849,7 +25030,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 161 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 162 /* 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 @@ -24891,11 +25072,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return parent.expression === template; - case 159 /* TaggedTemplateExpression */: - case 161 /* ParenthesizedExpression */: + case 160 /* TaggedTemplateExpression */: + case 162 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -24916,7 +25097,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 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 35 /* AsteriskToken */: case 36 /* SlashToken */: @@ -24928,8 +25109,8 @@ var ts; default: return -1 /* LessThan */; } - case 172 /* YieldExpression */: - case 170 /* ConditionalExpression */: + case 173 /* YieldExpression */: + case 171 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -24944,11 +25125,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 !== 152 /* BindingElement */); + ts.Debug.assert(node.kind !== 153 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 127 /* ComputedPropertyName */) { + else if (node.kind === 128 /* 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: @@ -24992,36 +25173,36 @@ var ts; function isNotExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 200 /* FunctionDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: + case 227 /* EnumMember */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 206 /* ModuleDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: return parent.name === node; - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: return parent.name === node || parent.propertyName === node; - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 214 /* ExportAssignment */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 215 /* ExportAssignment */: return false; - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return node.parent.label === node; } } @@ -25129,11 +25310,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: - case 153 /* ArrayLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 161 /* ParenthesizedExpression */: + case 154 /* ArrayLiteralExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 162 /* 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; @@ -25153,14 +25334,14 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 173 /* SpreadElementExpression */) { + if (e.kind === 174 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < length && elements[i].kind !== 173 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 174 /* SpreadElementExpression */) { i++; } write("["); @@ -25181,7 +25362,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 173 /* SpreadElementExpression */; + return node.kind === 174 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -25251,7 +25432,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 136 /* GetAccessor */ || property.kind === 137 /* SetAccessor */) { + if (property.kind === 137 /* GetAccessor */ || property.kind === 138 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -25303,13 +25484,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 224 /* PropertyAssignment */) { + if (property.kind === 225 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 225 /* ShorthandPropertyAssignment */) { + else if (property.kind === 226 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 134 /* MethodDeclaration */) { + else if (property.kind === 135 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -25343,7 +25524,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 === 127 /* ComputedPropertyName */) { + if (properties[i].name.kind === 128 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -25359,21 +25540,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(169 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(170 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(155 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(156 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(156 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(157 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -25387,10 +25568,10 @@ var ts; // NumberLiteral // 1.x -> not the same as (1).x // - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 158 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { + if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(161 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -25454,7 +25635,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 155 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 156 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -25506,10 +25687,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 173 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 174 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 161 /* ParenthesizedExpression */ || node.kind === 160 /* TypeAssertionExpression */) { + while (node.kind === 162 /* ParenthesizedExpression */ || node.kind === 161 /* TypeAssertionExpression */) { node = node.expression; } return node; @@ -25530,13 +25711,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 155 /* PropertyAccessExpression */) { + if (expr.kind === 156 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 156 /* ElementAccessExpression */) { + else if (expr.kind === 157 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -25581,7 +25762,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 155 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 156 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -25618,12 +25799,12 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 163 /* ArrowFunction */) { - if (node.expression.kind === 160 /* TypeAssertionExpression */) { + if (!node.parent || node.parent.kind !== 164 /* ArrowFunction */) { + if (node.expression.kind === 161 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == 160 /* TypeAssertionExpression */) { + while (operand.kind == 161 /* TypeAssertionExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -25634,14 +25815,14 @@ 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 !== 167 /* PrefixUnaryExpression */ && - operand.kind !== 166 /* VoidExpression */ && - operand.kind !== 165 /* TypeOfExpression */ && - operand.kind !== 164 /* DeleteExpression */ && - operand.kind !== 168 /* PostfixUnaryExpression */ && - operand.kind !== 158 /* NewExpression */ && - !(operand.kind === 157 /* CallExpression */ && node.parent.kind === 158 /* NewExpression */) && - !(operand.kind === 162 /* FunctionExpression */ && node.parent.kind === 157 /* CallExpression */)) { + if (operand.kind !== 168 /* PrefixUnaryExpression */ && + operand.kind !== 167 /* VoidExpression */ && + operand.kind !== 166 /* TypeOfExpression */ && + operand.kind !== 165 /* DeleteExpression */ && + operand.kind !== 169 /* PostfixUnaryExpression */ && + operand.kind !== 159 /* NewExpression */ && + !(operand.kind === 158 /* CallExpression */ && node.parent.kind === 159 /* NewExpression */) && + !(operand.kind === 163 /* FunctionExpression */ && node.parent.kind === 158 /* CallExpression */)) { emit(operand); return; } @@ -25666,7 +25847,27 @@ var ts; write(" "); emit(node.expression); } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 /* VariableDeclaration */ || node.parent.kind === 153 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } write(ts.tokenToString(node.operator)); // In some cases, we need to emit a space between the operator and the operand. One obvious case // is when the operator is an identifier, like delete or typeof. We also need to do this for plus @@ -25680,7 +25881,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 === 167 /* PrefixUnaryExpression */) { + if (node.operand.kind === 168 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); @@ -25690,23 +25891,87 @@ var ts; } } emit(node.operand); + if (exportChanged) { + write(")"); + } } function emitPostfixUnaryExpression(node) { - emit(node.operand); - write(ts.tokenToString(node.operator)); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 38 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 228 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 207 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 154 /* ObjectLiteralExpression */ || node.left.kind === 153 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 182 /* ExpressionStatement */); + (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 183 /* ExpressionStatement */); } else { + var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && + node.operatorToken.kind <= 64 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } emit(node.left); var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (exportChanged) { + write(")"); + } } } function synthesizedNodeStartsOnNewLine(node) { @@ -25738,7 +26003,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 179 /* Block */) { + if (node && node.kind === 180 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -25753,12 +26018,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 206 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 205 /* ModuleDeclaration */); + if (node.kind === 207 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 206 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 206 /* ModuleBlock */) { + if (node.kind === 207 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -25767,7 +26032,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 179 /* Block */) { + if (node.kind === 180 /* Block */) { write(" "); emit(node); } @@ -25779,7 +26044,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 163 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 164 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -25792,7 +26057,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 183 /* IfStatement */) { + if (node.elseStatement.kind === 184 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -25804,7 +26069,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 179 /* Block */) { + if (node.statement.kind === 180 /* Block */) { write(" "); } else { @@ -25820,7 +26085,15 @@ var ts; write(")"); emitEmbeddedStatement(node.statement); } - function emitStartOfVariableDeclarationList(decl, startPos) { + /* Returns true if start of variable declaration list was emitted. + * Return false if nothing was written - this can happen for source file level variable declarations + * in system modules - such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + // variables in variable declaration list were already hoisted + return false; + } var tokenKind = 98 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { @@ -25832,28 +26105,53 @@ var ts; } if (startPos !== undefined) { emitToken(tokenKind, startPos); + write(" "); } else { switch (tokenKind) { case 98 /* VarKeyword */: - return write("var "); + write("var "); + break; case 104 /* LetKeyword */: - return write("let "); + write("let "); + break; case 70 /* ConstKeyword */: - return write("const "); + write("const "); + break; } } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; } function emitForStatement(node) { var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 200 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; - var declarations = variableDeclarationList.declarations; - emitStartOfVariableDeclarationList(declarations[0], endPos); - write(" "); - emitCommaList(declarations); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } } else if (node.initializer) { emit(node.initializer); @@ -25866,25 +26164,23 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 188 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 189 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - emitStartOfVariableDeclarationList(decl, endPos); - write(" "); - emit(decl); + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 187 /* ForInStatement */) { + if (node.kind === 188 /* ForInStatement */) { write(" in "); } else { @@ -25969,7 +26265,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25999,7 +26295,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, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 153 /* ArrayLiteralExpression */ || node.initializer.kind === 154 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 154 /* ArrayLiteralExpression */ || node.initializer.kind === 155 /* 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, true, undefined); @@ -26010,7 +26306,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 179 /* Block */) { + if (node.statement.kind === 180 /* Block */) { emitLines(node.statement.statements); } else { @@ -26022,7 +26318,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 190 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -26067,7 +26363,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 220 /* CaseClause */) { + if (node.kind === 221 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -26122,7 +26418,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 205 /* ModuleDeclaration */); + } while (node && node.kind !== 206 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -26137,7 +26433,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2 /* ES6 */) { + else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); } } @@ -26147,7 +26443,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(166 /* VoidExpression */); + var result = ts.createSynthesizedNode(167 /* VoidExpression */); result.expression = zero; return result; } @@ -26155,19 +26451,35 @@ var ts; if (node.flags & 1 /* Export */) { writeLine(); emitStart(node); - if (node.flags & 256 /* Default */) { - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); + if (compilerOptions.module === 4 /* System */) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 256 /* Default */) { + write("default"); } else { - write("exports.default"); + emitNodeWithoutSourceMap(node.name); } + write("\", "); + emitDeclarationName(node); + write(")"); } else { - emitModuleMemberName(node); + if (node.flags & 256 /* Default */) { + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); } - write(" = "); - emitDeclarationName(node); emitEnd(node); write(";"); } @@ -26177,13 +26489,24 @@ var ts; for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); + if (compilerOptions.module === 4 /* System */) { + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(specifier.name); + write("\", "); + emitExpressionIdentifier(name); + write(")"); + emitEnd(specifier.name); + } + else { + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + } write(";"); } } @@ -26192,8 +26515,18 @@ var ts; var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so // temporary variables in an exported declaration need to have real declarations elsewhere - var isDeclaration = (root.kind === 198 /* VariableDeclaration */ && !(ts.getCombinedNodeFlags(root) & 1 /* Export */)) || root.kind === 129 /* Parameter */; - if (root.kind === 169 /* BinaryExpression */) { + // 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 === 199 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 130 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 170 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -26205,7 +26538,14 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 198 /* VariableDeclaration */ || name.parent.kind === 152 /* BindingElement */)) { + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 /* VariableDeclaration */ || name.parent.kind === 153 /* BindingElement */); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(name); + write("\", "); + } + if (isVariableDeclarationOrBindingElement) { emitModuleMemberName(name.parent); } else { @@ -26213,11 +26553,14 @@ var ts; } write(" = "); emit(value); + if (exportChanged) { + write(")"); + } } function ensureIdentifier(expr) { if (expr.kind !== 65 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); - if (!isDeclaration) { + if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -26230,14 +26573,14 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(169 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(170 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(170 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(171 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -26257,7 +26600,7 @@ var ts; return createPropertyAccessExpression(object, propName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(157 /* CallExpression */); + var call = ts.createSynthesizedNode(158 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -26274,7 +26617,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 224 /* PropertyAssignment */ || p.kind === 225 /* ShorthandPropertyAssignment */) { + if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); @@ -26290,8 +26633,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175 /* OmittedExpression */) { - if (e.kind !== 173 /* SpreadElementExpression */) { + if (e.kind !== 176 /* OmittedExpression */) { + if (e.kind !== 174 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26301,14 +26644,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 169 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 154 /* ObjectLiteralExpression */) { + if (target.kind === 155 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 153 /* ArrayLiteralExpression */) { + else if (target.kind === 154 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -26322,14 +26665,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 161 /* ParenthesizedExpression */) { + if (root.parent.kind !== 162 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 161 /* ParenthesizedExpression */) { + if (root.parent.kind !== 162 /* ParenthesizedExpression */) { write(")"); } } @@ -26353,12 +26696,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 150 /* ObjectBindingPattern */) { + if (pattern.kind === 151 /* 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 !== 175 /* OmittedExpression */) { + else if (element.kind !== 176 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -26386,7 +26729,6 @@ var ts; } else { renameNonTopLevelLetAndConst(node.name); - emitModuleMemberName(node); var initializer = node.initializer; if (!initializer && languageVersion < 2 /* ES6 */) { // downlevel emit for non-initialized let bindings defined in loops @@ -26399,16 +26741,26 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 187 /* ForInStatement */ && - node.parent.parent.kind !== 188 /* ForOfStatement */) { + node.parent.parent.kind !== 188 /* ForInStatement */ && + node.parent.parent.kind !== 189 /* ForOfStatement */) { initializer = createVoidZero(); } } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } } } function emitExportVariableAssignments(node) { - if (node.kind === 175 /* OmittedExpression */) { + if (node.kind === 176 /* OmittedExpression */) { return; } var name = node.name; @@ -26420,7 +26772,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -26435,7 +26787,7 @@ var ts; if (languageVersion >= 2 /* ES6 */ || ts.nodeIsSynthesized(node) || node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { + (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); @@ -26444,17 +26796,17 @@ var ts; return; } // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 199 /* VariableDeclarationList */); - if (list.parent.kind === 180 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 227 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 206 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 179 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); + var list = ts.getAncestor(node, 200 /* VariableDeclarationList */); + if (list.parent.kind === 181 /* VariableStatement */) { + var isSourceFileLevelBinding = list.parent.parent.kind === 228 /* SourceFile */; + var isModuleLevelBinding = list.parent.parent.kind === 207 /* ModuleBlock */; + var isFunctionLevelBinding = list.parent.parent.kind === 180 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { return; } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 227 /* SourceFile */ + var parent = blockScopeContainer.kind === 228 /* SourceFile */ ? blockScopeContainer : blockScopeContainer.parent; if (resolver.resolvesToSomeValue(parent, node.text)) { @@ -26469,19 +26821,28 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 227 /* SourceFile */; + node.parent.kind === 228 /* SourceFile */; } function emitVariableStatement(node) { + var startIsEmitted = true; if (!(node.flags & 1 /* Export */)) { - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); } else if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } } - emitCommaList(node.declarationList.declarations); - write(";"); if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } @@ -26585,12 +26946,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 136 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 137 /* GetAccessor */ ? "get " : "set "); emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 163 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 164 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -26601,11 +26962,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 162 /* FunctionExpression */) { + if (node.kind === 163 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 200 /* FunctionDeclaration */) { + if (node.kind === 201 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -26614,7 +26975,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -26637,10 +26998,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 200 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { emitTrailingComments(node); } } @@ -26691,7 +27052,7 @@ var ts; // in that case. write(" { }"); } - else if (node.body.kind === 179 /* Block */) { + else if (node.body.kind === 180 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -26722,10 +27083,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 160 /* TypeAssertionExpression */) { + while (current.kind === 161 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 154 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 155 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26801,9 +27162,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 182 /* ExpressionStatement */) { + if (statement && statement.kind === 183 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 157 /* CallExpression */) { + if (expr && expr.kind === 158 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 91 /* SuperKeyword */) { return statement; @@ -26835,7 +27196,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 127 /* ComputedPropertyName */) { + else if (memberName.kind === 128 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -26843,11 +27204,11 @@ var ts; emitNodeWithoutSourceMap(memberName); } } - function getInitializedProperties(node, static) { + function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 132 /* PropertyDeclaration */ && static === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -26887,11 +27248,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 178 /* SemicolonClassElement */) { + if (member.kind === 179 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) { + else if (member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -26910,7 +27271,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 136 /* GetAccessor */ || member.kind === 137 /* SetAccessor */) { + else if (member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26960,22 +27321,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) && !member.body) { + if ((member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 134 /* MethodDeclaration */ || - member.kind === 136 /* GetAccessor */ || - member.kind === 137 /* SetAccessor */) { + else if (member.kind === 135 /* MethodDeclaration */ || + member.kind === 137 /* GetAccessor */ || + member.kind === 138 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 136 /* GetAccessor */) { + if (member.kind === 137 /* GetAccessor */) { write("get "); } - else if (member.kind === 137 /* SetAccessor */) { + else if (member.kind === 138 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -26986,7 +27347,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 178 /* SemicolonClassElement */) { + else if (member.kind === 179 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -27011,11 +27372,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 135 /* Constructor */ && !member.body) { + if (member.kind === 136 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 132 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 133 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -27123,7 +27484,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* 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: @@ -27203,7 +27564,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, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 174 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -27233,6 +27594,7 @@ var ts; writeLine(); emitToken(15 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. // For a decorated class, we need to assign its name (if it has one). This is because we emit // the class as a class expression to avoid the double-binding of the identifier: // @@ -27242,15 +27604,6 @@ var ts; // if (thisNodeIsDecorated) { write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } } // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration @@ -27295,8 +27648,11 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 201 /* ClassDeclaration */) { - write("var "); + if (node.kind === 202 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } emitDeclarationName(node); write(" = "); } @@ -27351,11 +27707,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -27447,7 +27803,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 134 /* MethodDeclaration */) { + if (member.kind === 135 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -27485,7 +27841,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 132 /* PropertyDeclaration */) { + if (member.kind !== 133 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27515,7 +27871,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 132 /* PropertyDeclaration */) { + if (member.kind !== 133 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27557,10 +27913,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 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 132 /* PropertyDeclaration */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 133 /* PropertyDeclaration */: return true; } return false; @@ -27570,7 +27926,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 134 /* MethodDeclaration */: + case 135 /* MethodDeclaration */: return true; } return false; @@ -27580,9 +27936,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 201 /* ClassDeclaration */: - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: + case 202 /* ClassDeclaration */: + case 135 /* MethodDeclaration */: + case 138 /* SetAccessor */: return true; } return false; @@ -27745,7 +28101,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 205 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27762,7 +28118,9 @@ var ts; if (!shouldEmit) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (!isModuleMergedWithES6Class(node)) { + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -27779,7 +28137,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 206 /* ModuleBlock */) { + if (node.body.kind === 207 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27813,6 +28171,14 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 65 /* Identifier */ && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -27829,16 +28195,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 208 /* ImportEqualsDeclaration */) { + if (node.kind === 209 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 209 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 210 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27866,7 +28232,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27892,7 +28258,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 208 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 209 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -27911,7 +28277,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 209 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 210 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27979,6 +28345,7 @@ var ts; } } function emitExportDeclaration(node) { + ts.Debug.assert(compilerOptions.module !== 4 /* System */); if (languageVersion < 2 /* ES6 */) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); @@ -28074,8 +28441,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 200 /* FunctionDeclaration */ && - expression.kind !== 201 /* ClassDeclaration */) { + if (expression.kind !== 201 /* FunctionDeclaration */ && + expression.kind !== 202 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -28083,14 +28450,21 @@ var ts; else { writeLine(); emitStart(node); - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); + if (compilerOptions.module === 4 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); } else { - write(".default = "); + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); } - emit(node.expression); write(";"); emitEnd(node); } @@ -28104,7 +28478,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -28114,13 +28488,13 @@ var ts; externalImports.push(node); } break; - case 208 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 219 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 209 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 220 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -28141,7 +28515,7 @@ var ts; } } break; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -28162,6 +28536,476 @@ var ts; write("}"); } } + function getLocalNameForExternalImport(importNode) { + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + else { + return getGeneratedNameForNode(importNode); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 8 /* StringLiteral */) { + return getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 216 /* ExportDeclaration */ || + (importNode.kind === 210 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + if (!hasExportStars) { + // local names set is needed only in presence of star exports + return undefined; + } + // local names set should only be added if we have anything exported + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 216 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + // write name of exported declaration, i.e 'export var x...' + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + // write name of export specified, i.e. 'export {x}' + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 216 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + // define an export star helper function + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") " + exportFunctionForFile + "(n, m[n]);"); + decreaseIndent(); + writeLine(); + write("}"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + // do not record default exports + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 65 /* Identifier */ && node.flags & 256 /* Default */) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 65 /* Identifier */) { + emitNodeWithoutSourceMap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + if (i !== 0) { + write(", "); + } + if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 65 /* Identifier */ ? local.parent : local); + if (flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.kind === 201 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 202 /* ClassDeclaration */) { + // TODO: rename block scoped classes + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 206 /* ModuleDeclaration */ && shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (shouldHoistVariable(node, false)) { + var name_21 = node.name; + if (name_21.kind === 65 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_21); + } + else { + ts.forEachChild(name_21, visit); + } + } + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // 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) & 12288 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 228 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, startIndex) { + // shape of the body in system modules: + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // I.e: + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // will be transformed to + // function(exports) { + // var file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction); + writeLine(); + emitExecute(node, startIndex); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + write("}"); // return + } + function emitSetters(exportStarFunction) { + write("setters:["); + for (var i = 0; i < externalImports.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var importNode = externalImports[i]; + var importVariableName = getLocalNameForExternalImport(importNode) || ""; + var parameterName = "_" + importVariableName; + write("function (" + parameterName + ") {"); + switch (importNode.kind) { + case 210 /* ImportDeclaration */: + if (!importNode.importClause) { + // 'import "..."' case + // module is imported only for side-effects, setter body will be empty + break; + } + // fall-through + case 209 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + var defaultName = importNode.kind === 210 /* ImportDeclaration */ + ? importNode.importClause.name + : importNode.name; + if (defaultName) { + // emit re-export for imported default name + // import n1 from 'foo1' + // import n2 = require('foo2') + // export {n1} + // export {n2} + emitExportMemberAssignments(defaultName); + writeLine(); + } + if (importNode.kind === 210 /* ImportDeclaration */ && + importNode.importClause.namedBindings) { + var namedBindings = importNode.importClause.namedBindings; + if (namedBindings.kind === 212 /* NamespaceImport */) { + // emit re-export for namespace + // import * as n from 'foo' + // export {n} + emitExportMemberAssignments(namedBindings.name); + writeLine(); + } + else { + // emit re-exports for named imports + // import {a, b} from 'foo' + // export {a, b as c} + for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportMemberAssignments(element.name || element.propertyName); + writeLine(); + } + } + } + decreaseIndent(); + break; + case 216 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + if (importNode.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports('a', _foo["a"]) + // exports('c', _foo["b"]) + for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + writeLine(); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(e.name); + write("\", " + parameterName + "[\""); + emitNodeWithoutSourceMap(e.propertyName || e.name); + write("\"]);"); + } + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + decreaseIndent(); + break; + } + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + // - imports/exports are not emitted for system modules + // - function declarations are not emitted because they were already hoisted + switch (statement.kind) { + case 216 /* ExportDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 201 /* FunctionDeclaration */: + continue; + } + writeLine(); + emit(statement); + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node, startIndex) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. + // 'exports' returns its 'value' argument so in most cases expressions + // that mutate exported values can be rewritten as: + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, + // see comment to 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + write("System.register(["); + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } function emitAMDDependencies(node, includeNonAmdDependencies) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); @@ -28178,8 +29022,8 @@ var ts; // factory function. var unaliasedModuleNames = []; // names of modules with no corresponding parameters in // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { @@ -28195,20 +29039,9 @@ var ts; for (var _c = 0; _c < externalImports.length; _c++) { var importNode = externalImports[_c]; // Find the name of the external module - var externalModuleName = ""; - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - externalModuleName = getLiteralText(moduleName); - } + var externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one - var importAliasName = void 0; - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { - importAliasName = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - else { - importAliasName = getGeneratedNameForNode(importNode); - } + var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); @@ -28327,30 +29160,36 @@ var ts; emitDetachedComments(node); // emit prologue directives prior to __extends var startIndex = emitDirectivePrologues(node.statements, false); - // 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 */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); + // Only emit helpers if the user did not say otherwise. + 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 */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; } - decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (ts.isExternalModule(node)) { + if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); } else if (compilerOptions.module === 2 /* AMD */) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 4 /* System */) { + emitSystemModule(node, startIndex); + } else if (compilerOptions.module === 3 /* UMD */) { emitUMDModule(node, startIndex); } @@ -28389,18 +29228,18 @@ var ts; 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 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 214 /* ExportAssignment */: + case 203 /* InterfaceDeclaration */: + case 201 /* FunctionDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 215 /* ExportAssignment */: return false; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -28409,9 +29248,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 !== 179 /* Block */ && + if (node.kind !== 180 /* Block */ && node.parent && - node.parent.kind === 163 /* ArrowFunction */ && + node.parent.kind === 164 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -28425,13 +29264,13 @@ var ts; switch (node.kind) { case 65 /* Identifier */: return emitIdentifier(node, allowGeneratedIdentifiers); - case 129 /* Parameter */: + case 130 /* Parameter */: return emitParameter(node); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return emitMethod(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return emitAccessor(node); case 93 /* ThisKeyword */: return emitThis(node); @@ -28451,140 +29290,140 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: return emitTemplateExpression(node); - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return emitTemplateSpan(node); - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ObjectBindingPattern */: + case 151 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 151 /* ArrayBindingPattern */: + case 152 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 152 /* BindingElement */: + case 153 /* BindingElement */: return emitBindingElement(node); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 224 /* PropertyAssignment */: + case 225 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 225 /* ShorthandPropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 155 /* PropertyAccessExpression */: + case 156 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 157 /* CallExpression */: + case 158 /* CallExpression */: return emitCallExpression(node); - case 158 /* NewExpression */: + case 159 /* NewExpression */: return emitNewExpression(node); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return emit(node.expression); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return emitParenExpression(node); - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 164 /* DeleteExpression */: + case 165 /* DeleteExpression */: return emitDeleteExpression(node); - case 165 /* TypeOfExpression */: + case 166 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 166 /* VoidExpression */: + case 167 /* VoidExpression */: return emitVoidExpression(node); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 168 /* PostfixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return emitBinaryExpression(node); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return emitConditionalExpression(node); - case 173 /* SpreadElementExpression */: + case 174 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 172 /* YieldExpression */: + case 173 /* YieldExpression */: return emitYieldExpression(node); - case 175 /* OmittedExpression */: + case 176 /* OmittedExpression */: return; - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return emitBlock(node); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return emitVariableStatement(node); - case 181 /* EmptyStatement */: + case 182 /* EmptyStatement */: return write(";"); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return emitExpressionStatement(node); - case 183 /* IfStatement */: + case 184 /* IfStatement */: return emitIfStatement(node); - case 184 /* DoStatement */: + case 185 /* DoStatement */: return emitDoStatement(node); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: return emitWhileStatement(node); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return emitForStatement(node); - case 188 /* ForOfStatement */: - case 187 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 188 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return emitReturnStatement(node); - case 192 /* WithStatement */: + case 193 /* WithStatement */: return emitWithStatement(node); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return emitSwitchStatement(node); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return emitLabelledStatement(node); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: return emitThrowStatement(node); - case 196 /* TryStatement */: + case 197 /* TryStatement */: return emitTryStatement(node); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return emitCatchClause(node); - case 197 /* DebuggerStatement */: + case 198 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: return emitClassExpression(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return emitClassDeclaration(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return emitEnumMember(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return emitImportDeclaration(node); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return emitExportDeclaration(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return emitExportAssignment(node); - case 227 /* SourceFile */: + case 228 /* SourceFile */: return emitSourceFileNode(node); } } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -28607,7 +29446,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 === 227 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 228 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -28622,7 +29461,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 === 227 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 228 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -28685,13 +29524,13 @@ var ts; // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); } @@ -28733,6 +29572,8 @@ var ts; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ ts.version = "1.5.0"; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -28806,6 +29647,9 @@ var ts; } } } + var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed : + options.newLine === 1 /* LineFeed */ ? lineFeed : + ts.sys.newLine; return { getSourceFile: getSourceFile, getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, @@ -28813,14 +29657,14 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return ts.sys.newLine; } + getNewLine: function () { return newLine; } }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program) { - var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + function getPreEmitDiagnostics(program, sourceFile) { + var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics()); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -29068,7 +29912,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 209 /* ImportDeclaration */ || node.kind === 208 /* ImportEqualsDeclaration */ || node.kind === 215 /* ExportDeclaration */) { + if (node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */ || node.kind === 216 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -29088,7 +29932,7 @@ var ts; } } } - else if (node.kind === 205 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -29183,6 +30027,22 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); } } + if (options.inlineSourceMap) { + if (options.sourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.mapRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.sourceRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { @@ -29202,17 +30062,17 @@ var ts; var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -29279,6 +30139,14 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "inlineSourceMap", + type: "boolean" + }, + { + name: "inlineSources", + type: "boolean" + }, { name: "listFiles", type: "boolean" @@ -29300,17 +30168,32 @@ var ts; type: { "commonjs": 1 /* CommonJS */, "amd": 2 /* AMD */, + "system": 4 /* System */, "umd": 3 /* UMD */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + }, + { + name: "newLine", + type: { + "crlf": 0 /* CarriageReturnLineFeed */, + "lf": 1 /* LineFeed */ + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF }, { name: "noEmit", type: "boolean", description: ts.Diagnostics.Do_not_emit_outputs }, + { + name: "noEmitHelpers", + type: "boolean" + }, { name: "noEmitOnError", type: "boolean", @@ -29531,19 +30414,34 @@ var ts; function readConfigFile(fileName) { try { var text = ts.sys.readFile(fileName); - return /\S/.test(text) ? JSON.parse(text) : {}; } catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } + return parseConfigFileText(fileName, text); } ts.readConfigFile = readConfigFile; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileText(fileName, jsonText) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileText = parseConfigFileText; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseConfigFile(json, basePath) { + function parseConfigFile(json, host, basePath) { var errors = []; return { options: getCompilerOptions(), @@ -29599,7 +30497,7 @@ var ts; } } else { - var sysFiles = ts.sys.readDirectory(basePath, ".ts"); + var sysFiles = host.readDirectory(basePath, ".ts"); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { @@ -29684,7 +30582,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 163 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 164 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -29696,7 +30594,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 179 /* Block */: + case 180 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_6 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); @@ -29704,18 +30602,18 @@ var ts; // 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_6.kind === 184 /* DoStatement */ || - parent_6.kind === 187 /* ForInStatement */ || - parent_6.kind === 188 /* ForOfStatement */ || - parent_6.kind === 186 /* ForStatement */ || - parent_6.kind === 183 /* IfStatement */ || - parent_6.kind === 185 /* WhileStatement */ || - parent_6.kind === 192 /* WithStatement */ || - parent_6.kind === 223 /* CatchClause */) { + if (parent_6.kind === 185 /* DoStatement */ || + parent_6.kind === 188 /* ForInStatement */ || + parent_6.kind === 189 /* ForOfStatement */ || + parent_6.kind === 187 /* ForStatement */ || + parent_6.kind === 184 /* IfStatement */ || + parent_6.kind === 186 /* WhileStatement */ || + parent_6.kind === 193 /* WithStatement */ || + parent_6.kind === 224 /* CatchClause */) { addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_6.kind === 196 /* TryStatement */) { + if (parent_6.kind === 197 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_6; if (tryStatement.tryBlock === n) { @@ -29742,23 +30640,23 @@ var ts; break; } // Fallthrough. - case 206 /* ModuleBlock */: { + case 207 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 154 /* ObjectLiteralExpression */: - case 207 /* CaseBlock */: { + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 155 /* ObjectLiteralExpression */: + case 208 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -29786,12 +30684,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_21 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_21); + for (var name_22 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_22); 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_21); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_22); if (!matches) { continue; } @@ -29804,14 +30702,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_21); + matches = patternMatcher.getMatches(containers, name_22); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_21, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_22, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -29849,7 +30747,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 127 /* ComputedPropertyName */) { + else if (declaration.name.kind === 128 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -29870,7 +30768,7 @@ var ts; } return true; } - if (expression.kind === 155 /* PropertyAccessExpression */) { + if (expression.kind === 156 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -29883,7 +30781,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 === 127 /* ComputedPropertyName */) { + if (declaration.name.kind === 128 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -29959,17 +30857,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* 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 === 205 /* ModuleDeclaration */); + } while (current.kind === 206 /* ModuleDeclaration */); // fall through - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 203 /* InterfaceDeclaration */: + case 201 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -29980,21 +30878,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 215 /* ExportDeclaration */: + case 216 /* 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 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -30006,7 +30904,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -30015,21 +30913,21 @@ var ts; } } break; - case 152 /* BindingElement */: - case 198 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 199 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 200 /* FunctionDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 201 /* FunctionDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: childNodes.push(node); break; } @@ -30077,17 +30975,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 203 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -30098,12 +30996,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 200 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 201 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 179 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 180 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 200 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -30163,7 +31061,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 129 /* Parameter */: + case 130 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -30171,36 +31069,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 137 /* SetAccessor */: + case 138 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 138 /* CallSignature */: + case 139 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: var variableDeclarationNode; - var name_22; - if (node.kind === 152 /* BindingElement */) { - name_22 = node.name; + var name_23; + if (node.kind === 153 /* BindingElement */) { + name_23 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 198 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 199 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -30208,24 +31106,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_22 = node.name; + name_23 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.variableElement); } - case 135 /* Constructor */: + case 136 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 217 /* ExportSpecifier */: - case 213 /* ImportSpecifier */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: + case 218 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -30255,17 +31153,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: return createSourceFileItem(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return createClassItem(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return createEnumItem(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return createModuleItem(node); - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -30277,7 +31175,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 205 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -30289,7 +31187,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 === 179 /* Block */) { + if (node.body && node.body.kind === 180 /* 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)); } @@ -30310,7 +31208,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 135 /* Constructor */ && member; + return member.kind === 136 /* 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 @@ -30334,7 +31232,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 127 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -30343,13 +31241,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 205 /* ModuleDeclaration */) { + while (node.body.kind === 206 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 227 /* SourceFile */ + return node.kind === 228 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -31144,7 +32042,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 157 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 158 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -31152,7 +32050,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 65 /* Identifier */ ? expression - : expression.kind === 155 /* PropertyAccessExpression */ + : expression.kind === 156 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -31185,7 +32083,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 157 /* CallExpression */ || node.parent.kind === 158 /* NewExpression */) { + if (node.parent.kind === 158 /* CallExpression */ || node.parent.kind === 159 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -31238,25 +32136,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 159 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 160 /* 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, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 159 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 160 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 171 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 176 /* TemplateSpan */ && node.parent.parent.parent.kind === 159 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 178 /* TemplateSpan */ && node.parent.parent.parent.kind === 160 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 171 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -31374,7 +32272,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 === 171 /* TemplateExpression */) { + if (template.kind === 172 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -31383,7 +32281,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 227 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 228 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -31584,40 +32482,40 @@ var ts; return false; } switch (n.kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 154 /* ObjectLiteralExpression */: - case 150 /* ObjectBindingPattern */: - case 145 /* TypeLiteral */: - case 179 /* Block */: - case 206 /* ModuleBlock */: - case 207 /* CaseBlock */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 155 /* ObjectLiteralExpression */: + case 151 /* ObjectBindingPattern */: + case 146 /* TypeLiteral */: + case 180 /* Block */: + case 207 /* ModuleBlock */: + case 208 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 158 /* NewExpression */: + case 159 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 157 /* CallExpression */: - case 161 /* ParenthesizedExpression */: - case 149 /* ParenthesizedType */: + case 158 /* CallExpression */: + case 162 /* ParenthesizedExpression */: + case 150 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 139 /* ConstructSignature */: - case 138 /* CallSignature */: - case 163 /* ArrowFunction */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 140 /* ConstructSignature */: + case 139 /* CallSignature */: + case 164 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -31627,63 +32525,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 183 /* IfStatement */: + case 184 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 153 /* ArrayLiteralExpression */: - case 151 /* ArrayBindingPattern */: - case 156 /* ElementAccessExpression */: - case 127 /* ComputedPropertyName */: - case 147 /* TupleType */: + case 154 /* ArrayLiteralExpression */: + case 152 /* ArrayBindingPattern */: + case 157 /* ElementAccessExpression */: + case 128 /* ComputedPropertyName */: + case 148 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 185 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 186 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 184 /* DoStatement */: + case 185 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 165 /* TypeOfExpression */: - case 164 /* DeleteExpression */: - case 166 /* VoidExpression */: - case 172 /* YieldExpression */: - case 173 /* SpreadElementExpression */: + case 166 /* TypeOfExpression */: + case 165 /* DeleteExpression */: + case 167 /* VoidExpression */: + case 173 /* YieldExpression */: + case 174 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -31697,7 +32595,7 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last = children[children.length - 1]; + var last = ts.lastOrUndefined(children); if (last.kind === expectedLastToken) { return true; } @@ -31739,7 +32637,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 === 228 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 229 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -31873,7 +32771,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 227 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 228 /* 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. @@ -31917,17 +32815,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 141 /* TypeReference */ || node.kind === 157 /* CallExpression */) { + if (node.kind === 142 /* TypeReference */ || node.kind === 158 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 201 /* ClassDeclaration */ || node.kind === 202 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 202 /* ClassDeclaration */ || node.kind === 203 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 125 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 126 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -31982,7 +32880,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 129 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -32191,7 +33089,7 @@ var ts; if (isStarted) { if (trailingTrivia) { ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === 4 /* NewLineTrivia */; + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; } else { wasNewLine = false; @@ -32684,7 +33582,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 120 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 121 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -32692,9 +33590,9 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 118 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 119 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 120 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 118 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 121 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -32714,7 +33612,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 120 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 121 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -32804,9 +33702,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_23 in o) { - if (o[name_23] === rule) { - return name_23; + for (var name_24 in o) { + if (o[name_24] === rule) { + return name_24; } } throw new Error("Unknown rule"); @@ -32815,36 +33713,36 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 186 /* ForStatement */; + return context.contextNode.kind === 187 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 169 /* BinaryExpression */: - case 170 /* ConditionalExpression */: + case 170 /* BinaryExpression */: + case 171 /* ConditionalExpression */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 152 /* BindingElement */: + case 153 /* BindingElement */: // equals in type X = ... - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: // equal in p = 0; - case 129 /* Parameter */: - case 226 /* EnumMember */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 130 /* Parameter */: + case 227 /* EnumMember */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 187 /* ForInStatement */: + case 188 /* ForInStatement */: return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 188 /* ForOfStatement */: - return context.currentTokenSpan.kind === 125 /* OfKeyword */ || context.nextTokenSpan.kind === 125 /* OfKeyword */; + case 189 /* ForOfStatement */: + return context.currentTokenSpan.kind === 126 /* OfKeyword */ || context.nextTokenSpan.kind === 126 /* OfKeyword */; } return false; }; @@ -32852,7 +33750,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 170 /* ConditionalExpression */; + return context.contextNode.kind === 171 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -32896,31 +33794,31 @@ var ts; return true; } switch (node.kind) { - case 179 /* Block */: - case 207 /* CaseBlock */: - case 154 /* ObjectLiteralExpression */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 208 /* CaseBlock */: + case 155 /* ObjectLiteralExpression */: + case 207 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 138 /* CallSignature */: - case 162 /* FunctionExpression */: - case 135 /* Constructor */: - case 163 /* ArrowFunction */: + case 139 /* CallSignature */: + case 163 /* FunctionExpression */: + case 136 /* Constructor */: + case 164 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return true; } return false; @@ -32930,55 +33828,55 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 145 /* TypeLiteral */: - case 205 /* ModuleDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 146 /* TypeLiteral */: + case 206 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 201 /* ClassDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: - case 179 /* Block */: - case 223 /* CatchClause */: - case 206 /* ModuleBlock */: - case 193 /* SwitchStatement */: + case 202 /* ClassDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: + case 180 /* Block */: + case 224 /* CatchClause */: + case 207 /* ModuleBlock */: + case 194 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 183 /* IfStatement */: - case 193 /* SwitchStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 185 /* WhileStatement */: - case 196 /* TryStatement */: - case 184 /* DoStatement */: - case 192 /* WithStatement */: + case 184 /* IfStatement */: + case 194 /* SwitchStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 186 /* WhileStatement */: + case 197 /* TryStatement */: + case 185 /* DoStatement */: + case 193 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 223 /* CatchClause */: + case 224 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 154 /* ObjectLiteralExpression */; + return context.contextNode.kind === 155 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 157 /* CallExpression */; + return context.contextNode.kind === 158 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 158 /* NewExpression */; + return context.contextNode.kind === 159 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -32999,38 +33897,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 130 /* Decorator */; + return node.kind === 131 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 199 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 200 /* 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 === 205 /* ModuleDeclaration */; + return context.contextNode.kind === 206 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 145 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 146 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 141 /* TypeReference */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 142 /* TypeReference */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return true; default: return false; @@ -33041,7 +33939,7 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 166 /* VoidExpression */; + return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 167 /* VoidExpression */; }; return Rules; })(); @@ -33065,7 +33963,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 125 /* LastToken */ + 1; + this.mapRowLength = 126 /* 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); @@ -33260,7 +34158,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 125 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 126 /* LastToken */; token++) { result.push(token); } return result; @@ -33302,9 +34200,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 125 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 126 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 125 /* OfKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 126 /* OfKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); @@ -33312,7 +34210,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 119 /* NumberKeyword */, 121 /* StringKeyword */, 113 /* BooleanKeyword */, 122 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 120 /* NumberKeyword */, 122 /* StringKeyword */, 113 /* BooleanKeyword */, 123 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -33515,17 +34413,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 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 179 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 227 /* SourceFile */: - case 179 /* Block */: - case 206 /* ModuleBlock */: + return body && body.kind === 180 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 228 /* SourceFile */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -33650,6 +34548,8 @@ var ts; var previousRange; var previousParent; var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -33696,9 +34596,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 227 /* SourceFile */ || - parent.kind === 220 /* CaseClause */ || - parent.kind === 221 /* DefaultClause */) { + parent.kind === 228 /* SourceFile */ || + parent.kind === 221 /* CaseClause */ || + parent.kind === 222 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -33719,7 +34619,9 @@ var ts; // if node is located on the same line with the parent // - inherit indentation from the parent // - push children if either parent of node itself has non-zero delta - indentation = parentDynamicIndentation.getIndentation(); + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); } return { @@ -33732,19 +34634,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 201 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 202 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 200 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 204 /* EnumDeclaration */: return 204 /* EnumDeclaration */; - case 136 /* GetAccessor */: return 116 /* GetKeyword */; - case 137 /* SetAccessor */: return 120 /* SetKeyword */; - case 134 /* MethodDeclaration */: + case 202 /* ClassDeclaration */: return 69 /* ClassKeyword */; + case 203 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; + case 201 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; + case 205 /* EnumDeclaration */: return 205 /* EnumDeclaration */; + case 137 /* GetAccessor */: return 116 /* GetKeyword */; + case 138 /* SetAccessor */: return 121 /* SetKeyword */; + case 135 /* MethodDeclaration */: if (node.asteriskToken) { return 35 /* AsteriskToken */; } // fall-through - case 132 /* PropertyDeclaration */: - case 129 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 130 /* Parameter */: return node.name.kind; } } @@ -33877,7 +34779,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 130 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 131 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -33967,7 +34869,6 @@ var ts; if (!ts.rangeContainsRange(originalRange, triviaItem)) { continue; } - var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); @@ -33991,6 +34892,8 @@ var ts; if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; } } formattingScanner.advance(); @@ -34199,20 +35102,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 135 /* Constructor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 163 /* ArrowFunction */: + case 136 /* Constructor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 164 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -34220,8 +35123,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -34229,7 +35132,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 141 /* TypeReference */: + case 142 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -34328,7 +35231,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 169 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 170 /* 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 */) { @@ -34439,7 +35342,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 === 227 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 228 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -34472,7 +35375,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 183 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 184 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -34484,23 +35387,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 141 /* TypeReference */: + case 142 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return node.parent.properties; - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return node.parent.elements; - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: { + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -34511,8 +35414,8 @@ var ts; } break; } - case 158 /* NewExpression */: - case 157 /* CallExpression */: { + case 159 /* NewExpression */: + case 158 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -34591,28 +35494,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 153 /* ArrayLiteralExpression */: - case 179 /* Block */: - case 206 /* ModuleBlock */: - case 154 /* ObjectLiteralExpression */: - case 145 /* TypeLiteral */: - case 147 /* TupleType */: - case 207 /* CaseBlock */: - case 221 /* DefaultClause */: - case 220 /* CaseClause */: - case 161 /* ParenthesizedExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 180 /* VariableStatement */: - case 198 /* VariableDeclaration */: - case 214 /* ExportAssignment */: - case 191 /* ReturnStatement */: - case 170 /* ConditionalExpression */: - case 151 /* ArrayBindingPattern */: - case 150 /* ObjectBindingPattern */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 154 /* ArrayLiteralExpression */: + case 180 /* Block */: + case 207 /* ModuleBlock */: + case 155 /* ObjectLiteralExpression */: + case 146 /* TypeLiteral */: + case 148 /* TupleType */: + case 208 /* CaseBlock */: + case 222 /* DefaultClause */: + case 221 /* CaseClause */: + case 162 /* ParenthesizedExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 181 /* VariableStatement */: + case 199 /* VariableDeclaration */: + case 215 /* ExportAssignment */: + case 192 /* ReturnStatement */: + case 171 /* ConditionalExpression */: + case 152 /* ArrayBindingPattern */: + case 151 /* ObjectBindingPattern */: return true; } return false; @@ -34622,22 +35525,22 @@ var ts; return true; } switch (parent) { - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 186 /* ForStatement */: - case 183 /* IfStatement */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 138 /* CallSignature */: - case 163 /* ArrowFunction */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - return child !== 179 /* Block */; + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 187 /* ForStatement */: + case 184 /* IfStatement */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 139 /* CallSignature */: + case 164 /* ArrowFunction */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + return child !== 180 /* Block */; default: return false; } @@ -34647,7 +35550,7 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -34742,7 +35645,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(228 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(229 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -34761,7 +35664,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 126 /* FirstNode */) { + if (this.kind >= 127 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -34806,7 +35709,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 126 /* FirstNode */) { + if (child.kind < 127 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -34816,7 +35719,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 126 /* FirstNode */) { + if (child.kind < 127 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -34869,7 +35772,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 === 129 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 130 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -34878,15 +35781,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 205 /* ModuleDeclaration */ && declaration.body.kind === 205 /* ModuleDeclaration */) { + if (declaration.kind === 206 /* ModuleDeclaration */ && declaration.body.kind === 206 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 205 /* ModuleDeclaration */ && declaration.parent.kind === 205 /* ModuleDeclaration */) { + while (declaration.kind === 206 /* ModuleDeclaration */ && declaration.parent.kind === 206 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 198 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -35225,9 +36128,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 127 /* ComputedPropertyName */) { + if (declaration.name.kind === 128 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 155 /* PropertyAccessExpression */) { + if (expr.kind === 156 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -35247,9 +36150,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -35269,60 +36172,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 217 /* ExportSpecifier */: - case 213 /* ImportSpecifier */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 145 /* TypeLiteral */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* EnumDeclaration */: + case 206 /* ModuleDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 218 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 146 /* TypeLiteral */: addDeclaration(node); // fall through - case 135 /* Constructor */: - case 180 /* VariableStatement */: - case 199 /* VariableDeclarationList */: - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: - case 206 /* ModuleBlock */: + case 136 /* Constructor */: + case 181 /* VariableStatement */: + case 200 /* VariableDeclarationList */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: + case 207 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 179 /* Block */: + case 180 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 129 /* Parameter */: + case 130 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 226 /* EnumMember */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 227 /* EnumMember */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: addDeclaration(node); break; - case 215 /* ExportDeclaration */: + case 216 /* 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 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35334,7 +36237,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -35393,7 +36296,7 @@ var ts; })(ts.OutputFileType || (ts.OutputFileType = {})); var OutputFileType = ts.OutputFileType; (function (EndOfLineState) { - EndOfLineState[EndOfLineState["Start"] = 0] = "Start"; + EndOfLineState[EndOfLineState["None"] = 0] = "None"; EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; @@ -35495,10 +36398,31 @@ var ts; ClassificationTypeNames.interfaceName = "interface name"; ClassificationTypeNames.moduleName = "module name"; ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAlias = "type alias name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; return ClassificationTypeNames; })(); ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -35512,16 +36436,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 162 /* FunctionExpression */) { + if (declaration.kind === 163 /* FunctionExpression */) { return true; } - if (declaration.kind !== 198 /* VariableDeclaration */ && declaration.kind !== 200 /* FunctionDeclaration */) { + if (declaration.kind !== 199 /* VariableDeclaration */ && declaration.kind !== 201 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_7 = declaration.parent; !ts.isFunctionBlock(parent_7); parent_7 = parent_7.parent) { // Reached source file or module block - if (parent_7.kind === 227 /* SourceFile */ || parent_7.kind === 206 /* ModuleBlock */) { + if (parent_7.kind === 228 /* SourceFile */ || parent_7.kind === 207 /* ModuleBlock */) { return false; } } @@ -35873,7 +36797,7 @@ var ts; else { if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -35883,7 +36807,7 @@ var ts; } else if (token === 53 /* EqualsToken */) { token = scanner.scan(); - if (token === 118 /* RequireKeyword */) { + if (token === 119 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -35912,7 +36836,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -35928,7 +36852,7 @@ var ts; token = scanner.scan(); if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -35951,7 +36875,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -35963,7 +36887,7 @@ var ts; } else if (token === 35 /* AsteriskToken */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -35986,7 +36910,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 194 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 195 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -35995,12 +36919,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 /* Identifier */ && - (node.parent.kind === 190 /* BreakStatement */ || node.parent.kind === 189 /* ContinueStatement */) && + (node.parent.kind === 191 /* BreakStatement */ || node.parent.kind === 190 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 /* Identifier */ && - node.parent.kind === 194 /* LabeledStatement */ && + node.parent.kind === 195 /* LabeledStatement */ && node.parent.label === node; } /** @@ -36008,7 +36932,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 194 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 195 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -36019,25 +36943,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 126 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 157 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 205 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 206 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 /* Identifier */ && @@ -36046,22 +36970,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 === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 224 /* PropertyAssignment */ || node.parent.kind === 225 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 225 /* PropertyAssignment */ || node.parent.kind === 226 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 205 /* ModuleDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 227 /* EnumMember */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 206 /* ModuleDeclaration */: return node.parent.name === node; - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -36120,7 +37044,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 125 /* LastKeyword */; i++) { + for (var i = 66 /* FirstKeyword */; i <= 126 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -36135,17 +37059,17 @@ var ts; return undefined; } switch (node.kind) { - case 227 /* SourceFile */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: + case 228 /* SourceFile */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 206 /* ModuleDeclaration */: return node; } } @@ -36153,38 +37077,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 205 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 201 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 202 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 203 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 204 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 198 /* VariableDeclaration */: + case 206 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 202 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 203 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 204 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 205 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 199 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 200 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 136 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 137 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 201 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 137 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 138 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 140 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 139 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 138 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 135 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 128 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 226 /* EnumMember */: return ScriptElementKind.variableElement; - case 129 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 208 /* ImportEqualsDeclaration */: - case 213 /* ImportSpecifier */: - case 210 /* ImportClause */: - case 217 /* ExportSpecifier */: - case 211 /* NamespaceImport */: + case 141 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 140 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 139 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 136 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 129 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 227 /* EnumMember */: return ScriptElementKind.variableElement; + case 130 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 209 /* ImportEqualsDeclaration */: + case 214 /* ImportSpecifier */: + case 211 /* ImportClause */: + case 218 /* ExportSpecifier */: + case 212 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -36385,44 +37309,44 @@ var ts; return false; } switch (node.kind) { - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 222 /* HeritageClause */: + case 223 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 102 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 200 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -36430,20 +37354,20 @@ var ts; return true; } break; - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -36451,7 +37375,7 @@ var ts; return true; } break; - case 129 /* Parameter */: + case 130 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -36467,17 +37391,17 @@ var ts; return true; } break; - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 160 /* TypeAssertionExpression */: + case 161 /* 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 130 /* Decorator */: + case 131 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -36610,11 +37534,11 @@ var ts; // visible symbols in the scope, and the node is the current location. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 155 /* PropertyAccessExpression */) { + if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 156 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 126 /* QualifiedName */) { + else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 127 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -36641,7 +37565,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */ || node.kind === 155 /* PropertyAccessExpression */) { + if (node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -36683,13 +37607,13 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 210 /* ImportClause */)) { + else if (ts.getAncestor(contextToken, 211 /* ImportClause */)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 209 /* ImportDeclaration */); + var importDeclaration = ts.getAncestor(contextToken, 210 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); var exports; if (importDeclaration.moduleSpecifier) { @@ -36768,7 +37692,7 @@ var ts; // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 212 /* NamedImports */; + return node.parent.kind === 213 /* NamedImports */; } } return false; @@ -36778,35 +37702,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 157 /* CallExpression */ // func( a, | - || containingNodeKind === 135 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 158 /* NewExpression */ // new C(a, | - || containingNodeKind === 153 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 169 /* BinaryExpression */; // let x = (a, | + return containingNodeKind === 158 /* CallExpression */ // func( a, | + || containingNodeKind === 136 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === 159 /* NewExpression */ // new C(a, | + || containingNodeKind === 154 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 170 /* BinaryExpression */; // let x = (a, | case 16 /* OpenParenToken */: - return containingNodeKind === 157 /* CallExpression */ // func( | - || containingNodeKind === 135 /* Constructor */ // constructor( | - || containingNodeKind === 158 /* NewExpression */ // new C(a| - || containingNodeKind === 161 /* ParenthesizedExpression */; // let x = (a| + return containingNodeKind === 158 /* CallExpression */ // func( | + || containingNodeKind === 136 /* Constructor */ // constructor( | + || containingNodeKind === 159 /* NewExpression */ // new C(a| + || containingNodeKind === 162 /* ParenthesizedExpression */; // let x = (a| case 18 /* OpenBracketToken */: - return containingNodeKind === 153 /* ArrayLiteralExpression */; // [ | - case 117 /* ModuleKeyword */: + return containingNodeKind === 154 /* ArrayLiteralExpression */; // [ | + case 117 /* ModuleKeyword */: // module | + case 118 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 205 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 206 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 201 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 202 /* ClassDeclaration */; // class A{ | case 53 /* EqualsToken */: - return containingNodeKind === 198 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 169 /* BinaryExpression */; // x = a| + return containingNodeKind === 199 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 170 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 171 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 172 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 176 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 178 /* TemplateSpan */; // `aa ${10} dd ${| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 132 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 133 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -36842,7 +37767,7 @@ var ts; switch (previousToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_8 && parent_8.kind === 154 /* ObjectLiteralExpression */) { + if (parent_8 && parent_8.kind === 155 /* ObjectLiteralExpression */) { return parent_8; } break; @@ -36852,16 +37777,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: return true; } return false; @@ -36871,56 +37796,56 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 198 /* VariableDeclaration */ || - containingNodeKind === 199 /* VariableDeclarationList */ || - containingNodeKind === 180 /* VariableStatement */ || - containingNodeKind === 204 /* EnumDeclaration */ || + return containingNodeKind === 199 /* VariableDeclaration */ || + containingNodeKind === 200 /* VariableDeclarationList */ || + containingNodeKind === 181 /* VariableStatement */ || + containingNodeKind === 205 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 201 /* ClassDeclaration */ || - containingNodeKind === 200 /* FunctionDeclaration */ || - containingNodeKind === 202 /* InterfaceDeclaration */ || - containingNodeKind === 151 /* ArrayBindingPattern */ || - containingNodeKind === 150 /* ObjectBindingPattern */; // function func({ x, y| + containingNodeKind === 202 /* ClassDeclaration */ || + containingNodeKind === 201 /* FunctionDeclaration */ || + containingNodeKind === 203 /* InterfaceDeclaration */ || + containingNodeKind === 152 /* ArrayBindingPattern */ || + containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x, y| case 20 /* DotToken */: - return containingNodeKind === 151 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 152 /* ArrayBindingPattern */; // var [.| case 18 /* OpenBracketToken */: - return containingNodeKind === 151 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 152 /* ArrayBindingPattern */; // var [x| case 16 /* OpenParenToken */: - return containingNodeKind === 223 /* CatchClause */ || + return containingNodeKind === 224 /* CatchClause */ || isFunction(containingNodeKind); case 14 /* OpenBraceToken */: - return containingNodeKind === 204 /* EnumDeclaration */ || - containingNodeKind === 202 /* InterfaceDeclaration */ || - containingNodeKind === 145 /* TypeLiteral */ || - containingNodeKind === 150 /* ObjectBindingPattern */; // function func({ x| + return containingNodeKind === 205 /* EnumDeclaration */ || + containingNodeKind === 203 /* InterfaceDeclaration */ || + containingNodeKind === 146 /* TypeLiteral */ || + containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x| case 22 /* SemicolonToken */: - return containingNodeKind === 131 /* PropertySignature */ && + return containingNodeKind === 132 /* PropertySignature */ && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 202 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 145 /* TypeLiteral */); // let x : { a; | + (previousToken.parent.parent.kind === 203 /* InterfaceDeclaration */ || + previousToken.parent.parent.kind === 146 /* TypeLiteral */); // let x : { a; | case 24 /* LessThanToken */: - return containingNodeKind === 201 /* ClassDeclaration */ || - containingNodeKind === 200 /* FunctionDeclaration */ || - containingNodeKind === 202 /* InterfaceDeclaration */ || + return containingNodeKind === 202 /* ClassDeclaration */ || + containingNodeKind === 201 /* FunctionDeclaration */ || + containingNodeKind === 203 /* InterfaceDeclaration */ || isFunction(containingNodeKind); case 109 /* StaticKeyword */: - return containingNodeKind === 132 /* PropertyDeclaration */; + return containingNodeKind === 133 /* PropertyDeclaration */; case 21 /* DotDotDotToken */: - return containingNodeKind === 129 /* Parameter */ || - containingNodeKind === 135 /* Constructor */ || + return containingNodeKind === 130 /* Parameter */ || + containingNodeKind === 136 /* Constructor */ || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 151 /* ArrayBindingPattern */); // var [ ...z| + previousToken.parent.parent.kind === 152 /* ArrayBindingPattern */); // var [ ...z| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 129 /* Parameter */; + return containingNodeKind === 130 /* Parameter */; case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: case 103 /* InterfaceKeyword */: case 83 /* FunctionKeyword */: case 98 /* VarKeyword */: case 116 /* GetKeyword */: - case 120 /* SetKeyword */: + case 121 /* SetKeyword */: case 85 /* ImportKeyword */: case 104 /* LetKeyword */: case 70 /* ConstKeyword */: @@ -36956,7 +37881,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 212 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 213 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -36973,7 +37898,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 224 /* PropertyAssignment */ && m.kind !== 225 /* ShorthandPropertyAssignment */) { + if (m.kind !== 225 /* PropertyAssignment */ && m.kind !== 226 /* ShorthandPropertyAssignment */) { // Ignore omitted expressions for missing members in the object literal return; } @@ -37023,10 +37948,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_24 in nameTable) { - if (!allNames[name_24]) { - allNames[name_24] = name_24; - var displayName = getCompletionEntryDisplayName(name_24, target, true); + for (var name_25 in nameTable) { + if (!allNames[name_25]) { + allNames[name_25] = name_25; + var displayName = getCompletionEntryDisplayName(name_25, target, true); if (displayName) { var entry = { name: displayName, @@ -37201,22 +38126,6 @@ var ts; } return ScriptElementKind.unknown; } - function getTypeKind(type) { - var flags = type.getFlags(); - if (flags & 128 /* Enum */) - return ScriptElementKind.enumElement; - if (flags & 1024 /* Class */) - return ScriptElementKind.classElement; - if (flags & 2048 /* Interface */) - return ScriptElementKind.interfaceElement; - if (flags & 512 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - if (flags & 1048703 /* Intrinsic */) - return ScriptElementKind.primitiveType; - if (flags & 256 /* StringLiteral */) - return ScriptElementKind.primitiveType; - return ScriptElementKind.unknown; - } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) @@ -37241,7 +38150,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 155 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 156 /* 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)) { @@ -37250,7 +38159,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 157 /* CallExpression */ || location.kind === 158 /* NewExpression */) { + if (location.kind === 158 /* CallExpression */ || location.kind === 159 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -37263,7 +38172,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 158 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 159 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -37315,24 +38224,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 135 /* Constructor */)) { + (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 136 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 135 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 136 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 135 /* Constructor */) { + if (functionDeclaration.kind === 136 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 138 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -37355,7 +38264,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(123 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(124 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -37375,7 +38284,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(117 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 206 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 118 /* NamespaceKeyword */ : 117 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -37396,13 +38307,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 139 /* ConstructSignature */) { + if (signatureDeclaration.kind === 140 /* ConstructSignature */) { displayParts.push(ts.keywordPart(88 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 138 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 139 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -37411,7 +38322,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 226 /* EnumMember */) { + if (declaration.kind === 227 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -37427,13 +38338,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 208 /* ImportEqualsDeclaration */) { + if (declaration.kind === 209 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(118 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(119 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -37560,8 +38471,8 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 65 /* Identifier */: - case 155 /* PropertyAccessExpression */: - case 126 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position @@ -37597,6 +38508,62 @@ var ts; containerName: containerName }; } + function getDefinitionFromSymbol(symbol, node) { + var typeChecker = program.getTypeChecker(); + var result = []; + var declarations = symbol.getDeclarations(); + var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol + var symbolKind = getSymbolKind(symbol, node); + var containerSymbol = symbol.parent; + var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + // Just add all the declarations. + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + // Applicable only if we are in a new expression, or we are on a constructor declaration + // and in either case the symbol has a construct signature definition, i.e. class + if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { + if (symbol.flags & 32 /* Class */) { + var classDeclaration = symbol.getDeclarations()[0]; + ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */); + return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + } + } + return false; + } + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + } + return false; + } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 136 /* Constructor */) || + (!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; + } + } /// Goto definition function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); @@ -37649,7 +38616,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 === 225 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 226 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -37660,59 +38627,38 @@ var ts; var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); } - var result = []; - var declarations = symbol.getDeclarations(); - var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - var symbolKind = getSymbolKind(symbol, node); - var containerSymbol = symbol.parent; - var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. - ts.forEach(declarations, function (declaration) { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); + return getDefinitionFromSymbol(symbol, node); + } + /// Goto type + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; } - return result; - function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - // Applicable only if we are in a new expression, or we are on a constructor declaration - // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { - if (symbol.flags & 32 /* Class */) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 201 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); - } - } - return false; + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; } - function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); - } - return false; + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 135 /* Constructor */) || - (!selectConstructors && (d.kind === 200 /* FunctionDeclaration */ || d.kind === 134 /* MethodDeclaration */ || d.kind === 133 /* MethodSignature */))) { - declarations.push(d); - if (d.body) - definition = d; + if (type.flags & 16384 /* Union */) { + var result = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); } }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - return false; + return result; } + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(type.symbol, node); } function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); @@ -37799,74 +38745,74 @@ var ts; switch (node.kind) { case 84 /* IfKeyword */: case 76 /* ElseKeyword */: - if (hasKind(node.parent, 183 /* IfStatement */)) { + if (hasKind(node.parent, 184 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 191 /* ReturnStatement */)) { + if (hasKind(node.parent, 192 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 195 /* ThrowStatement */)) { + if (hasKind(node.parent, 196 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 196 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 197 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96 /* TryKeyword */: case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 196 /* TryStatement */)) { + if (hasKind(parent(node), 197 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 193 /* SwitchStatement */)) { + if (hasKind(node.parent, 194 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67 /* CaseKeyword */: case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 193 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 194 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66 /* BreakKeyword */: case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 190 /* BreakStatement */) || hasKind(node.parent, 189 /* ContinueStatement */)) { + if (hasKind(node.parent, 191 /* BreakStatement */) || hasKind(node.parent, 190 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82 /* ForKeyword */: - if (hasKind(node.parent, 186 /* ForStatement */) || - hasKind(node.parent, 187 /* ForInStatement */) || - hasKind(node.parent, 188 /* ForOfStatement */)) { + if (hasKind(node.parent, 187 /* ForStatement */) || + hasKind(node.parent, 188 /* ForInStatement */) || + hasKind(node.parent, 189 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100 /* WhileKeyword */: case 75 /* DoKeyword */: - if (hasKind(node.parent, 185 /* WhileStatement */) || hasKind(node.parent, 184 /* DoStatement */)) { + if (hasKind(node.parent, 186 /* WhileStatement */) || hasKind(node.parent, 185 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 135 /* Constructor */)) { + if (hasKind(node.parent, 136 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 116 /* GetKeyword */: - case 120 /* SetKeyword */: - if (hasKind(node.parent, 136 /* GetAccessor */) || hasKind(node.parent, 137 /* SetAccessor */)) { + case 121 /* SetKeyword */: + if (hasKind(node.parent, 137 /* GetAccessor */) || hasKind(node.parent, 138 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 180 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 181 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -37882,10 +38828,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 195 /* ThrowStatement */) { + if (node.kind === 196 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 196 /* TryStatement */) { + else if (node.kind === 197 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -37914,12 +38860,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent_9 = child.parent; - if (ts.isFunctionBlock(parent_9) || parent_9.kind === 227 /* SourceFile */) { + if (ts.isFunctionBlock(parent_9) || parent_9.kind === 228 /* SourceFile */) { return parent_9; } // 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_9.kind === 196 /* TryStatement */) { + if (parent_9.kind === 197 /* TryStatement */) { var tryStatement = parent_9; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -37934,7 +38880,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 190 /* BreakStatement */ || node.kind === 189 /* ContinueStatement */) { + if (node.kind === 191 /* BreakStatement */ || node.kind === 190 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -37950,16 +38896,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 193 /* SwitchStatement */: - if (statement.kind === 189 /* ContinueStatement */) { + case 194 /* SwitchStatement */: + if (statement.kind === 190 /* ContinueStatement */) { continue; } // Fall through. - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 185 /* WhileStatement */: - case 184 /* DoStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 186 /* WhileStatement */: + case 185 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -37978,18 +38924,18 @@ 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 === 201 /* ClassDeclaration */ || - (declaration.kind === 129 /* Parameter */ && hasKind(container, 135 /* Constructor */)))) { + if (!(container.kind === 202 /* ClassDeclaration */ || + (declaration.kind === 130 /* Parameter */ && hasKind(container, 136 /* Constructor */)))) { return undefined; } } else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 201 /* ClassDeclaration */) { + if (container.kind !== 202 /* ClassDeclaration */) { return undefined; } } else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 206 /* ModuleBlock */ || container.kind === 227 /* SourceFile */)) { + if (!(container.kind === 207 /* ModuleBlock */ || container.kind === 228 /* SourceFile */)) { return undefined; } } @@ -38001,20 +38947,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 206 /* ModuleBlock */: - case 227 /* SourceFile */: + case 207 /* ModuleBlock */: + case 228 /* SourceFile */: nodes = container.statements; break; - case 135 /* Constructor */: + case 136 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: 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 & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 135 /* Constructor */ && member; + return member.kind === 136 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -38062,13 +39008,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 136 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 120 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 121 /* SetKeyword */); }); } } } @@ -38086,7 +39032,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 184 /* DoStatement */) { + if (loopNode.kind === 185 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { @@ -38107,13 +39053,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -38167,7 +39113,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, 179 /* Block */))) { + if (!(func && hasKind(func.body, 180 /* Block */))) { return undefined; } var keywords = []; @@ -38183,7 +39129,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 183 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 184 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -38196,7 +39142,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 183 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 184 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -38375,17 +39321,17 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 213 /* ImportSpecifier */ || location.parent.kind === 217 /* ExportSpecifier */) && + (location.parent.kind === 214 /* ImportSpecifier */ || location.parent.kind === 218 /* ExportSpecifier */) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 213 /* ImportSpecifier */ || declaration.kind === 217 /* ExportSpecifier */; + return declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 218 /* ExportSpecifier */; }); } function getDeclaredName(symbol, location) { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 162 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -38412,7 +39358,7 @@ var ts; return location.getText(); } // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 162 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -38436,7 +39382,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 201 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 202 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -38462,7 +39408,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 227 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 228 /* 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; @@ -38650,13 +39596,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -38688,27 +39634,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 163 /* 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. @@ -38717,7 +39663,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 227 /* SourceFile */) { + if (searchSpaceNode.kind === 228 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -38748,27 +39694,27 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 201 /* ClassDeclaration */: + case 202 /* 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 & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 227 /* SourceFile */: - if (container.kind === 227 /* SourceFile */ && !ts.isExternalModule(container)) { + case 228 /* SourceFile */: + if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -38822,11 +39768,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 201 /* ClassDeclaration */) { + if (declaration.kind === 202 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 202 /* InterfaceDeclaration */) { + else if (declaration.kind === 203 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -38887,19 +39833,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_25 = node.text; + var name_26 = 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_25); + var unionProperty = contextualType.getProperty(name_26); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_25); + var symbol = t.getProperty(name_26); if (symbol) { result_4.push(symbol); } @@ -38908,7 +39854,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_25); + var symbol_1 = contextualType.getProperty(name_26); if (symbol_1) { return [symbol_1]; } @@ -38966,10 +39912,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 168 /* PostfixUnaryExpression */ || parent.kind === 167 /* PrefixUnaryExpression */) { + if (parent.kind === 169 /* PostfixUnaryExpression */ || parent.kind === 168 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 169 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 170 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; } @@ -39003,33 +39949,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 223 /* CatchClause */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: + case 227 /* EnumMember */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 224 /* CatchClause */: return 1 /* Value */; - case 128 /* TypeParameter */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 145 /* TypeLiteral */: + case 129 /* TypeParameter */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 146 /* TypeLiteral */: return 2 /* Type */; - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -39039,15 +39985,15 @@ var ts; else { return 4 /* Namespace */; } - case 212 /* NamedImports */: - case 213 /* ImportSpecifier */: - case 208 /* ImportEqualsDeclaration */: - case 209 /* ImportDeclaration */: - case 214 /* ExportAssignment */: - case 215 /* ExportDeclaration */: + case 213 /* NamedImports */: + case 214 /* ImportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 210 /* ImportDeclaration */: + case 215 /* ExportAssignment */: + case 216 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 227 /* SourceFile */: + case 228 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -39057,7 +40003,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 141 /* TypeReference */ || node.parent.kind === 177 /* HeritageClauseElement */; + return node.parent.kind === 142 /* TypeReference */ || node.parent.kind === 177 /* ExpressionWithTypeArguments */; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -39065,32 +40011,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 155 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 155 /* PropertyAccessExpression */) { + if (root.parent.kind === 156 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 156 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 /* HeritageClauseElement */ && root.parent.parent.kind === 222 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 177 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 223 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 201 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 202 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 202 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || + (decl.kind === 203 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 126 /* QualifiedName */) { - while (root.parent && root.parent.kind === 126 /* QualifiedName */) { + if (root.parent.kind === 127 /* QualifiedName */) { + while (root.parent && root.parent.kind === 127 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 141 /* TypeReference */ && !isLastClause; + return root.parent.kind === 142 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 126 /* QualifiedName */) { + while (node.parent.kind === 127 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -39100,15 +40046,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 126 /* QualifiedName */ && + if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 208 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 209 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 214 /* ExportAssignment */) { + if (node.parent.kind === 215 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -39148,8 +40094,8 @@ var ts; return; } switch (node.kind) { - case 155 /* PropertyAccessExpression */: - case 126 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: case 8 /* StringLiteral */: case 80 /* FalseKeyword */: case 95 /* TrueKeyword */: @@ -39172,7 +40118,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 === 205 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 206 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -39199,29 +40145,37 @@ var ts; return ts.NavigationBar.getNavigationBarItems(sourceFile); } function getSemanticClassifications(fileName, span) { + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + function getEncodedSemanticClassifications(fileName, span) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; processNode(sourceFile); - return result; + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) { - return ClassificationTypeNames.className; + return 11 /* className */; } else if (flags & 384 /* Enum */) { - return ClassificationTypeNames.enumName; + return 12 /* enumName */; } else if (flags & 524288 /* TypeAlias */) { - return ClassificationTypeNames.typeAlias; + return 16 /* typeAliasName */; } else if (meaningAtPosition & 2 /* Type */) { if (flags & 64 /* Interface */) { - return ClassificationTypeNames.interfaceName; + return 13 /* interfaceName */; } else if (flags & 262144 /* TypeParameter */) { - return ClassificationTypeNames.typeParameterName; + return 15 /* typeParameterName */; } } else if (flags & 1536 /* Module */) { @@ -39230,7 +40184,7 @@ var ts; // - There exists a module declaration which actually impacts the value side. if (meaningAtPosition & 4 /* Namespace */ || (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { - return ClassificationTypeNames.moduleName; + return 14 /* moduleName */; } } return undefined; @@ -39239,7 +40193,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 205 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; }); } } @@ -39251,10 +40205,7 @@ var ts; if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { - result.push({ - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - classificationType: type - }); + pushClassification(node.getStart(), node.getWidth(), type); } } } @@ -39262,7 +40213,42 @@ var ts; } } } + function getClassificationTypeName(type) { + switch (type) { + case 1 /* comment */: return ClassificationTypeNames.comment; + case 2 /* identifier */: return ClassificationTypeNames.identifier; + case 3 /* keyword */: return ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ClassificationTypeNames.text; + case 10 /* punctuation */: return ClassificationTypeNames.punctuation; + case 11 /* className */: return ClassificationTypeNames.className; + case 12 /* enumName */: return ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ClassificationTypeNames.parameterName; + } + } + function convertClassifications(classifications) { + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } function getSyntacticClassifications(fileName, span) { + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + function getEncodedSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Make a scanner we can get trivia from. @@ -39270,7 +40256,12 @@ var ts; var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); var result = []; processElement(sourceFile); - return result; + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } function classifyLeadingTrivia(token) { var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); if (tokenStart === token.pos) { @@ -39289,10 +40280,7 @@ var ts; } if (ts.isComment(kind)) { // Simple comment. Just add as is. - result.push({ - textSpan: ts.createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, 1 /* comment */); continue; } if (kind === 6 /* ConflictMarkerTrivia */) { @@ -39301,10 +40289,7 @@ var ts; // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - result.push({ - textSpan: ts.createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, 1 /* comment */); continue; } // for the ======== add a comment for the first line, and then lex all @@ -39323,10 +40308,7 @@ var ts; break; } } - result.push({ - textSpan: ts.createTextSpanFromBounds(start, i), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, i - start, 1 /* comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -39338,10 +40320,7 @@ var ts; var end = mergeConflictScanner.getTextPos(); var type = classifyTokenType(tokenKind); if (type) { - result.push({ - textSpan: ts.createTextSpanFromBounds(start, end), - classificationType: type - }); + pushClassification(start, end - start, type); } } function classifyToken(token) { @@ -39349,10 +40328,7 @@ var ts; if (token.getWidth() > 0) { var type = classifyTokenType(token.kind, token); if (type) { - result.push({ - textSpan: ts.createTextSpan(token.getStart(), token.getWidth()), - classificationType: type - }); + pushClassification(token.getStart(), token.getWidth(), type); } } } @@ -39361,7 +40337,7 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return ClassificationTypeNames.keyword; + return 3 /* keyword */; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. @@ -39369,73 +40345,78 @@ var ts; // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return ClassificationTypeNames.punctuation; + return 10 /* punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 53 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 198 /* VariableDeclaration */ || - token.parent.kind === 132 /* PropertyDeclaration */ || - token.parent.kind === 129 /* Parameter */) { - return ClassificationTypeNames.operator; + if (token.parent.kind === 199 /* VariableDeclaration */ || + token.parent.kind === 133 /* PropertyDeclaration */ || + token.parent.kind === 130 /* Parameter */) { + return 5 /* operator */; } } - if (token.parent.kind === 169 /* BinaryExpression */ || - token.parent.kind === 167 /* PrefixUnaryExpression */ || - token.parent.kind === 168 /* PostfixUnaryExpression */ || - token.parent.kind === 170 /* ConditionalExpression */) { - return ClassificationTypeNames.operator; + if (token.parent.kind === 170 /* BinaryExpression */ || + token.parent.kind === 168 /* PrefixUnaryExpression */ || + token.parent.kind === 169 /* PostfixUnaryExpression */ || + token.parent.kind === 171 /* ConditionalExpression */) { + return 5 /* operator */; } } - return ClassificationTypeNames.punctuation; + return 10 /* punctuation */; } else if (tokenKind === 7 /* NumericLiteral */) { - return ClassificationTypeNames.numericLiteral; + return 4 /* numericLiteral */; } else if (tokenKind === 8 /* StringLiteral */) { - return ClassificationTypeNames.stringLiteral; + return 6 /* stringLiteral */; } else if (tokenKind === 9 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return ClassificationTypeNames.stringLiteral; + return 6 /* stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return ClassificationTypeNames.stringLiteral; + return 6 /* stringLiteral */; } else if (tokenKind === 65 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.className; + return 11 /* className */; } return; - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: if (token.parent.name === token) { - return ClassificationTypeNames.typeParameterName; + return 15 /* typeParameterName */; } return; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.interfaceName; + return 13 /* interfaceName */; } return; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.enumName; + return 12 /* enumName */; } return; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.moduleName; + return 14 /* moduleName */; + } + return; + case 130 /* Parameter */: + if (token.parent.name === token) { + return 17 /* parameterName */; } return; } } - return ClassificationTypeNames.text; + return 9 /* text */; } } function processElement(element) { @@ -39715,11 +40696,14 @@ var ts; getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getSyntacticClassifications: getSyntacticClassifications, getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, getCompletionsAtPosition: getCompletionsAtPosition, getCompletionEntryDetails: getCompletionEntryDetails, getSignatureHelpItems: getSignatureHelpItems, getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, findReferences: findReferences, getOccurrencesAtPosition: getOccurrencesAtPosition, @@ -39767,7 +40751,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 === 219 /* ExternalModuleReference */ || + node.parent.kind === 220 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -39780,7 +40764,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 156 /* ElementAccessExpression */ && + node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -39828,7 +40812,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 120 /* SetKeyword */ || + keyword2 === 121 /* SetKeyword */ || keyword2 === 114 /* ConstructorKeyword */ || keyword2 === 109 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -39843,9 +40827,58 @@ var ts; // if there are more cases we want the classifier to be better at. return true; } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_1 = dense[i + 1]; + var type = dense[i + 2]; + // Make a whitespace entry between the last item and this one. + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + } + } + entries.push({ length: length_1, classification: convertClassification(type) }); + lastEnd = start + length_1; + } + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + return { entries: entries, finalLexState: classifications.endOfLineState }; + } + function convertClassification(type) { + switch (type) { + case 1 /* comment */: return TokenClass.Comment; + case 3 /* keyword */: return TokenClass.Keyword; + case 4 /* numericLiteral */: return TokenClass.NumberLiteral; + case 5 /* operator */: return TokenClass.Operator; + case 6 /* stringLiteral */: return TokenClass.StringLiteral; + case 8 /* whiteSpace */: return TokenClass.Whitespace; + case 10 /* punctuation */: return TokenClass.Punctuation; + case 2 /* identifier */: + case 11 /* className */: + case 12 /* enumName */: + case 13 /* interfaceName */: + case 14 /* moduleName */: + case 15 /* typeParameterName */: + case 16 /* typeAliasName */: + case 9 /* text */: + case 17 /* parameterName */: + default: + return TokenClass.Identifier; + } + } + function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. - function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { var offset = 0; var token = 0 /* Unknown */; var lastNonTriviaToken = 0 /* Unknown */; @@ -39885,8 +40918,8 @@ var ts; } scanner.setText(text); var result = { - finalLexState: 0 /* Start */, - entries: [] + endOfLineState: 0 /* None */, + spans: [] }; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -39938,10 +40971,10 @@ var ts; angleBracketStack--; } else if (token === 112 /* AnyKeyword */ || - token === 121 /* StringKeyword */ || - token === 119 /* NumberKeyword */ || + token === 122 /* StringKeyword */ || + token === 120 /* NumberKeyword */ || token === 113 /* BooleanKeyword */ || - token === 122 /* SymbolKeyword */) { + token === 123 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -39988,7 +41021,7 @@ var ts; function processToken() { var start = scanner.getTokenPos(); var end = scanner.getTextPos(); - addResult(end - start, classFromKind(token)); + addResult(start, end, classFromKind(token)); if (end >= text.length) { if (token === 8 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. @@ -40002,7 +41035,7 @@ var ts; // If we have an odd number of backslashes, then the multiline string is unclosed if (numBackslashes & 1) { var quoteChar = tokenText.charCodeAt(0); - result.finalLexState = quoteChar === 34 /* doubleQuote */ + result.endOfLineState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; } @@ -40011,16 +41044,16 @@ var ts; else if (token === 3 /* MultiLineCommentTrivia */) { // Check to see if the multiline comment was unclosed. if (scanner.isUnterminated()) { - result.finalLexState = 1 /* InMultiLineCommentTrivia */; + result.endOfLineState = 1 /* InMultiLineCommentTrivia */; } } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { if (token === 13 /* TemplateTail */) { - result.finalLexState = 5 /* InTemplateMiddleOrTail */; + result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } else if (token === 10 /* NoSubstitutionTemplateLiteral */) { - result.finalLexState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); @@ -40028,18 +41061,30 @@ var ts; } } else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { - result.finalLexState = 6 /* InTemplateSubstitutionPosition */; + result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } } - function addResult(length, classification) { + function addResult(start, end, classification) { + if (classification === 8 /* whiteSpace */) { + // Don't bother with whitespace classifications. They're not needed. + return; + } + if (start === 0 && offset > 0) { + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of + // the original text. + start += offset; + } + // All our tokens are in relation to the augmented text. Move them back to be + // relative to the original text. + start -= offset; + end -= offset; + var length = end - start; if (length > 0) { - // If this is the first classification we're adding to the list, then remove any - // offset we have if we were continuing a construct from the previous line. - if (result.entries.length === 0) { - length -= offset; - } - result.entries.push({ length: length, classification: classification }); + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); } } } @@ -40100,41 +41145,44 @@ var ts; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 125 /* LastKeyword */; + return token >= 66 /* FirstKeyword */ && token <= 126 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { - return TokenClass.Keyword; + return 3 /* keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return TokenClass.Operator; + return 5 /* operator */; } else if (token >= 14 /* FirstPunctuation */ && token <= 64 /* LastPunctuation */) { - return TokenClass.Punctuation; + return 10 /* punctuation */; } switch (token) { case 7 /* NumericLiteral */: - return TokenClass.NumberLiteral; + return 4 /* numericLiteral */; case 8 /* StringLiteral */: - return TokenClass.StringLiteral; + return 6 /* stringLiteral */; case 9 /* RegularExpressionLiteral */: - return TokenClass.RegExpLiteral; + return 7 /* regularExpressionLiteral */; case 6 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: - return TokenClass.Comment; + return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: - return TokenClass.Whitespace; + return 8 /* whiteSpace */; case 65 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return TokenClass.StringLiteral; + return 6 /* stringLiteral */; } - return TokenClass.Identifier; + return 2 /* identifier */; } } - return { getClassificationsForLine: getClassificationsForLine }; + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; } ts.createClassifier = createClassifier; /** @@ -40155,7 +41203,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 227 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 228 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -40225,125 +41273,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 184 /* DoStatement */) { + if (node.parent.kind === 185 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 186 /* ForStatement */) { + if (node.parent.kind === 187 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 169 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 170 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind == 163 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind == 164 /* 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 180 /* VariableStatement */: + case 181 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 198 /* VariableDeclaration */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 199 /* VariableDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return spanInVariableDeclaration(node); - case 129 /* Parameter */: + case 130 /* Parameter */: return spanInParameterDeclaration(node); - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 179 /* Block */: + case 180 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 206 /* ModuleBlock */: + case 207 /* ModuleBlock */: return spanInBlock(node); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return spanInBlock(node.block); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 184 /* DoStatement */: + case 185 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 197 /* DebuggerStatement */: + case 198 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 183 /* IfStatement */: + case 184 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return spanInForStatement(node); - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 196 /* TryStatement */: + case 197 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: // span on complete node return textSpan(node); - case 192 /* WithStatement */: + case 193 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -40373,11 +41421,11 @@ var ts; return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 224 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 225 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 160 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 161 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -40390,12 +41438,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 187 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 188 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 188 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 180 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 186 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -40449,7 +41497,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 201 /* ClassDeclaration */ && functionDeclaration.kind !== 135 /* Constructor */); + (functionDeclaration.parent.kind === 202 /* ClassDeclaration */ && functionDeclaration.kind !== 136 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -40472,18 +41520,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 185 /* WhileStatement */: - case 183 /* IfStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 186 /* WhileStatement */: + case 184 /* IfStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: 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 186 /* ForStatement */: + case 187 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -40491,7 +41539,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 199 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 200 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -40511,13 +41559,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 207 /* CaseBlock */: + case 208 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -40525,30 +41573,30 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 206 /* ModuleBlock */: + case 207 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 204 /* EnumDeclaration */: - case 201 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 179 /* Block */: + case 180 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 223 /* CatchClause */: - return spanInNode(node.parent.statements[node.parent.statements.length - 1]); + case 224 /* CatchClause */: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 207 /* CaseBlock */: + case 208 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; - var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { - return spanInNode(lastClause.statements[lastClause.statements.length - 1]); + return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; // Default to parent node @@ -40557,7 +41605,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 184 /* DoStatement */) { + if (node.parent.kind === 185 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -40567,17 +41615,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: - case 185 /* WhileStatement */: - case 184 /* DoStatement */: - case 186 /* ForStatement */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: + case 186 /* WhileStatement */: + case 185 /* DoStatement */: + case 187 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -40588,19 +41636,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 224 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 225 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 160 /* TypeAssertionExpression */) { + if (node.parent.kind === 161 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 184 /* DoStatement */) { + if (node.parent.kind === 185 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -40614,7 +41662,7 @@ var ts; })(ts || (ts = {})); // // Copyright (c) Microsoft Corporation. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -40633,7 +41681,9 @@ var debugObjectHost = this; var ts; (function (ts) { function logInternalError(logger, err) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } } var ScriptSnapshotShimAdapter = (function () { function ScriptSnapshotShimAdapter(scriptSnapshotShim) { @@ -40726,24 +41776,39 @@ var ts; return LanguageServiceShimHostAdapter; })(); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action) { - logger.log(actionDescription); - var start = Date.now(); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + this.shimHost = shimHost; + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { + var encoded = this.shimHost.readDirectory(rootDir, extension); + return JSON.parse(encoded); + }; + return CoreServicesShimHostAdapter; + })(); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, noPerfLogging) { + if (!noPerfLogging) { + logger.log(actionDescription); + var start = Date.now(); + } var result = action(); - var end = Date.now(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof (result) === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; + if (!noPerfLogging) { + var end = Date.now(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof (result) === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); } return result; } - function forwardJSONCall(logger, actionDescription, action) { + function forwardJSONCall(logger, actionDescription, action, noPerfLogging) { try { - var result = simpleForwardCall(logger, actionDescription, action); + var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); return JSON.stringify({ result: result }); } catch (err) { @@ -40788,7 +41853,7 @@ var ts; this.logger = this.host; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action); + return forwardJSONCall(this.logger, actionDescription, action, false); }; /// DISPOSE /** @@ -40841,6 +41906,22 @@ var ts; return classifications; }); }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); + }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); + }); + }; LanguageServiceShimObject.prototype.getNewLine = function () { return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; }; @@ -40919,6 +42000,17 @@ var ts; return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; + /// GOTO Type + /** + * Computes the definition location of the type of the symbol + * at the requested position. + */ + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getTypeDefinitionAtPosition(fileName, position); + }); + }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { var _this = this; return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { @@ -41060,12 +42152,21 @@ var ts; }; return LanguageServiceShimObject; })(ShimBase); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } var ClassifierShimObject = (function (_super) { __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory) { + function ClassifierShimObject(factory, logger) { _super.call(this, factory); + this.logger = logger; this.classifier = ts.createClassifier(); } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, + /*noPerfLogging:*/ true); + }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); @@ -41082,12 +42183,13 @@ var ts; })(ShimBase); var CoreServicesShimObject = (function (_super) { __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger) { + function CoreServicesShimObject(factory, logger, host) { _super.call(this, factory); this.logger = logger; + this.host = host; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action); + return forwardJSONCall(this.logger, actionDescription, action, false); }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { @@ -41114,6 +42216,26 @@ var ts; return convertResult; }); }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileText(fileName, text); + if (result.error) { + return { + options: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + var configFile = ts.parseConfigFile(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + return { + options: configFile.options, + files: configFile.fileNames, + errors: [realizeDiagnostics(configFile.errors, '\r\n')] + }; + }); + }; CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); @@ -41145,19 +42267,20 @@ var ts; }; TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { try { - return new ClassifierShimObject(this); + return new ClassifierShimObject(this, logger); } catch (err) { logInternalError(logger, err); throw err; } }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (logger) { + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { try { - return new CoreServicesShimObject(this, logger); + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); } catch (err) { - logInternalError(logger, err); + logInternalError(host, err); throw err; } }; diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index d946fdcfe30..3114c56b789 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -140,132 +140,133 @@ declare module ts { DeclareKeyword = 115, GetKeyword = 116, ModuleKeyword = 117, - RequireKeyword = 118, - NumberKeyword = 119, - SetKeyword = 120, - StringKeyword = 121, - SymbolKeyword = 122, - TypeKeyword = 123, - FromKeyword = 124, - OfKeyword = 125, - QualifiedName = 126, - ComputedPropertyName = 127, - TypeParameter = 128, - Parameter = 129, - Decorator = 130, - PropertySignature = 131, - PropertyDeclaration = 132, - MethodSignature = 133, - MethodDeclaration = 134, - Constructor = 135, - GetAccessor = 136, - SetAccessor = 137, - CallSignature = 138, - ConstructSignature = 139, - IndexSignature = 140, - TypeReference = 141, - FunctionType = 142, - ConstructorType = 143, - TypeQuery = 144, - TypeLiteral = 145, - ArrayType = 146, - TupleType = 147, - UnionType = 148, - ParenthesizedType = 149, - ObjectBindingPattern = 150, - ArrayBindingPattern = 151, - BindingElement = 152, - ArrayLiteralExpression = 153, - ObjectLiteralExpression = 154, - PropertyAccessExpression = 155, - ElementAccessExpression = 156, - CallExpression = 157, - NewExpression = 158, - TaggedTemplateExpression = 159, - TypeAssertionExpression = 160, - ParenthesizedExpression = 161, - FunctionExpression = 162, - ArrowFunction = 163, - DeleteExpression = 164, - TypeOfExpression = 165, - VoidExpression = 166, - PrefixUnaryExpression = 167, - PostfixUnaryExpression = 168, - BinaryExpression = 169, - ConditionalExpression = 170, - TemplateExpression = 171, - YieldExpression = 172, - SpreadElementExpression = 173, - ClassExpression = 174, - OmittedExpression = 175, - TemplateSpan = 176, - HeritageClauseElement = 177, - SemicolonClassElement = 178, - Block = 179, - VariableStatement = 180, - EmptyStatement = 181, - ExpressionStatement = 182, - IfStatement = 183, - DoStatement = 184, - WhileStatement = 185, - ForStatement = 186, - ForInStatement = 187, - ForOfStatement = 188, - ContinueStatement = 189, - BreakStatement = 190, - ReturnStatement = 191, - WithStatement = 192, - SwitchStatement = 193, - LabeledStatement = 194, - ThrowStatement = 195, - TryStatement = 196, - DebuggerStatement = 197, - VariableDeclaration = 198, - VariableDeclarationList = 199, - FunctionDeclaration = 200, - ClassDeclaration = 201, - InterfaceDeclaration = 202, - TypeAliasDeclaration = 203, - EnumDeclaration = 204, - ModuleDeclaration = 205, - ModuleBlock = 206, - CaseBlock = 207, - ImportEqualsDeclaration = 208, - ImportDeclaration = 209, - ImportClause = 210, - NamespaceImport = 211, - NamedImports = 212, - ImportSpecifier = 213, - ExportAssignment = 214, - ExportDeclaration = 215, - NamedExports = 216, - ExportSpecifier = 217, - MissingDeclaration = 218, - ExternalModuleReference = 219, - CaseClause = 220, - DefaultClause = 221, - HeritageClause = 222, - CatchClause = 223, - PropertyAssignment = 224, - ShorthandPropertyAssignment = 225, - EnumMember = 226, - SourceFile = 227, - SyntaxList = 228, - Count = 229, + NamespaceKeyword = 118, + RequireKeyword = 119, + NumberKeyword = 120, + SetKeyword = 121, + StringKeyword = 122, + SymbolKeyword = 123, + TypeKeyword = 124, + FromKeyword = 125, + OfKeyword = 126, + QualifiedName = 127, + ComputedPropertyName = 128, + TypeParameter = 129, + Parameter = 130, + Decorator = 131, + PropertySignature = 132, + PropertyDeclaration = 133, + MethodSignature = 134, + MethodDeclaration = 135, + Constructor = 136, + GetAccessor = 137, + SetAccessor = 138, + CallSignature = 139, + ConstructSignature = 140, + IndexSignature = 141, + TypeReference = 142, + FunctionType = 143, + ConstructorType = 144, + TypeQuery = 145, + TypeLiteral = 146, + ArrayType = 147, + TupleType = 148, + UnionType = 149, + ParenthesizedType = 150, + ObjectBindingPattern = 151, + ArrayBindingPattern = 152, + BindingElement = 153, + ArrayLiteralExpression = 154, + ObjectLiteralExpression = 155, + PropertyAccessExpression = 156, + ElementAccessExpression = 157, + CallExpression = 158, + NewExpression = 159, + TaggedTemplateExpression = 160, + TypeAssertionExpression = 161, + ParenthesizedExpression = 162, + FunctionExpression = 163, + ArrowFunction = 164, + DeleteExpression = 165, + TypeOfExpression = 166, + VoidExpression = 167, + PrefixUnaryExpression = 168, + PostfixUnaryExpression = 169, + BinaryExpression = 170, + ConditionalExpression = 171, + TemplateExpression = 172, + YieldExpression = 173, + SpreadElementExpression = 174, + ClassExpression = 175, + OmittedExpression = 176, + ExpressionWithTypeArguments = 177, + TemplateSpan = 178, + SemicolonClassElement = 179, + Block = 180, + VariableStatement = 181, + EmptyStatement = 182, + ExpressionStatement = 183, + IfStatement = 184, + DoStatement = 185, + WhileStatement = 186, + ForStatement = 187, + ForInStatement = 188, + ForOfStatement = 189, + ContinueStatement = 190, + BreakStatement = 191, + ReturnStatement = 192, + WithStatement = 193, + SwitchStatement = 194, + LabeledStatement = 195, + ThrowStatement = 196, + TryStatement = 197, + DebuggerStatement = 198, + VariableDeclaration = 199, + VariableDeclarationList = 200, + FunctionDeclaration = 201, + ClassDeclaration = 202, + InterfaceDeclaration = 203, + TypeAliasDeclaration = 204, + EnumDeclaration = 205, + ModuleDeclaration = 206, + ModuleBlock = 207, + CaseBlock = 208, + ImportEqualsDeclaration = 209, + ImportDeclaration = 210, + ImportClause = 211, + NamespaceImport = 212, + NamedImports = 213, + ImportSpecifier = 214, + ExportAssignment = 215, + ExportDeclaration = 216, + NamedExports = 217, + ExportSpecifier = 218, + MissingDeclaration = 219, + ExternalModuleReference = 220, + CaseClause = 221, + DefaultClause = 222, + HeritageClause = 223, + CatchClause = 224, + PropertyAssignment = 225, + ShorthandPropertyAssignment = 226, + EnumMember = 227, + SourceFile = 228, + SyntaxList = 229, + Count = 230, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, LastReservedWord = 101, FirstKeyword = 66, - LastKeyword = 125, + LastKeyword = 126, FirstFutureReservedWord = 102, LastFutureReservedWord = 110, - FirstTypeNode = 141, - LastTypeNode = 149, + FirstTypeNode = 142, + LastTypeNode = 150, FirstPunctuation = 14, LastPunctuation = 64, FirstToken = 0, - LastToken = 125, + LastToken = 126, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -274,7 +275,7 @@ declare module ts { LastTemplateToken = 13, FirstBinaryOperator = 24, LastBinaryOperator = 64, - FirstNode = 126, + FirstNode = 127, } const enum NodeFlags { Export = 1, @@ -290,7 +291,8 @@ declare module ts { Let = 4096, Const = 8192, OctalLiteral = 16384, - ExportContext = 32768, + Namespace = 32768, + ExportContext = 65536, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -553,7 +555,7 @@ declare module ts { typeArguments?: NodeArray; arguments: NodeArray; } - interface HeritageClauseElement extends TypeNode { + interface ExpressionWithTypeArguments extends TypeNode { expression: LeftHandSideExpression; typeArguments?: NodeArray; } @@ -672,7 +674,7 @@ declare module ts { } interface HeritageClause extends Node { token: SyntaxKind; - types?: NodeArray; + types?: NodeArray; } interface TypeAliasDeclaration extends Declaration, ModuleElement { name: Identifier; @@ -756,6 +758,9 @@ declare module ts { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } + interface ParseConfigHost { + readDirectory(rootDir: string, extension: string): string[]; + } interface WriteFileCallback { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } @@ -804,6 +809,7 @@ declare module ts { sourceMapFile: string; sourceMapSourceRoot: string; sourceMapSources: string[]; + sourceMapSourcesContent?: string[]; inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; @@ -1082,11 +1088,15 @@ declare module ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; listFiles?: boolean; locale?: string; mapRoot?: string; module?: ModuleKind; + newLine?: NewLineKind; noEmit?: boolean; + noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; noImplicitAny?: boolean; @@ -1113,6 +1123,11 @@ declare module ts { CommonJS = 1, AMD = 2, UMD = 3, + System = 4, + } + const enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, } interface LineAndCharacter { line: number; @@ -1176,6 +1191,32 @@ declare module ts { var sys: System; } declare module ts { + interface ErrorCallback { + (message: DiagnosticMessage, length: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasExtendedUnicodeEscape(): boolean; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string, start?: number, length?: number): void; + setOnError(onError: ErrorCallback): void; + setScriptTarget(scriptTarget: ScriptTarget): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } function tokenToString(t: SyntaxKind): string; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; @@ -1185,6 +1226,8 @@ declare module ts { function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + /** Creates a scanner over a (possibly unspecified) range of a piece of text. */ + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare module ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1226,7 +1269,7 @@ declare module ts { const version: string; function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; } @@ -1236,14 +1279,26 @@ declare module ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string): any; + function readConfigFile(fileName: string): { + config?: any; + error?: Diagnostic; + }; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileText(fileName: string, jsonText: string): { + config?: any; + error?: Diagnostic; + }; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseConfigFile(json: any, basePath?: string): ParsedCommandLine; + function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; } declare module ts { /** The version of the language service API */ @@ -1340,8 +1395,16 @@ declare module ts { getSyntacticDiagnostics(fileName: string): Diagnostic[]; getSemanticDiagnostics(fileName: string): Diagnostic[]; getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; @@ -1351,6 +1414,7 @@ declare module ts { getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; findReferences(fileName: string, position: number): ReferencedSymbol[]; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; @@ -1370,6 +1434,10 @@ declare module ts { getSourceFile(fileName: string): SourceFile; dispose(): void; } + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; + } interface ClassifiedSpan { textSpan: TextSpan; classificationType: string; @@ -1581,7 +1649,7 @@ declare module ts { text: string; } const enum EndOfLineState { - Start = 0, + None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, InDoubleQuoteStringLiteral = 3, @@ -1627,8 +1695,10 @@ declare module ts { * classifications which may be incorrectly categorized will be given * back as Identifiers in order to allow the syntactic classifier to * subsume the classification. + * @deprecated Use getLexicalClassifications instead. */ getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } /** * The document registry represents a store of SourceFile objects that can be shared between @@ -1739,7 +1809,27 @@ declare module ts { static interfaceName: string; static moduleName: string; static typeParameterName: string; - static typeAlias: string; + static typeAliasName: string; + static parameterName: string; + } + const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, } interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index fefe3658fb4..ba375bc4096 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -145,149 +145,150 @@ var ts; SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 118] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 119] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 120] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 121] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 122] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 123] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 124] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 125] = "OfKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 118] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 119] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 120] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 121] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 122] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 123] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 124] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 125] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 126] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 126] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 127] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 127] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 128] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 128] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 129] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 130] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 129] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 130] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 131] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 131] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 132] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 133] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 134] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 135] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 136] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 137] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 138] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 139] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 140] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 132] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 133] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 134] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 135] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 136] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 137] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 138] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 139] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 140] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 141] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypeReference"] = 141] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 142] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 143] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 144] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 145] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 146] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 147] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 148] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 149] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypeReference"] = 142] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 143] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 144] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 145] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 146] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 147] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 148] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 149] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 150] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 150] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 151] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 152] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 151] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 152] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 153] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 153] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 154] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 155] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 156] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 157] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 158] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 159] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 160] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 161] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 162] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 163] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 164] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 165] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 166] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 167] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 168] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 169] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 170] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 171] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 172] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 173] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 174] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 175] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 154] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 155] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 156] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 157] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 158] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 159] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 160] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 161] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 162] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 163] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 164] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 165] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 166] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 167] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 168] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 169] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 170] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 171] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 172] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 173] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 174] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 175] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 176] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 177] = "ExpressionWithTypeArguments"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 176] = "TemplateSpan"; - SyntaxKind[SyntaxKind["HeritageClauseElement"] = 177] = "HeritageClauseElement"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 178] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 178] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 179] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 179] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 180] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 181] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 182] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 183] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 184] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 185] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 186] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 187] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 188] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 189] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 190] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 191] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 192] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 193] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 194] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 195] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 196] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 197] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 198] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 199] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 200] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 201] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 202] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 203] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 204] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 205] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 206] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 207] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 208] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 209] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 210] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 211] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 212] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 213] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 214] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 215] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 216] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 217] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 218] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 180] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 181] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 182] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 183] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 184] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 185] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 186] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 187] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 188] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 189] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 190] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 191] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 192] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 193] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 194] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 195] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 196] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 197] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 198] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 199] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 200] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 201] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 202] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 203] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 204] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 205] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 206] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 207] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 208] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 209] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 210] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 211] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 212] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 213] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 214] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 215] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 216] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 217] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 218] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 219] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 219] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 220] = "ExternalModuleReference"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 220] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 221] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 222] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 223] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 221] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 222] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 223] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 224] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 224] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 225] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 225] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 226] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 226] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 227] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 227] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 228] = "SourceFile"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 228] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 229] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 229] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 230] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 125] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 126] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 141] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 149] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 142] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 150] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 125] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 126] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -296,7 +297,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 126] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 127] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -313,7 +314,8 @@ var ts; NodeFlags[NodeFlags["Let"] = 4096] = "Let"; NodeFlags[NodeFlags["Const"] = 8192] = "Const"; NodeFlags[NodeFlags["OctalLiteral"] = 16384] = "OctalLiteral"; - NodeFlags[NodeFlags["ExportContext"] = 32768] = "ExportContext"; + NodeFlags[NodeFlags["Namespace"] = 32768] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 65536] = "ExportContext"; NodeFlags[NodeFlags["Modifier"] = 499] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 12288] = "BlockScoped"; @@ -542,8 +544,14 @@ var ts; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; + ModuleKind[ModuleKind["System"] = 4] = "System"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; @@ -1134,7 +1142,7 @@ var ts; for (var _i = 0; _i < parts.length; _i++) { var part = parts[_i]; if (part !== ".") { - if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); } else { @@ -1241,7 +1249,7 @@ var ts; function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name // that is ["test", "cases", ""] needs to be actually ["test", "cases"] directoryComponents.length--; @@ -1695,7 +1703,7 @@ var ts; A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, @@ -1756,8 +1764,8 @@ var ts; or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, @@ -1799,9 +1807,9 @@ var ts; The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, @@ -1810,28 +1818,27 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, + Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." }, + Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find external module '{0}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, @@ -1854,7 +1861,7 @@ var ts; Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, @@ -1946,15 +1953,15 @@ var ts; Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, @@ -2008,11 +2015,13 @@ var ts; Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "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}'." }, 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}'." }, @@ -2088,6 +2097,7 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, @@ -2101,6 +2111,10 @@ var ts; Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, + Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2112,7 +2126,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -2133,7 +2147,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -2147,6 +2161,9 @@ var ts; Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2159,7 +2176,6 @@ var ts; 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." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, @@ -2215,7 +2231,7 @@ var ts; "false": 80 /* FalseKeyword */, "finally": 81 /* FinallyKeyword */, "for": 82 /* ForKeyword */, - "from": 124 /* FromKeyword */, + "from": 125 /* FromKeyword */, "function": 83 /* FunctionKeyword */, "get": 116 /* GetKeyword */, "if": 84 /* IfKeyword */, @@ -2226,33 +2242,34 @@ var ts; "interface": 103 /* InterfaceKeyword */, "let": 104 /* LetKeyword */, "module": 117 /* ModuleKeyword */, + "namespace": 118 /* NamespaceKeyword */, "new": 88 /* NewKeyword */, "null": 89 /* NullKeyword */, - "number": 119 /* NumberKeyword */, + "number": 120 /* NumberKeyword */, "package": 105 /* PackageKeyword */, "private": 106 /* PrivateKeyword */, "protected": 107 /* ProtectedKeyword */, "public": 108 /* PublicKeyword */, - "require": 118 /* RequireKeyword */, + "require": 119 /* RequireKeyword */, "return": 90 /* ReturnKeyword */, - "set": 120 /* SetKeyword */, + "set": 121 /* SetKeyword */, "static": 109 /* StaticKeyword */, - "string": 121 /* StringKeyword */, + "string": 122 /* StringKeyword */, "super": 91 /* SuperKeyword */, "switch": 92 /* SwitchKeyword */, - "symbol": 122 /* SymbolKeyword */, + "symbol": 123 /* SymbolKeyword */, "this": 93 /* ThisKeyword */, "throw": 94 /* ThrowKeyword */, "true": 95 /* TrueKeyword */, "try": 96 /* TryKeyword */, - "type": 123 /* TypeKeyword */, + "type": 124 /* TypeKeyword */, "typeof": 97 /* TypeOfKeyword */, "var": 98 /* VarKeyword */, "void": 99 /* VoidKeyword */, "while": 100 /* WhileKeyword */, "with": 101 /* WithKeyword */, "yield": 110 /* YieldKeyword */, - "of": 125 /* OfKeyword */, + "of": 126 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2644,7 +2661,7 @@ var ts; } collecting = true; if (result && result.length) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } continue; case 9 /* tab */: @@ -2690,7 +2707,7 @@ var ts; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { if (result && result.length && isLineBreak(ch)) { - result[result.length - 1].hasTrailingNewLine = true; + ts.lastOrUndefined(result).hasTrailingNewLine = true; } pos++; continue; @@ -2720,8 +2737,7 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - // Creates a scanner over a (possibly unspecified) range of a piece of text. - /* @internal */ + /** Creates a scanner over a (possibly unspecified) range of a piece of text. */ function createScanner(languageVersion, skipTrivia, text, onError, start, length) { var pos; // Current position (end position of text of current token) var end; // end of text @@ -3570,16 +3586,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 202 /* InterfaceDeclaration */ || node.kind === 203 /* TypeAliasDeclaration */) { + if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 204 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 209 /* ImportDeclaration */ || node.kind === 208 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 206 /* ModuleBlock */) { + else if (node.kind === 207 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3598,7 +3614,7 @@ var ts; }); return state; } - else if (node.kind === 205 /* ModuleDeclaration */) { + else if (node.kind === 206 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3653,10 +3669,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 205 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3664,22 +3680,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 143 /* ConstructorType */: - case 135 /* Constructor */: + case 144 /* ConstructorType */: + case 136 /* Constructor */: return "__constructor"; - case 142 /* FunctionType */: - case 138 /* CallSignature */: + case 143 /* FunctionType */: + case 139 /* CallSignature */: return "__call"; - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: return "__new"; - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: return "__index"; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return "__export"; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 200 /* FunctionDeclaration */: - case 201 /* ClassDeclaration */: + case 201 /* FunctionDeclaration */: + case 202 /* ClassDeclaration */: return node.flags & 256 /* Default */ ? "default" : undefined; } } @@ -3714,7 +3730,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if ((node.kind === 201 /* ClassDeclaration */ || node.kind === 174 /* ClassExpression */) && symbol.exports) { + if ((node.kind === 202 /* ClassDeclaration */ || node.kind === 175 /* ClassExpression */) && symbol.exports) { // 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. @@ -3734,7 +3750,7 @@ var ts; function declareModuleMember(node, symbolKind, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolKind & 8388608 /* Alias */) { - if (node.kind === 217 /* ExportSpecifier */ || (node.kind === 208 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 218 /* ExportSpecifier */ || (node.kind === 209 /* ImportEqualsDeclaration */ && hasExportModifier)) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); } else { @@ -3753,7 +3769,7 @@ 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 & 32768 /* ExportContext */) { + if (hasExportModifier || container.flags & 65536 /* ExportContext */) { var exportKind = (symbolKind & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolKind & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolKind & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -3787,7 +3803,7 @@ var ts; // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, (symbolKind & 255504 /* HasLocals */) === 0 && node.kind !== 227 /* SourceFile */); + setBlockScopeContainer(node, (symbolKind & 255504 /* HasLocals */) === 0 && node.kind !== 228 /* SourceFile */); } ts.forEachChild(node, bind); container = saveContainer; @@ -3802,41 +3818,41 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 174 /* ClassExpression */: - case 201 /* ClassDeclaration */: + case 175 /* ClassExpression */: + case 202 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 145 /* TypeLiteral */: - case 154 /* ObjectLiteralExpression */: - case 202 /* InterfaceDeclaration */: + case 146 /* TypeLiteral */: + case 155 /* ObjectLiteralExpression */: + case 203 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -3851,11 +3867,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 227 /* SourceFile */ ? node : node.body; - if (body.kind === 227 /* SourceFile */ || body.kind === 206 /* ModuleBlock */) { + var body = node.kind === 228 /* SourceFile */ ? node : node.body; + if (body.kind === 228 /* SourceFile */ || body.kind === 207 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 215 /* ExportDeclaration */ || stat.kind === 214 /* ExportAssignment */) { + if (stat.kind === 216 /* ExportDeclaration */ || stat.kind === 215 /* ExportAssignment */) { return true; } } @@ -3866,10 +3882,10 @@ var ts; // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 32768 /* ExportContext */; + node.flags |= 65536 /* ExportContext */; } else { - node.flags &= ~32768 /* ExportContext */; + node.flags &= ~65536 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -3909,7 +3925,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 142 /* FunctionType */ ? "__call" : "__new"] = symbol; + typeLiteralSymbol.members[node.kind === 143 /* FunctionType */ ? "__call" : "__new"] = symbol; } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { var symbol = createSymbol(symbolKind, name); @@ -3921,10 +3937,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolKind, symbolExcludes) { switch (blockScopeContainer.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; @@ -3948,14 +3964,14 @@ var ts; function bind(node) { node.parent = parent; switch (node.kind) { - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: bindDeclaration(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */, false); break; - case 129 /* Parameter */: + case 130 /* Parameter */: bindParameter(node); break; - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: if (ts.isBindingPattern(node.name)) { bindChildren(node, 0, false); } @@ -3966,72 +3982,72 @@ var ts; bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); } break; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0), 107455 /* PropertyExcludes */, false); break; - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 226 /* EnumMember */: + case 227 /* EnumMember */: bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: bindDeclaration(node, 131072 /* Signature */, 0, false); break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* 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. bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); break; - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; - case 135 /* Constructor */: + case 136 /* Constructor */: bindDeclaration(node, 16384 /* Constructor */, 0, true); break; - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); break; - case 137 /* SetAccessor */: + case 138 /* SetAccessor */: bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); break; - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: bindFunctionOrConstructorType(node); break; - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: bindAnonymousDeclaration(node, 32 /* Class */, "__class", false); break; - case 223 /* CatchClause */: + case 224 /* CatchClause */: bindCatchVariableDeclaration(node); break; - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); break; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: bindDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */, false); break; - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: bindDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */, false); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: if (ts.isConst(node)) { bindDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */, false); } @@ -4039,16 +4055,16 @@ var ts; bindDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */, false); } break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 208 /* ImportEqualsDeclaration */: - case 211 /* NamespaceImport */: - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 212 /* NamespaceImport */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: bindDeclaration(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */, false); break; - case 210 /* ImportClause */: + case 211 /* ImportClause */: if (node.name) { bindDeclaration(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */, false); } @@ -4056,14 +4072,14 @@ var ts; bindChildren(node, 0, false); } break; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0); } bindChildren(node, 0, false); break; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: if (node.expression.kind === 65 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); @@ -4074,13 +4090,13 @@ var ts; } bindChildren(node, 0, false); break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: setExportContextFlag(node); if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.fileName) + '"', true); break; } - case 179 /* Block */: + case 180 /* Block */: // do not treat function block a block-scope container // all block-scope locals that reside in this block should go to the function locals. // Otherwise this won't be considered as redeclaration of a block scoped local: @@ -4091,11 +4107,11 @@ var ts; // 'let x' will be placed into the function locals and 'let x' - into the locals of the block bindChildren(node, 0, !ts.isFunctionLike(node.parent)); break; - case 223 /* CatchClause */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 207 /* CaseBlock */: + case 224 /* CatchClause */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 208 /* CaseBlock */: bindChildren(node, 0, true); break; default: @@ -4115,8 +4131,8 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 135 /* Constructor */ && - (node.parent.parent.kind === 201 /* ClassDeclaration */ || node.parent.parent.kind === 174 /* ClassExpression */)) { + node.parent.kind === 136 /* Constructor */ && + (node.parent.parent.kind === 202 /* ClassDeclaration */ || node.parent.parent.kind === 175 /* ClassExpression */)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -4206,7 +4222,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 227 /* SourceFile */) { + while (node && node.kind !== 228 /* SourceFile */) { node = node.parent; } return node; @@ -4316,15 +4332,15 @@ var ts; return current; } switch (current.kind) { - case 227 /* SourceFile */: - case 207 /* CaseBlock */: - case 223 /* CatchClause */: - case 205 /* ModuleDeclaration */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 228 /* SourceFile */: + case 208 /* CaseBlock */: + case 224 /* CatchClause */: + case 206 /* ModuleDeclaration */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: return current; - case 179 /* Block */: + case 180 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4337,9 +4353,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 198 /* VariableDeclaration */ && + declaration.kind === 199 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 223 /* CatchClause */; + declaration.parent.kind === 224 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4378,7 +4394,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4387,16 +4403,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 202 /* ClassDeclaration */: + case 175 /* ClassExpression */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: errorNode = node.name; break; } @@ -4420,11 +4436,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 204 /* EnumDeclaration */ && isConst(node); + return node.kind === 205 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 152 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 153 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4439,14 +4455,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 198 /* VariableDeclaration */) { + if (node.kind === 199 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 199 /* VariableDeclarationList */) { + if (node && node.kind === 200 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 180 /* VariableStatement */) { + if (node && node.kind === 181 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4461,12 +4477,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 182 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 183 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 129 /* Parameter */ || node.kind === 128 /* TypeParameter */) { + if (node.kind === 130 /* Parameter */ || node.kind === 129 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -4495,23 +4511,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return visitor(node); - case 207 /* CaseBlock */: - case 179 /* Block */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 192 /* WithStatement */: - case 193 /* SwitchStatement */: - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - case 194 /* LabeledStatement */: - case 196 /* TryStatement */: - case 223 /* CatchClause */: + case 208 /* CaseBlock */: + case 180 /* Block */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 193 /* WithStatement */: + case 194 /* SwitchStatement */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: + case 195 /* LabeledStatement */: + case 197 /* TryStatement */: + case 224 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4520,14 +4536,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 152 /* BindingElement */: - case 226 /* EnumMember */: - case 129 /* Parameter */: - case 224 /* PropertyAssignment */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 225 /* ShorthandPropertyAssignment */: - case 198 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 227 /* EnumMember */: + case 130 /* Parameter */: + case 225 /* PropertyAssignment */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 226 /* ShorthandPropertyAssignment */: + case 199 /* VariableDeclaration */: return true; } } @@ -4537,8 +4553,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return true; } } @@ -4548,22 +4564,22 @@ var ts; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 135 /* Constructor */: - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 200 /* FunctionDeclaration */: + case 136 /* Constructor */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: return true; } } @@ -4571,11 +4587,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 179 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 180 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 134 /* MethodDeclaration */ && node.parent.kind === 154 /* ObjectLiteralExpression */; + return node && node.kind === 135 /* MethodDeclaration */ && node.parent.kind === 155 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4594,12 +4610,12 @@ var ts; return undefined; } switch (node.kind) { - case 127 /* ComputedPropertyName */: + case 128 /* 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 // so that we can error on it. - if (node.parent.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.parent.kind === 202 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4609,9 +4625,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 130 /* Decorator */: + case 131 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 129 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 130 /* 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; @@ -4622,23 +4638,23 @@ var ts; node = node.parent; } break; - case 163 /* ArrowFunction */: + case 164 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 205 /* ModuleDeclaration */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 204 /* EnumDeclaration */: - case 227 /* SourceFile */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 206 /* ModuleDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 205 /* EnumDeclaration */: + case 228 /* SourceFile */: return node; } } @@ -4650,12 +4666,12 @@ var ts; if (!node) return node; switch (node.kind) { - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.parent.kind === 202 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4665,9 +4681,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 130 /* Decorator */: + case 131 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 129 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 130 /* 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; @@ -4678,26 +4694,26 @@ var ts; node = node.parent; } break; - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression or NewExpression. @@ -4706,44 +4722,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: // classes are valid targets return true; - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 201 /* ClassDeclaration */; - case 129 /* Parameter */: + return node.parent.kind === 202 /* ClassDeclaration */; + case 130 /* 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 === 201 /* ClassDeclaration */; - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 134 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 202 /* ClassDeclaration */; + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 135 /* 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 === 201 /* ClassDeclaration */; + return node.body && node.parent.kind === 202 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 132 /* PropertyDeclaration */: - case 129 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 130 /* Parameter */: if (node.decorators) { return true; } return false; - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 138 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -4754,10 +4770,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 138 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4775,37 +4791,37 @@ var ts; case 95 /* TrueKeyword */: case 80 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 153 /* ArrayLiteralExpression */: - case 154 /* ObjectLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 159 /* TaggedTemplateExpression */: - case 160 /* TypeAssertionExpression */: - case 161 /* ParenthesizedExpression */: - case 162 /* FunctionExpression */: - case 174 /* ClassExpression */: - case 163 /* ArrowFunction */: - case 166 /* VoidExpression */: - case 164 /* DeleteExpression */: - case 165 /* TypeOfExpression */: - case 167 /* PrefixUnaryExpression */: - case 168 /* PostfixUnaryExpression */: - case 169 /* BinaryExpression */: - case 170 /* ConditionalExpression */: - case 173 /* SpreadElementExpression */: - case 171 /* TemplateExpression */: + case 154 /* ArrayLiteralExpression */: + case 155 /* ObjectLiteralExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 160 /* TaggedTemplateExpression */: + case 161 /* TypeAssertionExpression */: + case 162 /* ParenthesizedExpression */: + case 163 /* FunctionExpression */: + case 175 /* ClassExpression */: + case 164 /* ArrowFunction */: + case 167 /* VoidExpression */: + case 165 /* DeleteExpression */: + case 166 /* TypeOfExpression */: + case 168 /* PrefixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: + case 170 /* BinaryExpression */: + case 171 /* ConditionalExpression */: + case 174 /* SpreadElementExpression */: + case 172 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 175 /* OmittedExpression */: + case 176 /* OmittedExpression */: return true; - case 126 /* QualifiedName */: - while (node.parent.kind === 126 /* QualifiedName */) { + case 127 /* QualifiedName */: + while (node.parent.kind === 127 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 144 /* TypeQuery */; + return node.parent.kind === 145 /* TypeQuery */; case 65 /* Identifier */: - if (node.parent.kind === 144 /* TypeQuery */) { + if (node.parent.kind === 145 /* TypeQuery */) { return true; } // fall through @@ -4813,42 +4829,42 @@ var ts; case 8 /* StringLiteral */: var parent_1 = node.parent; switch (parent_1.kind) { - case 198 /* VariableDeclaration */: - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 226 /* EnumMember */: - case 224 /* PropertyAssignment */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 227 /* EnumMember */: + case 225 /* PropertyAssignment */: + case 153 /* BindingElement */: return parent_1.initializer === node; - case 182 /* ExpressionStatement */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 191 /* ReturnStatement */: - case 192 /* WithStatement */: - case 193 /* SwitchStatement */: - case 220 /* CaseClause */: - case 195 /* ThrowStatement */: - case 193 /* SwitchStatement */: + case 183 /* ExpressionStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 192 /* ReturnStatement */: + case 193 /* WithStatement */: + case 194 /* SwitchStatement */: + case 221 /* CaseClause */: + case 196 /* ThrowStatement */: + case 194 /* SwitchStatement */: return parent_1.expression === node; - case 186 /* ForStatement */: + case 187 /* ForStatement */: var forStatement = parent_1; - return (forStatement.initializer === node && forStatement.initializer.kind !== 199 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 200 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: var forInStatement = parent_1; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 199 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200 /* VariableDeclarationList */) || forInStatement.expression === node; - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return node === parent_1.expression; - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return node === parent_1.expression; - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: return node === parent_1.expression; - case 130 /* Decorator */: + case 131 /* Decorator */: return true; default: if (isExpression(parent_1)) { @@ -4866,7 +4882,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 219 /* ExternalModuleReference */; + return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4875,40 +4891,40 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 208 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 219 /* ExternalModuleReference */; + return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 220 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 209 /* ImportDeclaration */) { + if (node.kind === 210 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 208 /* ImportEqualsDeclaration */) { + if (node.kind === 209 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 219 /* ExternalModuleReference */) { + if (reference.kind === 220 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 215 /* ExportDeclaration */) { + if (node.kind === 216 /* ExportDeclaration */) { return node.moduleSpecifier; } } ts.getExternalModuleName = getExternalModuleName; function hasDotDotDotToken(node) { - return node && node.kind === 129 /* Parameter */ && node.dotDotDotToken !== undefined; + return node && node.kind === 130 /* Parameter */ && node.dotDotDotToken !== undefined; } ts.hasDotDotDotToken = hasDotDotDotToken; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 129 /* Parameter */: + case 130 /* Parameter */: return node.questionToken !== undefined; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return node.questionToken !== undefined; - case 225 /* ShorthandPropertyAssignment */: - case 224 /* PropertyAssignment */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 226 /* ShorthandPropertyAssignment */: + case 225 /* PropertyAssignment */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -4916,7 +4932,7 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; + return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { @@ -4932,7 +4948,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 151 /* ArrayBindingPattern */ || node.kind === 150 /* ObjectBindingPattern */); + return !!node && (node.kind === 152 /* ArrayBindingPattern */ || node.kind === 151 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4947,33 +4963,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 163 /* ArrowFunction */: - case 152 /* BindingElement */: - case 201 /* ClassDeclaration */: - case 135 /* Constructor */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 217 /* ExportSpecifier */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 136 /* GetAccessor */: - case 210 /* ImportClause */: - case 208 /* ImportEqualsDeclaration */: - case 213 /* ImportSpecifier */: - case 202 /* InterfaceDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 205 /* ModuleDeclaration */: - case 211 /* NamespaceImport */: - case 129 /* Parameter */: - case 224 /* PropertyAssignment */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 137 /* SetAccessor */: - case 225 /* ShorthandPropertyAssignment */: - case 203 /* TypeAliasDeclaration */: - case 128 /* TypeParameter */: - case 198 /* VariableDeclaration */: + case 164 /* ArrowFunction */: + case 153 /* BindingElement */: + case 202 /* ClassDeclaration */: + case 136 /* Constructor */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 218 /* ExportSpecifier */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 137 /* GetAccessor */: + case 211 /* ImportClause */: + case 209 /* ImportEqualsDeclaration */: + case 214 /* ImportSpecifier */: + case 203 /* InterfaceDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 206 /* ModuleDeclaration */: + case 212 /* NamespaceImport */: + case 130 /* Parameter */: + case 225 /* PropertyAssignment */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 138 /* SetAccessor */: + case 226 /* ShorthandPropertyAssignment */: + case 204 /* TypeAliasDeclaration */: + case 129 /* TypeParameter */: + case 199 /* VariableDeclaration */: return true; } return false; @@ -4981,25 +4997,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 197 /* DebuggerStatement */: - case 184 /* DoStatement */: - case 182 /* ExpressionStatement */: - case 181 /* EmptyStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 186 /* ForStatement */: - case 183 /* IfStatement */: - case 194 /* LabeledStatement */: - case 191 /* ReturnStatement */: - case 193 /* SwitchStatement */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 198 /* DebuggerStatement */: + case 185 /* DoStatement */: + case 183 /* ExpressionStatement */: + case 182 /* EmptyStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 187 /* ForStatement */: + case 184 /* IfStatement */: + case 195 /* LabeledStatement */: + case 192 /* ReturnStatement */: + case 194 /* SwitchStatement */: case 94 /* ThrowKeyword */: - case 196 /* TryStatement */: - case 180 /* VariableStatement */: - case 185 /* WhileStatement */: - case 192 /* WithStatement */: - case 214 /* ExportAssignment */: + case 197 /* TryStatement */: + case 181 /* VariableStatement */: + case 186 /* WhileStatement */: + case 193 /* WithStatement */: + case 215 /* ExportAssignment */: return true; default: return false; @@ -5008,13 +5024,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 135 /* Constructor */: - case 132 /* PropertyDeclaration */: - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 133 /* MethodSignature */: - case 140 /* IndexSignature */: + case 136 /* Constructor */: + case 133 /* PropertyDeclaration */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 134 /* MethodSignature */: + case 141 /* IndexSignature */: return true; default: return false; @@ -5027,7 +5043,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 213 /* ImportSpecifier */ || parent.kind === 217 /* ExportSpecifier */) { + if (parent.kind === 214 /* ImportSpecifier */ || parent.kind === 218 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5047,12 +5063,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 208 /* ImportEqualsDeclaration */ || - node.kind === 210 /* ImportClause */ && !!node.name || - node.kind === 211 /* NamespaceImport */ || - node.kind === 213 /* ImportSpecifier */ || - node.kind === 217 /* ExportSpecifier */ || - node.kind === 214 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 209 /* ImportEqualsDeclaration */ || + node.kind === 211 /* ImportClause */ && !!node.name || + node.kind === 212 /* NamespaceImport */ || + node.kind === 214 /* ImportSpecifier */ || + node.kind === 218 /* ExportSpecifier */ || + node.kind === 215 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5135,7 +5151,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 125 /* LastKeyword */; + return 66 /* FirstKeyword */ <= token && token <= 126 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5151,7 +5167,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 127 /* ComputedPropertyName */ && + declaration.name.kind === 128 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5161,14 +5177,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 155 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 156 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 127 /* ComputedPropertyName */) { + if (name.kind === 128 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5205,7 +5221,7 @@ var ts; } ts.isModifier = isModifier; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 205 /* ModuleDeclaration */ || n.kind === 227 /* SourceFile */; + return isFunctionLike(n) || n.kind === 206 /* ModuleDeclaration */ || n.kind === 228 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5380,7 +5396,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); } } } @@ -5441,7 +5457,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 135 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 136 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -5449,8 +5465,10 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - return true; + if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + // 1. in-browser single file compilation scenario + // 2. non .js file + return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -5464,10 +5482,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 136 /* GetAccessor */) { + if (accessor.kind === 137 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 137 /* SetAccessor */) { + else if (accessor.kind === 138 /* SetAccessor */) { setAccessor = accessor; } else { @@ -5476,7 +5494,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 136 /* GetAccessor */ || member.kind === 137 /* SetAccessor */) + if ((member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5487,10 +5505,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 136 /* GetAccessor */ && !getAccessor) { + if (member.kind === 137 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 137 /* SetAccessor */ && !setAccessor) { + if (member.kind === 138 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -5638,22 +5656,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 158 /* NewExpression */: - case 157 /* CallExpression */: - case 159 /* TaggedTemplateExpression */: - case 153 /* ArrayLiteralExpression */: - case 161 /* ParenthesizedExpression */: - case 154 /* ObjectLiteralExpression */: - case 174 /* ClassExpression */: - case 162 /* FunctionExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 159 /* NewExpression */: + case 158 /* CallExpression */: + case 160 /* TaggedTemplateExpression */: + case 154 /* ArrayLiteralExpression */: + case 162 /* ParenthesizedExpression */: + case 155 /* ObjectLiteralExpression */: + case 175 /* ClassExpression */: + case 163 /* FunctionExpression */: case 65 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: case 80 /* FalseKeyword */: case 89 /* NullKeyword */: case 93 /* ThisKeyword */: @@ -5671,30 +5689,97 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). - function isSupportedHeritageClauseElement(node) { - return isSupportedHeritageClauseElementExpression(node.expression); + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } - ts.isSupportedHeritageClauseElement = isSupportedHeritageClauseElement; - function isSupportedHeritageClauseElementExpression(node) { + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { if (node.kind === 65 /* Identifier */) { return true; } - else if (node.kind === 155 /* PropertyAccessExpression */) { - return isSupportedHeritageClauseElementExpression(node.expression); + else if (node.kind === 156 /* PropertyAccessExpression */) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { return false; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 126 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + /** + * Replace each instance of non-ascii characters by one, two, three, or four escape sequences + * representing the UTF-8 encoding of the character, and return the expanded char code list. + */ + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + var leadSurrogate = undefined; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + // handel utf8 + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + /** + * Converts a string to a base-64 encoded ASCII string. + */ + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + // Convert every 6-bits in the input 3 character points + // into a base64 digit + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + // We are out of characters in the input, set the extra + // digits to 64 (padding character). + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + // Write to the ouput + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; })(ts || (ts = {})); var ts; (function (ts) { @@ -5906,7 +5991,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(229 /* Count */); + var nodeConstructors = new Array(230 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5951,20 +6036,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5973,24 +6058,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6001,220 +6086,220 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 141 /* TypeReference */: + case 142 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 147 /* TupleType */: + case 148 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 148 /* UnionType */: + case 149 /* UnionType */: return visitNodes(cbNodes, node.types); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 155 /* PropertyAccessExpression */: + case 156 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 164 /* DeleteExpression */: + case 165 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 165 /* TypeOfExpression */: + case 166 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 166 /* VoidExpression */: + case 167 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 172 /* YieldExpression */: + case 173 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 168 /* PostfixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 173 /* SpreadElementExpression */: + case 174 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 227 /* SourceFile */: + case 228 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 199 /* VariableDeclarationList */: + case 200 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 183 /* IfStatement */: + case 184 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 184 /* DoStatement */: + case 185 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 187 /* ForInStatement */: + case 188 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 188 /* ForOfStatement */: + case 189 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: return visitNode(cbNode, node.label); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 192 /* WithStatement */: + case 193 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 207 /* CaseBlock */: + case 208 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 220 /* CaseClause */: + case 221 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 221 /* DefaultClause */: + case 222 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 196 /* TryStatement */: + case 197 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 130 /* Decorator */: + case 131 /* Decorator */: return visitNode(cbNode, node.expression); - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: + case 202 /* ClassDeclaration */: + case 175 /* 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 202 /* InterfaceDeclaration */: + case 203 /* 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 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 210 /* ImportClause */: + case 211 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 211 /* NamespaceImport */: + case 212 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 212 /* NamedImports */: - case 216 /* NamedExports */: + case 213 /* NamedImports */: + case 217 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 222 /* HeritageClause */: + case 223 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 177 /* HeritageClauseElement */: + case 177 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 219 /* ExternalModuleReference */: + case 220 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 218 /* MissingDeclaration */: + case 219 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); } } @@ -6393,7 +6478,7 @@ var ts; } } function createSourceFile(fileName, languageVersion) { - sourceFile = createNode(227 /* SourceFile */, 0); + sourceFile = createNode(228 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6735,7 +6820,7 @@ var ts; // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] // - var node = createNode(127 /* ComputedPropertyName */); + var node = createNode(128 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -7127,14 +7212,14 @@ var ts; function isReusableModuleElement(node) { if (node) { switch (node.kind) { - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 215 /* ExportDeclaration */: - case 214 /* ExportAssignment */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 216 /* ExportDeclaration */: + case 215 /* ExportAssignment */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: return true; } return isReusableStatement(node); @@ -7144,13 +7229,13 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 135 /* Constructor */: - case 140 /* IndexSignature */: - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 132 /* PropertyDeclaration */: - case 178 /* SemicolonClassElement */: + case 136 /* Constructor */: + case 141 /* IndexSignature */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 179 /* SemicolonClassElement */: return true; } } @@ -7159,8 +7244,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: return true; } } @@ -7169,49 +7254,49 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 180 /* VariableStatement */: - case 179 /* Block */: - case 183 /* IfStatement */: - case 182 /* ExpressionStatement */: - case 195 /* ThrowStatement */: - case 191 /* ReturnStatement */: - case 193 /* SwitchStatement */: - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 186 /* ForStatement */: - case 185 /* WhileStatement */: - case 192 /* WithStatement */: - case 181 /* EmptyStatement */: - case 196 /* TryStatement */: - case 194 /* LabeledStatement */: - case 184 /* DoStatement */: - case 197 /* DebuggerStatement */: + case 201 /* FunctionDeclaration */: + case 181 /* VariableStatement */: + case 180 /* Block */: + case 184 /* IfStatement */: + case 183 /* ExpressionStatement */: + case 196 /* ThrowStatement */: + case 192 /* ReturnStatement */: + case 194 /* SwitchStatement */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 187 /* ForStatement */: + case 186 /* WhileStatement */: + case 193 /* WithStatement */: + case 182 /* EmptyStatement */: + case 197 /* TryStatement */: + case 195 /* LabeledStatement */: + case 185 /* DoStatement */: + case 198 /* DebuggerStatement */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 226 /* EnumMember */; + return node.kind === 227 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 139 /* ConstructSignature */: - case 133 /* MethodSignature */: - case 140 /* IndexSignature */: - case 131 /* PropertySignature */: - case 138 /* CallSignature */: + case 140 /* ConstructSignature */: + case 134 /* MethodSignature */: + case 141 /* IndexSignature */: + case 132 /* PropertySignature */: + case 139 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 198 /* VariableDeclaration */) { + if (node.kind !== 199 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -7232,7 +7317,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 129 /* Parameter */) { + if (node.kind !== 130 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -7344,7 +7429,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(126 /* QualifiedName */, entity.pos); + var node = createNode(127 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7383,20 +7468,20 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(171 /* TemplateExpression */); + var template = createNode(172 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(176 /* TemplateSpan */); + var span = createNode(178 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -7437,7 +7522,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(141 /* TypeReference */); + var node = createNode(142 /* TypeReference */); node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); @@ -7445,13 +7530,13 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(144 /* TypeQuery */); + var node = createNode(145 /* TypeQuery */); parseExpected(97 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(128 /* TypeParameter */); + var node = createNode(129 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(79 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -7497,7 +7582,7 @@ var ts; } } function parseParameter() { - var node = createNode(129 /* Parameter */); + var node = createNode(130 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); @@ -7594,7 +7679,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 139 /* ConstructSignature */) { + if (kind === 140 /* ConstructSignature */) { parseExpected(88 /* NewKeyword */); } fillSignature(51 /* ColonToken */, false, false, node); @@ -7658,7 +7743,7 @@ var ts; return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(140 /* IndexSignature */, fullStart); + var node = createNode(141 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); @@ -7671,7 +7756,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(133 /* MethodSignature */, fullStart); + var method = createNode(134 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -7681,7 +7766,7 @@ var ts; return finishNode(method); } else { - var property = createNode(131 /* PropertySignature */, fullStart); + var property = createNode(132 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7723,7 +7808,7 @@ var ts; switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(138 /* CallSignature */); + return parseSignatureMember(139 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -7731,7 +7816,7 @@ var ts; : parsePropertyOrMethodSignature(); case 88 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(139 /* ConstructSignature */); + return parseSignatureMember(140 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -7768,7 +7853,7 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(145 /* TypeLiteral */); + var node = createNode(146 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7784,12 +7869,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(147 /* TupleType */); + var node = createNode(148 /* TupleType */); node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(149 /* ParenthesizedType */); + var node = createNode(150 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -7797,7 +7882,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 143 /* ConstructorType */) { + if (kind === 144 /* ConstructorType */) { parseExpected(88 /* NewKeyword */); } fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); @@ -7810,10 +7895,10 @@ var ts; function parseNonArrayType() { switch (token) { case 112 /* AnyKeyword */: - case 121 /* StringKeyword */: - case 119 /* NumberKeyword */: + case 122 /* StringKeyword */: + case 120 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -7834,10 +7919,10 @@ var ts; function isStartOfType() { switch (token) { case 112 /* AnyKeyword */: - case 121 /* StringKeyword */: - case 119 /* NumberKeyword */: + case 122 /* StringKeyword */: + case 120 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 97 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: @@ -7861,7 +7946,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(146 /* ArrayType */, type.pos); + var node = createNode(147 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -7876,7 +7961,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(148 /* UnionType */, type.pos); + var node = createNode(149 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } @@ -7931,10 +8016,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(142 /* FunctionType */); + return parseFunctionOrConstructorType(143 /* FunctionType */); } if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(143 /* ConstructorType */); + return parseFunctionOrConstructorType(144 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -8136,7 +8221,7 @@ var ts; (isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */); } function parseYieldExpression() { - var node = createNode(172 /* YieldExpression */); + var node = createNode(173 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -8156,8 +8241,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(163 /* ArrowFunction */, identifier.pos); - var parameter = createNode(129 /* Parameter */, identifier.pos); + var node = createNode(164 /* ArrowFunction */, identifier.pos); + var parameter = createNode(130 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8275,7 +8360,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(163 /* ArrowFunction */); + var node = createNode(164 /* ArrowFunction */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -8336,7 +8421,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(170 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(171 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8349,7 +8434,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 125 /* OfKeyword */; + return t === 86 /* InKeyword */ || t === 126 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -8415,33 +8500,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(169 /* BinaryExpression */, left.pos); + var node = createNode(170 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(167 /* PrefixUnaryExpression */); + var node = createNode(168 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(164 /* DeleteExpression */); + var node = createNode(165 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(165 /* TypeOfExpression */); + var node = createNode(166 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(166 /* VoidExpression */); + var node = createNode(167 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -8471,7 +8556,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(168 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(169 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -8575,14 +8660,14 @@ 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(155 /* PropertyAccessExpression */, expression.pos); + var node = createNode(156 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(160 /* TypeAssertionExpression */); + var node = createNode(161 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); parseExpected(25 /* GreaterThanToken */); @@ -8593,7 +8678,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(155 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(156 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8602,7 +8687,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(156 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(157 /* 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. @@ -8618,7 +8703,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(159 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(160 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -8641,7 +8726,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(157 /* CallExpression */, expression.pos); + var callExpr = createNode(158 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8649,7 +8734,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(157 /* CallExpression */, expression.pos); + var callExpr = createNode(158 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8751,28 +8836,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(161 /* ParenthesizedExpression */); + var node = createNode(162 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(173 /* SpreadElementExpression */); + var node = createNode(174 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(175 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(176 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(153 /* ArrayLiteralExpression */); + var node = createNode(154 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 512 /* MultiLine */; @@ -8782,10 +8867,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(136 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(137 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(120 /* SetKeyword */)) { - return parseAccessorDeclaration(137 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(121 /* SetKeyword */)) { + return parseAccessorDeclaration(138 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -8808,13 +8893,13 @@ var ts; } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(225 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(226 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(224 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(225 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51 /* ColonToken */); @@ -8823,7 +8908,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(154 /* ObjectLiteralExpression */); + var node = createNode(155 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512 /* MultiLine */; @@ -8841,7 +8926,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(162 /* FunctionExpression */); + var node = createNode(163 /* FunctionExpression */); parseExpected(83 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -8856,7 +8941,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(158 /* NewExpression */); + var node = createNode(159 /* NewExpression */); parseExpected(88 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -8867,7 +8952,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(179 /* Block */); + var node = createNode(180 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); parseExpected(15 /* CloseBraceToken */); @@ -8894,12 +8979,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(181 /* EmptyStatement */); + var node = createNode(182 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(183 /* IfStatement */); + var node = createNode(184 /* IfStatement */); parseExpected(84 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -8909,7 +8994,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(184 /* DoStatement */); + var node = createNode(185 /* DoStatement */); parseExpected(75 /* DoKeyword */); node.statement = parseStatement(); parseExpected(100 /* WhileKeyword */); @@ -8924,7 +9009,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(185 /* WhileStatement */); + var node = createNode(186 /* WhileStatement */); parseExpected(100 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -8947,21 +9032,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(187 /* ForInStatement */, pos); + var forInStatement = createNode(188 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(125 /* OfKeyword */)) { - var forOfStatement = createNode(188 /* ForOfStatement */, pos); + else if (parseOptional(126 /* OfKeyword */)) { + var forOfStatement = createNode(189 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(186 /* ForStatement */, pos); + var forStatement = createNode(187 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -8979,7 +9064,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 190 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8987,7 +9072,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(191 /* ReturnStatement */); + var node = createNode(192 /* ReturnStatement */); parseExpected(90 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -8996,7 +9081,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(192 /* WithStatement */); + var node = createNode(193 /* WithStatement */); parseExpected(101 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9005,7 +9090,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(220 /* CaseClause */); + var node = createNode(221 /* CaseClause */); parseExpected(67 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(51 /* ColonToken */); @@ -9013,7 +9098,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(221 /* DefaultClause */); + var node = createNode(222 /* DefaultClause */); parseExpected(73 /* DefaultKeyword */); parseExpected(51 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); @@ -9023,12 +9108,12 @@ var ts; return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(193 /* SwitchStatement */); + var node = createNode(194 /* SwitchStatement */); parseExpected(92 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(207 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(208 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); caseBlock.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); @@ -9043,7 +9128,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(195 /* ThrowStatement */); + var node = createNode(196 /* ThrowStatement */); parseExpected(94 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -9051,7 +9136,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(196 /* TryStatement */); + var node = createNode(197 /* TryStatement */); parseExpected(96 /* TryKeyword */); node.tryBlock = parseBlock(false, false); node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -9064,7 +9149,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(223 /* CatchClause */); + var result = createNode(224 /* CatchClause */); parseExpected(68 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -9074,7 +9159,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(197 /* DebuggerStatement */); + var node = createNode(198 /* DebuggerStatement */); parseExpected(72 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -9086,13 +9171,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(194 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(195 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(182 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(183 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -9150,8 +9235,9 @@ var ts; return !isConstEnum; case 103 /* InterfaceKeyword */: case 117 /* ModuleKeyword */: + case 118 /* NamespaceKeyword */: case 77 /* EnumKeyword */: - case 123 /* TypeKeyword */: + case 124 /* TypeKeyword */: // When followed by an identifier, these do not start a statement but might // instead be following declarations if (isDeclarationStart()) { @@ -9201,9 +9287,9 @@ var ts; case 82 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(189 /* ContinueStatement */); + return parseBreakOrContinueStatement(190 /* ContinueStatement */); case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(190 /* BreakStatement */); + return parseBreakOrContinueStatement(191 /* BreakStatement */); case 90 /* ReturnKeyword */: return parseReturnStatement(); case 101 /* WithKeyword */: @@ -9278,16 +9364,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(175 /* OmittedExpression */); + return createNode(176 /* OmittedExpression */); } - var node = createNode(152 /* BindingElement */); + var node = createNode(153 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(152 /* BindingElement */); + var node = createNode(153 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -9303,14 +9389,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(150 /* ObjectBindingPattern */); + var node = createNode(151 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); node.elements = parseDelimitedList(10 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(151 /* ArrayBindingPattern */); + var node = createNode(152 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); node.elements = parseDelimitedList(11 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); @@ -9329,7 +9415,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(198 /* VariableDeclaration */); + var node = createNode(199 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -9338,7 +9424,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(199 /* VariableDeclarationList */); + var node = createNode(200 /* VariableDeclarationList */); switch (token) { case 98 /* VarKeyword */: break; @@ -9361,7 +9447,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 === 125 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 126 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -9376,7 +9462,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(180 /* VariableStatement */, fullStart); + var node = createNode(181 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -9384,7 +9470,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(200 /* FunctionDeclaration */, fullStart); + var node = createNode(201 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83 /* FunctionKeyword */); @@ -9395,7 +9481,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(135 /* Constructor */, pos); + var node = createNode(136 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114 /* ConstructorKeyword */); @@ -9404,7 +9490,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(134 /* MethodDeclaration */, fullStart); + var method = createNode(135 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -9415,7 +9501,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(132 /* PropertyDeclaration */, fullStart); + var property = createNode(133 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -9496,7 +9582,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 120 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 121 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -9530,7 +9616,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(130 /* Decorator */, decoratorStart); + var decorator = createNode(131 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -9563,7 +9649,7 @@ var ts; } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(178 /* SemicolonClassElement */); + var result = createNode(179 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -9601,10 +9687,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart:*/ scanner.getStartPos(), /*decorators:*/ undefined, - /*modifiers:*/ undefined, 174 /* ClassExpression */); + /*modifiers:*/ undefined, 175 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 201 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code @@ -9649,16 +9735,16 @@ var ts; } function parseHeritageClause() { if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(222 /* HeritageClause */); + var node = createNode(223 /* HeritageClause */); node.token = token; nextToken(); - node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseHeritageClauseElement); + node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } - function parseHeritageClauseElement() { - var node = createNode(177 /* HeritageClauseElement */); + function parseExpressionWithTypeArguments() { + var node = createNode(177 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); @@ -9672,7 +9758,7 @@ var ts; return parseList(6 /* ClassMembers */, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(202 /* InterfaceDeclaration */, fullStart); + var node = createNode(203 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103 /* InterfaceKeyword */); @@ -9683,10 +9769,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* TypeAliasDeclaration */, fullStart); + var node = createNode(204 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(123 /* TypeKeyword */); + parseExpected(124 /* TypeKeyword */); node.name = parseIdentifier(); parseExpected(53 /* EqualsToken */); node.type = parseType(); @@ -9698,13 +9784,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(226 /* EnumMember */, scanner.getStartPos()); + var node = createNode(227 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204 /* EnumDeclaration */, fullStart); + var node = createNode(205 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77 /* EnumKeyword */); @@ -9719,7 +9805,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(206 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(207 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); parseExpected(15 /* CloseBraceToken */); @@ -9729,19 +9815,19 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, decorators, modifiers, flags) { - var node = createNode(205 /* ModuleDeclaration */, fullStart); + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(206 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(20 /* DotToken */) - ? parseInternalModuleTail(getNodePos(), undefined, undefined, 1 /* Export */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* ModuleDeclaration */, fullStart); + var node = createNode(206 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9749,13 +9835,20 @@ var ts; return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { - parseExpected(117 /* ModuleKeyword */); - return token === 8 /* StringLiteral */ - ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) - : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(118 /* NamespaceKeyword */)) { + flags |= 32768 /* Namespace */; + } + else { + parseExpected(117 /* ModuleKeyword */); + if (token === 8 /* StringLiteral */) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 118 /* RequireKeyword */ && + return token === 119 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -9764,7 +9857,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 124 /* FromKeyword */; + token === 125 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85 /* ImportKeyword */); @@ -9772,11 +9865,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 124 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 125 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(208 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(209 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -9787,7 +9880,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(209 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(210 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -9797,7 +9890,7 @@ var ts; token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(124 /* FromKeyword */); + parseExpected(125 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -9810,7 +9903,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(210 /* ImportClause */, fullStart); + var importClause = createNode(211 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -9820,7 +9913,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(212 /* NamedImports */); + importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(213 /* NamedImports */); } return finishNode(importClause); } @@ -9830,8 +9923,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(219 /* ExternalModuleReference */); - parseExpected(118 /* RequireKeyword */); + var node = createNode(220 /* ExternalModuleReference */); + parseExpected(119 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -9852,7 +9945,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(211 /* NamespaceImport */); + var namespaceImport = createNode(212 /* NamespaceImport */); parseExpected(35 /* AsteriskToken */); parseExpected(111 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -9867,14 +9960,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 212 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 213 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(217 /* ExportSpecifier */); + return parseImportOrExportSpecifier(218 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(213 /* ImportSpecifier */); + return parseImportOrExportSpecifier(214 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9899,23 +9992,23 @@ var ts; else { node.name = identifierName; } - if (kind === 213 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 214 /* 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(215 /* ExportDeclaration */, fullStart); + var node = createNode(216 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(124 /* FromKeyword */); + parseExpected(125 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(216 /* NamedExports */); - if (parseOptional(124 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(217 /* NamedExports */); + if (parseOptional(125 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9923,7 +10016,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(214 /* ExportAssignment */, fullStart); + var node = createNode(215 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53 /* EqualsToken */)) { @@ -9952,13 +10045,14 @@ var ts; case 69 /* ClassKeyword */: case 103 /* InterfaceKeyword */: case 77 /* EnumKeyword */: - case 123 /* TypeKeyword */: + case 124 /* TypeKeyword */: // Not true keywords so ensure an identifier follows return lookAhead(nextTokenIsIdentifierOrKeyword); case 85 /* ImportKeyword */: // Not true keywords so ensure an identifier follows or is string literal or asterisk or open brace return lookAhead(nextTokenCanFollowImportKeyword); case 117 /* ModuleKeyword */: + case 118 /* NamespaceKeyword */: // Not a true keyword so ensure an identifier or string literal follows return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); case 78 /* ExportKeyword */: @@ -10029,11 +10123,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 123 /* TypeKeyword */: + case 124 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); case 117 /* ModuleKeyword */: + case 118 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -10041,7 +10136,7 @@ var ts; if (decorators) { // We reached this point because we encountered an AtToken and assumed a declaration would // follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(218 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(219 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10124,10 +10219,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 208 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 219 /* ExternalModuleReference */ - || node.kind === 209 /* ImportDeclaration */ - || node.kind === 214 /* ExportAssignment */ - || node.kind === 215 /* ExportDeclaration */ + || node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */ + || node.kind === 210 /* ImportDeclaration */ + || node.kind === 215 /* ExportAssignment */ + || node.kind === 216 /* ExportDeclaration */ ? node : undefined; }); @@ -10710,7 +10805,6 @@ var ts; var undefinedType = createIntrinsicType(32 /* Undefined */ | 262144 /* ContainsUndefinedOrNull */, "undefined"); var nullType = createIntrinsicType(64 /* Null */ | 262144 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var resolvingType = createIntrinsicType(1 /* Any */, "__resolving__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -10740,6 +10834,8 @@ var ts; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var resolutionTargets = []; + var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10905,10 +11001,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 227 /* SourceFile */); + return ts.getAncestor(node, 228 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 227 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 228 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10957,40 +11053,40 @@ var ts; } } switch (location.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { - if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 217 /* ExportSpecifier */)) { + if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 218 /* ExportSpecifier */)) { break loop; } result = undefined; } - else if (location.kind === 227 /* SourceFile */ || - (location.kind === 205 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { - result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & 8914931 /* ModuleMember */); + else if (location.kind === 228 /* SourceFile */ || + (location.kind === 206 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + result = getSymbolOfNode(location).exports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) { + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* 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 // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === 201 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (location.parent.kind === 202 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -11000,8 +11096,8 @@ var ts; } } break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -11021,9 +11117,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (grandparent.kind === 201 /* ClassDeclaration */ || grandparent.kind === 202 /* InterfaceDeclaration */) { + if (grandparent.kind === 202 /* ClassDeclaration */ || grandparent.kind === 203 /* 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); @@ -11031,19 +11127,19 @@ var ts; } } break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 162 /* FunctionExpression */: + case 163 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -11054,14 +11150,14 @@ var ts; break loop; } break; - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: var className = location.name; if (className && name === className.text) { result = location.symbol; break loop; } break; - case 130 /* Decorator */: + case 131 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -11070,7 +11166,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 === 129 /* Parameter */) { + if (location.parent && location.parent.kind === 130 /* Parameter */) { location = location.parent; } // @@ -11126,16 +11222,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 198 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 199 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 180 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 186 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 181 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 187 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 188 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 187 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 188 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -11162,10 +11258,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 208 /* ImportEqualsDeclaration */) { + if (node.kind === 209 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 209 /* ImportDeclaration */) { + while (node && node.kind !== 210 /* ImportDeclaration */) { node = node.parent; } return node; @@ -11175,7 +11271,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 219 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 220 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11185,7 +11281,7 @@ var ts; if (moduleSymbol) { var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } return exportDefaultSymbol; } @@ -11282,17 +11378,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 210 /* ImportClause */: + case 211 /* ImportClause */: return getTargetOfImportClause(node); - case 211 /* NamespaceImport */: + case 212 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 213 /* ImportSpecifier */: + case 214 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 217 /* ExportSpecifier */: + case 218 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -11337,11 +11433,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 214 /* ExportAssignment */) { + if (node.kind === 215 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 217 /* ExportSpecifier */) { + else if (node.kind === 218 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -11354,7 +11450,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 208 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 209 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -11367,13 +11463,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 126 /* QualifiedName */) { + if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 127 /* 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 === 208 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 209 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -11387,14 +11483,15 @@ var ts; } var symbol; if (name.kind === 65 /* Identifier */) { - symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); + var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, message, name); if (!symbol) { return undefined; } } - else if (name.kind === 126 /* QualifiedName */ || name.kind === 155 /* PropertyAccessExpression */) { - var left = name.kind === 126 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 126 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 127 /* QualifiedName */ || name.kind === 156 /* PropertyAccessExpression */) { + var left = name.kind === 127 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 127 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11451,10 +11548,10 @@ var ts; if (sourceFile.symbol) { return sourceFile.symbol; } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.fileName); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); return; } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); } // 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. @@ -11467,7 +11564,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { - error(moduleReferenceExpression, ts.Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } return symbol; @@ -11554,7 +11651,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 135 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 136 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -11624,17 +11721,17 @@ var ts; } } switch (location_1.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11783,8 +11880,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 205 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 227 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 206 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 228 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11820,12 +11917,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 144 /* TypeQuery */) { + if (entityName.parent.kind === 145 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 126 /* QualifiedName */ || entityName.kind === 155 /* PropertyAccessExpression */ || - entityName.parent.kind === 208 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 127 /* QualifiedName */ || entityName.kind === 156 /* PropertyAccessExpression */ || + entityName.parent.kind === 209 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -11873,10 +11970,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 149 /* ParenthesizedType */) { + while (node.kind === 150 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 203 /* TypeAliasDeclaration */) { + if (node.kind === 204 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -12080,7 +12177,7 @@ var ts; var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { - return declaration.parent.kind === 227 /* SourceFile */ || declaration.parent.kind === 206 /* ModuleBlock */; + return declaration.parent.kind === 228 /* SourceFile */ || declaration.parent.kind === 207 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -12159,7 +12256,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 121 /* StringKeyword */); + writeKeyword(writer, 122 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -12173,7 +12270,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 119 /* NumberKeyword */); + writeKeyword(writer, 120 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -12319,12 +12416,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 205 /* ModuleDeclaration */) { + if (node.kind === 206 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 227 /* SourceFile */) { + else if (node.kind === 228 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -12373,69 +12470,69 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 152 /* BindingElement */: + case 153 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 198 /* VariableDeclaration */: + case 199 /* 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 205 /* ModuleDeclaration */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 200 /* FunctionDeclaration */: - case 204 /* EnumDeclaration */: - case 208 /* ImportEqualsDeclaration */: + case 206 /* ModuleDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 201 /* FunctionDeclaration */: + case 205 /* EnumDeclaration */: + case 209 /* ImportEqualsDeclaration */: var parent_2 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 208 /* ImportEqualsDeclaration */ && parent_2.kind !== 227 /* SourceFile */ && ts.isInAmbientContext(parent_2))) { + !(node.kind !== 209 /* ImportEqualsDeclaration */ && parent_2.kind !== 228 /* SourceFile */ && ts.isInAmbientContext(parent_2))) { return isGlobalSourceFile(parent_2); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_2); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 135 /* Constructor */: - case 139 /* ConstructSignature */: - case 138 /* CallSignature */: - case 140 /* IndexSignature */: - case 129 /* Parameter */: - case 206 /* ModuleBlock */: - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 145 /* TypeLiteral */: - case 141 /* TypeReference */: - case 146 /* ArrayType */: - case 147 /* TupleType */: - case 148 /* UnionType */: - case 149 /* ParenthesizedType */: + case 136 /* Constructor */: + case 140 /* ConstructSignature */: + case 139 /* CallSignature */: + case 141 /* IndexSignature */: + case 130 /* Parameter */: + case 207 /* ModuleBlock */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 146 /* TypeLiteral */: + case 142 /* TypeReference */: + case 147 /* ArrayType */: + case 148 /* TupleType */: + case 149 /* UnionType */: + case 150 /* 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 210 /* ImportClause */: - case 211 /* NamespaceImport */: - case 213 /* ImportSpecifier */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: + case 214 /* ImportSpecifier */: return false; // Type parameters are always visible - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: // Source file is always visible - case 227 /* SourceFile */: + case 228 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -12451,10 +12548,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 214 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 215 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 217 /* ExportSpecifier */) { + else if (node.parent.kind === 218 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -12479,8 +12576,37 @@ var ts; }); } } + // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, + // a new entry with that target and an associated result value of true is pushed on the stack, and the value + // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and + // all entries pushed after it are changed to false, and the value false is returned. The target object provides + // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of + // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and + // Signature instances are used to track resolution of Signature.resolvedReturnType. + function pushTypeResolution(target) { + var i = 0; + var count = resolutionTargets.length; + while (i < count && resolutionTargets[i] !== target) { + i++; + } + if (i < count) { + do { + resolutionResults[i++] = false; + } while (i < count); + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + return true; + } + // Pop an entry from the type resolution stack and return its associated result value. The result value will + // be true if no circularities were detected, or false if a circularity was found. + function popTypeResolution() { + resolutionTargets.pop(); + return resolutionResults.pop(); + } function getRootDeclaration(node) { - while (node.kind === 152 /* BindingElement */) { + while (node.kind === 153 /* BindingElement */) { node = node.parent.parent; } return node; @@ -12489,7 +12615,7 @@ var ts; node = getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 198 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 199 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -12522,7 +12648,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 150 /* ObjectBindingPattern */) { + if (pattern.kind === 151 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_5 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -12569,10 +12695,10 @@ 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 === 187 /* ForInStatement */) { + if (declaration.parent.parent.kind === 188 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 188 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 189 /* 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, @@ -12586,11 +12712,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129 /* Parameter */) { + if (declaration.kind === 130 /* 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 === 137 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 136 /* GetAccessor */); + if (func.kind === 138 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12606,7 +12732,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 225 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 226 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -12641,7 +12767,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 175 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 176 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -12664,7 +12790,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) { - return pattern.kind === 150 /* ObjectBindingPattern */ + return pattern.kind === 151 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -12686,7 +12812,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 224 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 225 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -12698,7 +12824,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 129 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 130 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12713,28 +12839,33 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 223 /* CatchClause */) { + if (declaration.parent.kind === 224 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 214 /* ExportAssignment */) { + if (declaration.kind === 215 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - links.type = resolvingType; + if (!pushTypeResolution(symbol)) { + return unknownType; + } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var diagnostic = symbol.valueDeclaration.type ? - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation : - ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer; - error(symbol.valueDeclaration, diagnostic, symbolToString(symbol)); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + // Variable has type annotation that circularly references the variable itself + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + // Variable has initializer that circularly references the variable itself + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } } + links.type = type; } return links.type; } @@ -12743,7 +12874,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 136 /* GetAccessor */) { + if (accessor.kind === 137 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12755,15 +12886,12 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - checkAndStoreTypeOfAccessors(symbol, links); - return links.type; - } - function checkAndStoreTypeOfAccessors(symbol, links) { - links = links || getSymbolLinks(symbol); if (!links.type) { - links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 136 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 137 /* SetAccessor */); + if (!pushTypeResolution(symbol)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 138 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -12789,17 +12917,16 @@ var ts; } } } - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 136 /* GetAccessor */); - error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 137 /* 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)); + } } + links.type = type; } + return links.type; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -12866,7 +12993,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 202 /* InterfaceDeclaration */ || node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 202 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -12900,10 +13027,10 @@ var ts; } function resolveBaseTypesOfClass(type) { type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 201 /* ClassDeclaration */); + var declaration = ts.getDeclarationOfKind(type.symbol, 202 /* ClassDeclaration */); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); if (baseTypeNode) { - var baseType = getTypeFromHeritageClauseElement(baseTypeNode); + var baseType = getTypeFromTypeNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024 /* Class */) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -12923,10 +13050,10 @@ var ts; type.baseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 202 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 203 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; - var baseType = getTypeFromHeritageClauseElement(node); + var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -12964,17 +13091,18 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 203 /* TypeAliasDeclaration */); - var type = getTypeFromTypeNode(declaration.type); - if (links.declaredType === resolvingType) { - links.declaredType = type; + // Note that we use the links object as the target here because the symbol object is used as the unique + // identity for resolution of the 'type' property in SymbolLinks. + if (!pushTypeResolution(links)) { + return unknownType; } - } - else if (links.declaredType === resolvingType) { - links.declaredType = unknownType; - var declaration = ts.getDeclarationOfKind(symbol, 203 /* TypeAliasDeclaration */); - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + var declaration = ts.getDeclarationOfKind(symbol, 204 /* TypeAliasDeclaration */); + var type = getTypeFromTypeNode(declaration.type); + if (!popTypeResolution()) { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; } return links.declaredType; } @@ -12992,7 +13120,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 128 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -13461,7 +13589,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 136 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13492,8 +13620,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 === 136 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 137 /* SetAccessor */); + if (declaration.kind === 137 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 138 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13511,19 +13639,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 164 /* 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). @@ -13540,7 +13668,9 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - signature.resolvedReturnType = resolvingType; + if (!pushTypeResolution(signature)) { + return unknownType; + } var type; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); @@ -13551,27 +13681,25 @@ var ts; else { type = getReturnTypeFromBody(signature.declaration); } - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = type; - } - } - else if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + } } } + signature.resolvedReturnType = type; } return signature.resolvedReturnType; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -13600,7 +13728,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 === 135 /* Constructor */ || signature.declaration.kind === 139 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 136 /* Constructor */ || signature.declaration.kind === 140 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -13614,7 +13742,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 119 /* NumberKeyword */ : 121 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 120 /* NumberKeyword */ : 122 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -13644,7 +13772,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 128 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -13700,13 +13828,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 128 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 141 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 142 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -13732,20 +13860,14 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReference(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromHeritageClauseElement(node) { - return getTypeFromTypeReferenceOrHeritageClauseElement(node); - } - function getTypeFromTypeReferenceOrHeritageClauseElement(node) { + function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var type; // We don't currently support heritage clauses with complex expressions in them. // For these cases, we just set the type to be the unknownType. - if (node.kind !== 177 /* HeritageClauseElement */ || ts.isSupportedHeritageClauseElement(node)) { - var typeNameOrExpression = node.kind === 141 /* TypeReference */ + if (node.kind !== 177 /* ExpressionWithTypeArguments */ || ts.isSupportedExpressionWithTypeArguments(node)) { + var typeNameOrExpression = node.kind === 142 /* TypeReference */ ? node.typeName : node.expression; var symbol = resolveEntityName(typeNameOrExpression, 793056 /* Type */); @@ -13799,9 +13921,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: return declaration; } } @@ -13999,40 +14121,40 @@ var ts; switch (node.kind) { case 112 /* AnyKeyword */: return anyType; - case 121 /* StringKeyword */: + case 122 /* StringKeyword */: return stringType; - case 119 /* NumberKeyword */: + case 120 /* NumberKeyword */: return numberType; case 113 /* BooleanKeyword */: return booleanType; - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: return esSymbolType; case 99 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 141 /* TypeReference */: - return getTypeFromTypeReference(node); - case 177 /* HeritageClauseElement */: - return getTypeFromHeritageClauseElement(node); - case 144 /* TypeQuery */: + case 142 /* TypeReference */: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + case 177 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + case 145 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 147 /* TupleType */: + case 148 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 148 /* UnionType */: + case 149 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 145 /* TypeLiteral */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 146 /* 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 65 /* Identifier */: - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -14190,27 +14312,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 !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return node.operatorToken.kind === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 224 /* PropertyAssignment */: + case 225 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -15046,22 +15168,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 129 /* Parameter */: + case 130 /* 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 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -15330,10 +15452,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 144 /* TypeQuery */: + case 145 /* TypeQuery */: return true; case 65 /* Identifier */: - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: node = node.parent; continue; default: @@ -15381,7 +15503,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { var n = node.left; - while (n.kind === 161 /* ParenthesizedExpression */) { + while (n.kind === 162 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -15398,46 +15520,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: - case 153 /* ArrayLiteralExpression */: - case 154 /* ObjectLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 160 /* TypeAssertionExpression */: - case 161 /* ParenthesizedExpression */: - case 167 /* PrefixUnaryExpression */: - case 164 /* DeleteExpression */: - case 165 /* TypeOfExpression */: - case 166 /* VoidExpression */: - case 168 /* PostfixUnaryExpression */: - case 170 /* ConditionalExpression */: - case 173 /* SpreadElementExpression */: - case 179 /* Block */: - case 180 /* VariableStatement */: - case 182 /* ExpressionStatement */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 191 /* ReturnStatement */: - case 192 /* WithStatement */: - case 193 /* SwitchStatement */: - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - case 194 /* LabeledStatement */: - case 195 /* ThrowStatement */: - case 196 /* TryStatement */: - case 223 /* CatchClause */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: + case 154 /* ArrayLiteralExpression */: + case 155 /* ObjectLiteralExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 161 /* TypeAssertionExpression */: + case 162 /* ParenthesizedExpression */: + case 168 /* PrefixUnaryExpression */: + case 165 /* DeleteExpression */: + case 166 /* TypeOfExpression */: + case 167 /* VoidExpression */: + case 169 /* PostfixUnaryExpression */: + case 171 /* ConditionalExpression */: + case 174 /* SpreadElementExpression */: + case 180 /* Block */: + case 181 /* VariableStatement */: + case 183 /* ExpressionStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 192 /* ReturnStatement */: + case 193 /* WithStatement */: + case 194 /* SwitchStatement */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: + case 195 /* LabeledStatement */: + case 196 /* ThrowStatement */: + case 197 /* TryStatement */: + case 224 /* CatchClause */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15489,19 +15611,19 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 183 /* IfStatement */: + case 184 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { @@ -15512,14 +15634,14 @@ var ts; } } break; - case 227 /* SourceFile */: - case 205 /* ModuleDeclaration */: - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: + case 228 /* SourceFile */: + case 206 /* ModuleDeclaration */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -15535,7 +15657,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 !== 165 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 166 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; @@ -15610,17 +15732,34 @@ var ts; } // Target type is type of prototype property var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (!prototypeProperty) { - return type; + if (prototypeProperty) { + var targetType = getTypeOfSymbol(prototypeProperty); + if (targetType !== anyType) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + } + } } - var targetType = getTypeOfSymbol(prototypeProperty); - // Narrow to target type if it is a subtype of current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; + // Target type is type of construct signature + var constructSignatures; + if (rightType.flags & 2048 /* Interface */) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - // If current type is a union type, remove all constituents that aren't subtypes of target type - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + else if (rightType.flags & 32768 /* Anonymous */) { + constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + } + if (constructSignatures && constructSignatures.length !== 0) { + var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + // Pickup type from union types + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); })); + } + return instanceType; } return type; } @@ -15628,9 +15767,9 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -15645,7 +15784,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -15662,7 +15801,7 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 163 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 /* ArrowFunction */ && 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); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -15686,7 +15825,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 223 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 224 /* CatchClause */) { return; } // - check if binding is used in some function @@ -15695,12 +15834,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 199 /* VariableDeclarationList */) { + while (container.kind !== 200 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 180 /* VariableStatement */) { + if (container.kind === 181 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -15719,9 +15858,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 201 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 132 /* PropertyDeclaration */ || container.kind === 135 /* Constructor */) { + if (container.kind === 133 /* PropertyDeclaration */ || container.kind === 136 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -15734,39 +15873,39 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 163 /* ArrowFunction */) { + if (container.kind === 164 /* ArrowFunction */) { container = ts.getThisContainer(container, 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 205 /* ModuleDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); + case 206 /* 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 204 /* EnumDeclaration */: + case 205 /* 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 135 /* Constructor */: + case 136 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 201 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -15775,15 +15914,15 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 129 /* Parameter */) { + if (n.kind === 130 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 157 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 201 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); var baseClass; if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -15801,7 +15940,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 135 /* Constructor */; + canUseSuperExpression = container.kind === 136 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -15810,28 +15949,28 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 163 /* ArrowFunction */) { + while (container && container.kind === 164 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === 201 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 202 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 134 /* MethodDeclaration */ || - container.kind === 133 /* MethodSignature */ || - container.kind === 136 /* GetAccessor */ || - container.kind === 137 /* SetAccessor */; + container.kind === 135 /* MethodDeclaration */ || + container.kind === 134 /* MethodSignature */ || + container.kind === 137 /* GetAccessor */ || + container.kind === 138 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 134 /* MethodDeclaration */ || - container.kind === 133 /* MethodSignature */ || - container.kind === 136 /* GetAccessor */ || - container.kind === 137 /* SetAccessor */ || - container.kind === 132 /* PropertyDeclaration */ || - container.kind === 131 /* PropertySignature */ || - container.kind === 135 /* Constructor */; + container.kind === 135 /* MethodDeclaration */ || + container.kind === 134 /* MethodSignature */ || + container.kind === 137 /* GetAccessor */ || + container.kind === 138 /* SetAccessor */ || + container.kind === 133 /* PropertyDeclaration */ || + container.kind === 132 /* PropertySignature */ || + container.kind === 136 /* Constructor */; } } } @@ -15845,7 +15984,7 @@ var ts; getNodeLinks(node).flags |= 16 /* SuperInstance */; returnType = baseClass; } - if (container.kind === 135 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 136 /* 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); returnType = unknownType; @@ -15859,7 +15998,7 @@ var ts; return returnType; } } - if (container && container.kind === 127 /* ComputedPropertyName */) { + if (container && container.kind === 128 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15886,7 +16025,7 @@ var ts; // If last parameter is contextually rest parameter get its type if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); } } } @@ -15904,7 +16043,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 129 /* Parameter */) { + if (declaration.kind === 130 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15921,7 +16060,7 @@ var ts; if (func) { // 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 (func.type || func.kind === 135 /* Constructor */ || func.kind === 136 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 137 /* SetAccessor */))) { + if (func.type || func.kind === 136 /* Constructor */ || func.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 138 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -15944,7 +16083,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 159 /* TaggedTemplateExpression */) { + if (template.parent.kind === 160 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -16075,32 +16214,32 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 198 /* VariableDeclaration */: - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 153 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 163 /* ArrowFunction */: - case 191 /* ReturnStatement */: + case 164 /* ArrowFunction */: + case 192 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 224 /* PropertyAssignment */: + case 225 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 176 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 171 /* TemplateExpression */); + case 178 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 172 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return getContextualType(parent); } return undefined; @@ -16117,7 +16256,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 162 /* FunctionExpression */ || node.kind === 163 /* ArrowFunction */; + return node.kind === 163 /* FunctionExpression */ || node.kind === 164 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions and arrow functions are contextually typed. @@ -16129,7 +16268,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 !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -16185,13 +16324,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 === 169 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 170 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 224 /* PropertyAssignment */) { + if (parent.kind === 225 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 153 /* ArrayLiteralExpression */) { + if (parent.kind === 154 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -16216,7 +16355,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 173 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 174 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -16240,7 +16379,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 173 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 174 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -16251,7 +16390,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 127 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 128 /* 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, @@ -16307,18 +16446,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 224 /* PropertyAssignment */ || - memberDecl.kind === 225 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 225 /* PropertyAssignment */ || + memberDecl.kind === 226 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 224 /* PropertyAssignment */) { + if (memberDecl.kind === 225 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 134 /* MethodDeclaration */) { + else if (memberDecl.kind === 135 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 225 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 226 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -16338,7 +16477,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 === 136 /* GetAccessor */ || memberDecl.kind === 137 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 137 /* GetAccessor */ || memberDecl.kind === 138 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16377,7 +16516,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 : 132 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 133 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -16390,7 +16529,7 @@ var ts; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getAncestor(node, 201 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 202 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -16451,7 +16590,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 (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 134 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -16463,14 +16602,14 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 155 /* PropertyAccessExpression */ + var left = node.kind === 156 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 134 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { return false; } else { @@ -16486,7 +16625,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 158 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 159 /* 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); @@ -16615,7 +16754,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -16683,7 +16822,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 173 /* SpreadElementExpression */) { + if (args[i].kind === 174 /* SpreadElementExpression */) { return i; } } @@ -16693,13 +16832,13 @@ var ts; var adjustedArgCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* 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 === 171 /* TemplateExpression */) { + if (tagExpression.template.kind === 172 /* 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; @@ -16720,7 +16859,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 === 158 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 159 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -16797,10 +16936,10 @@ var ts; // wildcards for all context sensitive function expressions. for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175 /* OmittedExpression */) { + if (arg.kind !== 176 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 159 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 160 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { @@ -16847,12 +16986,12 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 175 /* OmittedExpression */) { + if (arg.kind !== 176 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // A tagged template expression provides a special first argument, and string literals get string literal types // unless we're reporting errors - var argType = i === 0 && node.kind === 159 /* TaggedTemplateExpression */ + var argType = i === 0 && node.kind === 160 /* TaggedTemplateExpression */ ? globalTemplateStringsArrayType : arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) @@ -16874,10 +17013,10 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 159 /* TaggedTemplateExpression */) { + if (node.kind === 160 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 171 /* TemplateExpression */) { + if (template.kind === 172 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -16900,7 +17039,7 @@ var ts; */ function getEffectiveTypeArguments(callExpression) { if (callExpression.expression.kind === 91 /* SuperKeyword */) { - var containingClass = ts.getAncestor(callExpression, 201 /* ClassDeclaration */); + var containingClass = ts.getAncestor(callExpression, 202 /* ClassDeclaration */); var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); return baseClassTypeNode && baseClassTypeNode.typeArguments; } @@ -16910,7 +17049,7 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 159 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 160 /* TaggedTemplateExpression */; var typeArguments; if (!isTaggedTemplate) { typeArguments = getEffectiveTypeArguments(node); @@ -17223,13 +17362,13 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 157 /* CallExpression */) { + if (node.kind === 158 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 158 /* NewExpression */) { + else if (node.kind === 159 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 159 /* TaggedTemplateExpression */) { + else if (node.kind === 160 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -17245,12 +17384,12 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { return voidType; } - if (node.kind === 158 /* NewExpression */) { + if (node.kind === 159 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 135 /* Constructor */ && - declaration.kind !== 139 /* ConstructSignature */ && - declaration.kind !== 143 /* ConstructorType */) { + declaration.kind !== 136 /* Constructor */ && + declaration.kind !== 140 /* ConstructSignature */ && + declaration.kind !== 144 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -17287,9 +17426,9 @@ var ts; links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var parameter = signature.parameters[signature.parameters.length - 1]; + var parameter = ts.lastOrUndefined(signature.parameters); var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } function getReturnTypeFromBody(func, contextualMapper) { @@ -17298,7 +17437,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 179 /* Block */) { + if (func.body.kind !== 180 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -17340,7 +17479,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 195 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 196 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -17355,7 +17494,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 179 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 180 /* Block */) { return; } var bodyBlock = func.body; @@ -17373,10 +17512,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 162 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 163 /* FunctionExpression */) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -17398,10 +17537,9 @@ var ts; if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type) { - signature.resolvedReturnType = resolvingType; + if (!node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); - if (signature.resolvedReturnType === resolvingType) { + if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } @@ -17409,19 +17547,19 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } if (node.body) { - if (node.body.kind === 179 /* Block */) { + if (node.body.kind === 180 /* Block */) { checkSourceElement(node.body); } else { @@ -17463,17 +17601,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 155 /* PropertyAccessExpression */: { + case 156 /* 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 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17482,11 +17620,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65 /* Identifier */: - case 155 /* PropertyAccessExpression */: { + case 156 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; } - case 156 /* ElementAccessExpression */: { + case 157 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { @@ -17496,7 +17634,7 @@ var ts; } return false; } - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -17647,7 +17785,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 224 /* PropertyAssignment */ || p.kind === 225 /* ShorthandPropertyAssignment */) { + if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_8 = p.name; var type = sourceType.flags & 1 /* Any */ ? sourceType : @@ -17675,8 +17813,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175 /* OmittedExpression */) { - if (e.kind !== 173 /* SpreadElementExpression */) { + if (e.kind !== 176 /* OmittedExpression */) { + if (e.kind !== 174 /* SpreadElementExpression */) { var propName = "" + i; var type = sourceType.flags & 1 /* Any */ ? sourceType : isTupleLikeType(sourceType) @@ -17700,7 +17838,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 169 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 170 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17713,14 +17851,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 169 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 154 /* ObjectLiteralExpression */) { + if (target.kind === 155 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 153 /* ArrayLiteralExpression */) { + if (target.kind === 154 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17740,7 +17878,7 @@ var ts; checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 154 /* ObjectLiteralExpression */ || node.left.kind === 153 /* ArrayLiteralExpression */)) { + if (operator === 53 /* EqualsToken */ && (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -17952,7 +18090,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -17963,7 +18101,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -17997,7 +18135,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 126 /* QualifiedName */) { + if (node.kind == 127 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -18009,9 +18147,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 156 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 65 /* Identifier */ || node.kind === 127 /* 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); } @@ -18038,54 +18176,54 @@ var ts; return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 155 /* PropertyAccessExpression */: + case 156 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return checkCallExpression(node); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: return checkClassExpression(node); - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 165 /* TypeOfExpression */: + case 166 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 164 /* DeleteExpression */: + case 165 /* DeleteExpression */: return checkDeleteExpression(node); - case 166 /* VoidExpression */: + case 167 /* VoidExpression */: return checkVoidExpression(node); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 168 /* PostfixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 173 /* SpreadElementExpression */: + case 174 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 175 /* OmittedExpression */: + case 176 /* OmittedExpression */: return undefinedType; - case 172 /* YieldExpression */: + case 173 /* YieldExpression */: checkYieldExpression(node); return unknownType; } @@ -18118,7 +18256,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 135 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 136 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18133,12 +18271,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 140 /* IndexSignature */) { + if (node.kind === 141 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 142 /* FunctionType */ || node.kind === 200 /* FunctionDeclaration */ || node.kind === 143 /* ConstructorType */ || - node.kind === 138 /* CallSignature */ || node.kind === 135 /* Constructor */ || - node.kind === 139 /* ConstructSignature */) { + else if (node.kind === 143 /* FunctionType */ || node.kind === 201 /* FunctionDeclaration */ || node.kind === 144 /* ConstructorType */ || + node.kind === 139 /* CallSignature */ || node.kind === 136 /* Constructor */ || + node.kind === 140 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -18150,10 +18288,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 138 /* CallSignature */: + case 139 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18162,7 +18300,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 202 /* InterfaceDeclaration */) { + if (node.kind === 203 /* 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 @@ -18182,7 +18320,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 121 /* StringKeyword */: + case 122 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18190,7 +18328,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 119 /* NumberKeyword */: + case 120 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18234,17 +18372,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 157 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 158 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 154 /* ObjectLiteralExpression */: return false; + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 155 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -18252,12 +18390,12 @@ var ts; if (n.kind === 93 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 162 /* FunctionExpression */ && n.kind !== 200 /* FunctionDeclaration */) { + else if (n.kind !== 163 /* FunctionExpression */ && n.kind !== 201 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 132 /* PropertyDeclaration */ && + return n.kind === 133 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -18274,7 +18412,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 182 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 183 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -18292,7 +18430,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 136 /* GetAccessor */) { + if (node.kind === 137 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -18300,7 +18438,7 @@ var ts; 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 === 136 /* GetAccessor */ ? 137 /* SetAccessor */ : 136 /* GetAccessor */; + var otherKind = node.kind === 137 /* GetAccessor */ ? 138 /* SetAccessor */ : 137 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -18317,7 +18455,7 @@ var ts; } } } - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + getTypeOfAccessors(getSymbolOfNode(node)); } checkFunctionLikeDeclaration(node); } @@ -18326,16 +18464,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrHeritageClauseElement(node); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkHeritageClauseElement(node) { - checkGrammarHeritageClauseElementInStrictMode(node.expression); - return checkTypeReferenceOrHeritageClauseElement(node); + function checkExpressionWithTypeArguments(node) { + checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); + return checkTypeReferenceOrExpressionWithTypeArguments(node); } - function checkTypeReferenceOrHeritageClauseElement(node) { + function checkTypeReferenceOrExpressionWithTypeArguments(node) { // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrHeritageClauseElement(node); + var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved var len = node.typeArguments.length; @@ -18397,9 +18535,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 === 202 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 138 /* CallSignature */ || signatureDeclarationNode.kind === 139 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 138 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 139 /* CallSignature */ || signatureDeclarationNode.kind === 140 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 139 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18417,7 +18555,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 202 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 203 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -18500,7 +18638,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */); + ts.Debug.assert(node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18529,7 +18667,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 202 /* InterfaceDeclaration */ || node.parent.kind === 145 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 203 /* InterfaceDeclaration */ || node.parent.kind === 146 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -18540,7 +18678,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 === 200 /* FunctionDeclaration */ || node.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */ || node.kind === 135 /* Constructor */) { + if (node.kind === 201 /* FunctionDeclaration */ || node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */ || node.kind === 136 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18663,16 +18801,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18687,23 +18825,23 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 129 /* Parameter */: + case 130 /* Parameter */: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } @@ -18713,7 +18851,7 @@ 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 === 141 /* TypeReference */) { + if (node && node.kind === 142 /* TypeReference */) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.separateCompilation; if (!type || (!shouldCheckIfUnknownType && type.flags & (1048703 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { @@ -18730,19 +18868,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 129 /* Parameter */: + case 130 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 134 /* MethodDeclaration */: + case 135 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 137 /* SetAccessor */: + case 138 /* SetAccessor */: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -18768,25 +18906,25 @@ 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 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 134 /* MethodDeclaration */: + case 135 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 137 /* SetAccessor */: - case 136 /* GetAccessor */: - case 132 /* PropertyDeclaration */: - case 129 /* Parameter */: + case 138 /* SetAccessor */: + case 137 /* GetAccessor */: + case 133 /* PropertyDeclaration */: + case 130 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 129 /* Parameter */) { + if (node.kind === 130 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18809,7 +18947,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 127 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 128 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -18845,11 +18983,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 179 /* Block */) { + if (node.kind === 180 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 206 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 207 /* ModuleBlock */) { checkFunctionExpressionBodies(node); } } @@ -18868,12 +19006,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 132 /* PropertyDeclaration */ || - node.kind === 131 /* PropertySignature */ || - node.kind === 134 /* MethodDeclaration */ || - node.kind === 133 /* MethodSignature */ || - node.kind === 136 /* GetAccessor */ || - node.kind === 137 /* SetAccessor */) { + if (node.kind === 133 /* PropertyDeclaration */ || + node.kind === 132 /* PropertySignature */ || + node.kind === 135 /* MethodDeclaration */ || + node.kind === 134 /* MethodSignature */ || + node.kind === 137 /* GetAccessor */ || + node.kind === 138 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -18882,7 +19020,7 @@ var ts; return false; } var root = getRootDeclaration(node); - if (root.kind === 129 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 130 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -18915,7 +19053,7 @@ var ts; return; } // bubble up and find containing type - var enclosingClass = ts.getAncestor(node, 201 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; @@ -18935,14 +19073,14 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 205 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 206 /* 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 === 227 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 228 /* SourceFile */ && ts.isExternalModule(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_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { @@ -18975,7 +19113,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 === 198 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 199 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -18985,17 +19123,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 199 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 180 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 181 /* 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 === 179 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 206 /* ModuleBlock */ || - container.kind === 205 /* ModuleDeclaration */ || - container.kind === 227 /* SourceFile */); + (container.kind === 180 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 207 /* ModuleBlock */ || + container.kind === 206 /* ModuleDeclaration */ || + container.kind === 228 /* 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 @@ -19009,14 +19147,14 @@ var ts; } } function isParameterDeclaration(node) { - while (node.kind === 152 /* BindingElement */) { + while (node.kind === 153 /* BindingElement */) { node = node.parent.parent; } - return node.kind === 129 /* Parameter */; + return node.kind === 130 /* Parameter */; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (getRootDeclaration(node).kind !== 129 /* Parameter */) { + if (getRootDeclaration(node).kind !== 130 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -19027,7 +19165,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 === 129 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 130 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19054,7 +19192,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19065,7 +19203,7 @@ 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 && getRootDeclaration(node).kind === 129 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && getRootDeclaration(node).kind === 130 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19097,10 +19235,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 132 /* PropertyDeclaration */ && node.kind !== 131 /* PropertySignature */) { + if (node.kind !== 133 /* PropertyDeclaration */ && node.kind !== 132 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 198 /* VariableDeclaration */ || node.kind === 152 /* BindingElement */) { + if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19130,7 +19268,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 179 /* Block */ || node.kind === 154 /* ObjectLiteralExpression */) { + if (node.kind === 180 /* Block */ || node.kind === 155 /* ObjectLiteralExpression */) { return true; } node = node.parent; @@ -19163,12 +19301,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 199 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind == 200 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19188,14 +19326,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 === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* 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 === 153 /* ArrayLiteralExpression */ || varExpr.kind === 154 /* ObjectLiteralExpression */) { + if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* 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. @@ -19224,7 +19362,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 === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* 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); @@ -19238,7 +19376,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 === 153 /* ArrayLiteralExpression */ || varExpr.kind === 154 /* ObjectLiteralExpression */) { + if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!allConstituentTypesHaveKind(leftType, 1 /* Any */ | 258 /* StringLike */)) { @@ -19438,7 +19576,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 136 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 137 /* SetAccessor */))); + return !!(node.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -19453,11 +19591,11 @@ var ts; if (func) { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); var exprType = checkExpressionCached(node.expression); - if (func.kind === 137 /* SetAccessor */) { + if (func.kind === 138 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else { - if (func.kind === 135 /* Constructor */) { + if (func.kind === 136 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19487,7 +19625,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 221 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 222 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19499,7 +19637,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 220 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 221 /* 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. @@ -19520,7 +19658,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 194 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 195 /* 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; @@ -19590,7 +19728,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 201 /* ClassDeclaration */) { + if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 202 /* ClassDeclaration */) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -19628,7 +19766,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 === 127 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 128 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19686,7 +19824,7 @@ var ts; function checkClassDeclaration(node) { checkGrammarDeclarationNameInStrictMode(node); // Grammar checking - if (node.parent.kind !== 206 /* ModuleBlock */ && node.parent.kind !== 227 /* SourceFile */) { + if (node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); } if (!node.name && !(node.flags & 256 /* Default */)) { @@ -19706,11 +19844,11 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedHeritageClauseElement(baseTypeNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkHeritageClauseElement(baseTypeNode); + checkExpressionWithTypeArguments(baseTypeNode); } var baseTypes = getBaseTypes(type); if (baseTypes.length) { @@ -19732,12 +19870,12 @@ var ts; var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { - if (!ts.isSupportedHeritageClauseElement(typeRefNode)) { + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(typeRefNode); + checkExpressionWithTypeArguments(typeRefNode); if (produceDiagnostics) { - var t = getTypeFromHeritageClauseElement(typeRefNode); + var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { @@ -19823,7 +19961,7 @@ var ts; } } function isAccessor(kind) { - return kind === 136 /* GetAccessor */ || kind === 137 /* SetAccessor */; + return kind === 137 /* GetAccessor */ || kind === 138 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19893,7 +20031,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 202 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203 /* 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); @@ -19912,10 +20050,10 @@ var ts; } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedHeritageClauseElement(heritageElement)) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkHeritageClauseElement(heritageElement); + checkExpressionWithTypeArguments(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -19937,7 +20075,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 127 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 128 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -19977,7 +20115,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -19988,7 +20126,7 @@ var ts; case 47 /* TildeToken */: return ~value; } return undefined; - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20013,11 +20151,11 @@ var ts; return undefined; case 7 /* NumericLiteral */: return +e.text; - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return evalConstant(e.expression); case 65 /* Identifier */: - case 156 /* ElementAccessExpression */: - case 155 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 156 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -20030,7 +20168,7 @@ var ts; } else { var expression; - if (e.kind === 156 /* ElementAccessExpression */) { + if (e.kind === 157 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -20048,7 +20186,7 @@ var ts; if (current.kind === 65 /* Identifier */) { break; } - else if (current.kind === 155 /* PropertyAccessExpression */) { + else if (current.kind === 156 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -20117,7 +20255,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 !== 204 /* EnumDeclaration */) { + if (declaration.kind !== 205 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -20140,8 +20278,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 201 /* ClassDeclaration */ || - (declaration.kind === 200 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 202 /* ClassDeclaration */ || + (declaration.kind === 201 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20181,15 +20319,15 @@ var ts; var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); } else if (node.pos < firstNonAmbientClassOrFunc.pos) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } // 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, 201 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 202 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; @@ -20198,10 +20336,10 @@ var ts; // Checks for ambient external modules. if (node.name.kind === 8 /* StringLiteral */) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } if (isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name); + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } } @@ -20209,10 +20347,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 126 /* QualifiedName */) { + if (node.kind === 127 /* QualifiedName */) { node = node.left; } - else if (node.kind === 155 /* PropertyAccessExpression */) { + else if (node.kind === 156 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -20228,11 +20366,11 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 206 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 227 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 215 /* ExportDeclaration */ ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module : - ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 216 /* 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 && isExternalModuleNameRelative(moduleName.text)) { @@ -20240,7 +20378,7 @@ var ts; // 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_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } return true; @@ -20253,7 +20391,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 === 217 /* ExportSpecifier */ ? + var message = node.kind === 218 /* 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)); @@ -20276,7 +20414,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -20325,16 +20463,16 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 206 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 227 /* SourceFile */ && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { // export * from "foo" var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } @@ -20346,9 +20484,9 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 227 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 205 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); + var container = node.parent.kind === 228 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 206 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } // Grammar checking @@ -20362,16 +20500,22 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if (node.isExportEquals && languageVersion >= 2 /* ES6 */) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (languageVersion >= 2 /* ES6 */) { + // export assignment is deprecated in es6 or above + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } + else if (compilerOptions.module === 4 /* System */) { + // system modules does not support export assignment + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } } } function getModuleStatements(node) { - if (node.kind === 227 /* SourceFile */) { + if (node.kind === 228 /* SourceFile */) { return node.statements; } - if (node.kind === 205 /* ModuleDeclaration */ && node.body.kind === 206 /* ModuleBlock */) { + if (node.kind === 206 /* ModuleDeclaration */ && node.body.kind === 207 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -20400,107 +20544,107 @@ var ts; if (!node) return; switch (node.kind) { - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: return checkTypeParameter(node); - case 129 /* Parameter */: + case 130 /* Parameter */: return checkParameter(node); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return checkPropertyDeclaration(node); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: return checkSignatureDeclaration(node); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return checkMethodDeclaration(node); - case 135 /* Constructor */: + case 136 /* Constructor */: return checkConstructorDeclaration(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return checkAccessorDeclaration(node); - case 141 /* TypeReference */: + case 142 /* TypeReference */: return checkTypeReferenceNode(node); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return checkTypeQuery(node); - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: return checkTypeLiteral(node); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return checkArrayType(node); - case 147 /* TupleType */: + case 148 /* TupleType */: return checkTupleType(node); - case 148 /* UnionType */: + case 149 /* UnionType */: return checkUnionType(node); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return checkSourceElement(node.type); - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return checkBlock(node); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return checkVariableStatement(node); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return checkExpressionStatement(node); - case 183 /* IfStatement */: + case 184 /* IfStatement */: return checkIfStatement(node); - case 184 /* DoStatement */: + case 185 /* DoStatement */: return checkDoStatement(node); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: return checkWhileStatement(node); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return checkForStatement(node); - case 187 /* ForInStatement */: + case 188 /* ForInStatement */: return checkForInStatement(node); - case 188 /* ForOfStatement */: + case 189 /* ForOfStatement */: return checkForOfStatement(node); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return checkReturnStatement(node); - case 192 /* WithStatement */: + case 193 /* WithStatement */: return checkWithStatement(node); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return checkSwitchStatement(node); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return checkLabeledStatement(node); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: return checkThrowStatement(node); - case 196 /* TryStatement */: + case 197 /* TryStatement */: return checkTryStatement(node); - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 152 /* BindingElement */: + case 153 /* BindingElement */: return checkBindingElement(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return checkClassDeclaration(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return checkImportDeclaration(node); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return checkExportDeclaration(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return checkExportAssignment(node); - case 181 /* EmptyStatement */: + case 182 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 197 /* DebuggerStatement */: + case 198 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 218 /* MissingDeclaration */: + case 219 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -20515,81 +20659,81 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 192 /* WithStatement */: + case 193 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 129 /* Parameter */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: - case 152 /* BindingElement */: - case 153 /* ArrayLiteralExpression */: - case 154 /* ObjectLiteralExpression */: - case 224 /* PropertyAssignment */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 159 /* TaggedTemplateExpression */: - case 171 /* TemplateExpression */: - case 176 /* TemplateSpan */: - case 160 /* TypeAssertionExpression */: - case 161 /* ParenthesizedExpression */: - case 165 /* TypeOfExpression */: - case 166 /* VoidExpression */: - case 164 /* DeleteExpression */: - case 167 /* PrefixUnaryExpression */: - case 168 /* PostfixUnaryExpression */: - case 169 /* BinaryExpression */: - case 170 /* ConditionalExpression */: - case 173 /* SpreadElementExpression */: - case 179 /* Block */: - case 206 /* ModuleBlock */: - case 180 /* VariableStatement */: - case 182 /* ExpressionStatement */: - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: - case 191 /* ReturnStatement */: - case 193 /* SwitchStatement */: - case 207 /* CaseBlock */: - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - case 194 /* LabeledStatement */: - case 195 /* ThrowStatement */: - case 196 /* TryStatement */: - case 223 /* CatchClause */: - case 198 /* VariableDeclaration */: - case 199 /* VariableDeclarationList */: - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 214 /* ExportAssignment */: - case 227 /* SourceFile */: + case 130 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: + case 153 /* BindingElement */: + case 154 /* ArrayLiteralExpression */: + case 155 /* ObjectLiteralExpression */: + case 225 /* PropertyAssignment */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 160 /* TaggedTemplateExpression */: + case 172 /* TemplateExpression */: + case 178 /* TemplateSpan */: + case 161 /* TypeAssertionExpression */: + case 162 /* ParenthesizedExpression */: + case 166 /* TypeOfExpression */: + case 167 /* VoidExpression */: + case 165 /* DeleteExpression */: + case 168 /* PrefixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: + case 170 /* BinaryExpression */: + case 171 /* ConditionalExpression */: + case 174 /* SpreadElementExpression */: + case 180 /* Block */: + case 207 /* ModuleBlock */: + case 181 /* VariableStatement */: + case 183 /* ExpressionStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: + case 192 /* ReturnStatement */: + case 194 /* SwitchStatement */: + case 208 /* CaseBlock */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: + case 195 /* LabeledStatement */: + case 196 /* ThrowStatement */: + case 197 /* TryStatement */: + case 224 /* CatchClause */: + case 199 /* VariableDeclaration */: + case 200 /* VariableDeclarationList */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 215 /* ExportAssignment */: + case 228 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -20652,7 +20796,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 192 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 193 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -20675,23 +20819,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 162 /* FunctionExpression */: + case 163 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -20729,22 +20873,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 162 /* FunctionExpression */: + case 163 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -20763,64 +20907,64 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 128 /* TypeParameter */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: + case 129 /* TypeParameter */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* 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 === 126 /* QualifiedName */) { + while (node.parent && node.parent.kind === 127 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 141 /* TypeReference */; + return node.parent && node.parent.kind === 142 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 155 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 156 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 177 /* HeritageClauseElement */; + return node.parent && node.parent.kind === 177 /* ExpressionWithTypeArguments */; } function isTypeNode(node) { - if (141 /* FirstTypeNode */ <= node.kind && node.kind <= 149 /* LastTypeNode */) { + if (142 /* FirstTypeNode */ <= node.kind && node.kind <= 150 /* LastTypeNode */) { return true; } switch (node.kind) { case 112 /* AnyKeyword */: - case 119 /* NumberKeyword */: - case 121 /* StringKeyword */: + case 120 /* NumberKeyword */: + case 122 /* StringKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: return true; case 99 /* VoidKeyword */: - return node.parent.kind !== 166 /* VoidExpression */; + return node.parent.kind !== 167 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 129 /* Parameter */; - case 177 /* HeritageClauseElement */: + return node.parent.kind === 130 /* Parameter */; + case 177 /* ExpressionWithTypeArguments */: return true; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 65 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 126 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 126 /* QualifiedName */: - case 155 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */ || node.kind === 155 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_5 = node.parent; - if (parent_5.kind === 144 /* TypeQuery */) { + if (parent_5.kind === 145 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -20829,38 +20973,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 (141 /* FirstTypeNode */ <= parent_5.kind && parent_5.kind <= 149 /* LastTypeNode */) { + if (142 /* FirstTypeNode */ <= parent_5.kind && parent_5.kind <= 150 /* LastTypeNode */) { return true; } switch (parent_5.kind) { - case 177 /* HeritageClauseElement */: + case 177 /* ExpressionWithTypeArguments */: return true; - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: return node === parent_5.constraint; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: return node === parent_5.type; - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 135 /* Constructor */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 136 /* Constructor */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return node === parent_5.type; - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: return node === parent_5.type; - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return node === parent_5.type; - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return parent_5.typeArguments && ts.indexOf(parent_5.typeArguments, node) >= 0; - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -20868,13 +21012,13 @@ var ts; return false; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 126 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 127 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 208 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 209 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 214 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 215 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20886,11 +21030,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 214 /* ExportAssignment */) { + if (entityName.parent.kind === 215 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 155 /* PropertyAccessExpression */) { + if (entityName.kind !== 156 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -20900,7 +21044,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 /* HeritageClauseElement */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 177 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } @@ -20915,14 +21059,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 155 /* PropertyAccessExpression */) { + else if (entityName.kind === 156 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 126 /* QualifiedName */) { + else if (entityName.kind === 127 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20931,7 +21075,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 141 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 142 /* 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 */; @@ -20950,14 +21094,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 214 /* ExportAssignment */ + return node.parent.kind === 215 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65 /* Identifier */: - case 155 /* PropertyAccessExpression */: - case 126 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: @@ -20966,7 +21110,7 @@ var ts; case 114 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 135 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 136 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -20975,14 +21119,14 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 209 /* ImportDeclaration */ || node.parent.kind === 215 /* ExportDeclaration */) && + ((node.parent.kind === 210 /* ImportDeclaration */ || node.parent.kind === 216 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Intentional fall-through case 7 /* NumericLiteral */: // index access - if (node.parent.kind == 156 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind == 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20999,7 +21143,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 225 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 226 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -21079,7 +21223,7 @@ var ts; } // Emitter support function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 227 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228 /* SourceFile */; } function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { // If this is es6 or higher, just use the name of the export @@ -21089,7 +21233,7 @@ var ts; } var node = getDeclarationOfAliasSymbol(symbol); if (node) { - if (node.kind === 210 /* ImportClause */) { + if (node.kind === 211 /* ImportClause */) { var defaultKeyword; if (languageVersion === 0 /* ES3 */) { defaultKeyword = "[\"default\"]"; @@ -21099,7 +21243,7 @@ var ts; } return getGeneratedNameForNode(node.parent) + defaultKeyword; } - if (node.kind === 213 /* ImportSpecifier */) { + if (node.kind === 214 /* ImportSpecifier */) { var moduleName = getGeneratedNameForNode(node.parent.parent.parent); var propertyName = node.propertyName || node.name; return moduleName + "." + ts.unescapeIdentifier(propertyName.text); @@ -21108,9 +21252,11 @@ var ts; } function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { if (isExternalModuleSymbol(symbol.parent)) { - // If this is es6 or higher, just use the name of the export + // 1. If this is es6 or higher, just use the name of the export // no need to qualify it. - if (languageVersion >= 2 /* ES6 */) { + // 2. export mechanism for System modules is different from CJS\AMD + // and it does not need qualifications for exports + if (languageVersion >= 2 /* ES6 */ || compilerOptions.module === 4 /* System */) { return undefined; } return "exports." + ts.unescapeIdentifier(symbol.name); @@ -21118,7 +21264,7 @@ var ts; var node = location; var containerSymbol = getParentOfSymbol(symbol); while (node) { - if ((node.kind === 205 /* ModuleDeclaration */ || node.kind === 204 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { + if ((node.kind === 206 /* ModuleDeclaration */ || node.kind === 205 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); } node = node.parent; @@ -21147,22 +21293,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 227 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 228 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -21220,7 +21366,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 226 /* EnumMember */) { + if (node.kind === 227 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21265,7 +21411,7 @@ var ts; // * The serialized type of a TypeReference with a value declaration is its entity name. // * The serialized type of a TypeReference with a call or construct signature is "Function". // * The serialized type of any other type is "Object". - var type = getTypeFromTypeReference(node); + var type = getTypeFromTypeNode(node); if (type.flags & 16 /* Void */) { return "void 0"; } @@ -21313,26 +21459,26 @@ var ts; switch (node.kind) { case 99 /* VoidKeyword */: return "void 0"; - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: return "Function"; - case 146 /* ArrayType */: - case 147 /* TupleType */: + case 147 /* ArrayType */: + case 148 /* TupleType */: return "Array"; case 113 /* BooleanKeyword */: return "Boolean"; - case 121 /* StringKeyword */: + case 122 /* StringKeyword */: case 8 /* StringLiteral */: return "String"; - case 119 /* NumberKeyword */: + case 120 /* NumberKeyword */: return "Number"; - case 141 /* TypeReference */: + case 142 /* TypeReference */: return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 144 /* TypeQuery */: - case 145 /* TypeLiteral */: - case 148 /* UnionType */: + case 145 /* TypeQuery */: + case 146 /* TypeLiteral */: + case 149 /* UnionType */: case 112 /* AnyKeyword */: break; default: @@ -21355,11 +21501,11 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 201 /* ClassDeclaration */: return "Function"; - case 132 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 129 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 136 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 202 /* ClassDeclaration */: return "Function"; + case 133 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 130 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 137 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); + case 138 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); } if (ts.isFunctionLike(node)) { return "Function"; @@ -21376,7 +21522,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -21391,10 +21537,10 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 146 /* ArrayType */) { + if (parameterType.kind === 147 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 141 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 142 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -21442,15 +21588,21 @@ var ts; ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); return !!resolveName(location, name, 107455 /* Value */, undefined, undefined); } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 152 /* BindingElement */ || (n.parent.kind === 198 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 153 /* BindingElement */ || (n.parent.kind === 199 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 223 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 224 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -21489,6 +21641,7 @@ var ts; resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, + getReferencedValueDeclaration: getReferencedValueDeclaration, serializeTypeOfNode: serializeTypeOfNode, serializeParameterTypesOfNode: serializeParameterTypesOfNode, serializeReturnTypeOfNode: serializeReturnTypeOfNode @@ -21545,12 +21698,12 @@ var ts; function isReservedWordInStrictMode(node) { // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word return (node.parserContextFlags & 1 /* StrictMode */) && - (node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); + (102 /* FirstFutureReservedWord */ <= node.originalKeywordKind && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); } function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) // if so, we would like to give more explicit invalid usage error. - if (ts.getAncestor(identifier, 201 /* ClassDeclaration */) || ts.getAncestor(identifier, 174 /* ClassExpression */)) { + if (ts.getAncestor(identifier, 202 /* ClassDeclaration */) || ts.getAncestor(identifier, 175 /* ClassExpression */)) { return grammarErrorOnNode(identifier, message, arg0); } return false; @@ -21561,19 +21714,19 @@ var ts; var impotClause = node.importClause; if (impotClause.namedBindings) { var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 211 /* NamespaceImport */) { + if (nameBindings.kind === 212 /* NamespaceImport */) { var name_11 = nameBindings.name; - if (name_11.originalKeywordKind) { + if (isReservedWordInStrictMode(name_11)) { var nameText = ts.declarationNameToString(name_11); return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } } - else if (nameBindings.kind === 212 /* NamedImports */) { + else if (nameBindings.kind === 213 /* NamedImports */) { var reportError = false; for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { var element = _a[_i]; var name_12 = element.name; - if (name_12.originalKeywordKind) { + if (isReservedWordInStrictMode(name_12)) { var nameText = ts.declarationNameToString(name_12); reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -21589,23 +21742,23 @@ var ts; if (name && name.kind === 65 /* Identifier */ && isReservedWordInStrictMode(name)) { var nameText = ts.declarationNameToString(name); switch (node.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 200 /* FunctionDeclaration */: - case 128 /* TypeParameter */: - case 152 /* BindingElement */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: + case 201 /* FunctionDeclaration */: + case 129 /* TypeParameter */: + case 153 /* BindingElement */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* EnumDeclaration */: return checkGrammarIdentifierInStrictMode(name); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: // Report an error if the class declaration uses strict-mode reserved word. return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: // Report an error if the module declaration uses strict-mode reserved word. // TODO(yuisu): fix this when having external module in strict mode return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: // TODO(yuisu): fix this when having external module in strict mode return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -21621,7 +21774,7 @@ var ts; if (typeName.kind === 65 /* Identifier */) { checkGrammarTypeNameInStrictMode(typeName); } - else if (typeName.kind === 126 /* QualifiedName */) { + else if (typeName.kind === 127 /* QualifiedName */) { // Walk from right to left and report a possible error at each Identifier in QualifiedName // Example: // x1: public.private.package // error at public and private @@ -21635,18 +21788,18 @@ var ts; // public // error at public // public.private.package // error at public // B.private.B // no error - function checkGrammarHeritageClauseElementInStrictMode(expression) { + function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { // Example: // class C extends public // error at public if (expression && expression.kind === 65 /* Identifier */) { return checkGrammarIdentifierInStrictMode(expression); } - else if (expression && expression.kind === 155 /* PropertyAccessExpression */) { + else if (expression && expression.kind === 156 /* PropertyAccessExpression */) { // Walk from left to right in PropertyAccessExpression until we are at the left most expression // in PropertyAccessExpression. According to grammar production of MemberExpression, // the left component expression is a PrimaryExpression (i.e. Identifier) while the other // component after dots can be IdentifierName. - checkGrammarHeritageClauseElementInStrictMode(expression.expression); + checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); } } // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. @@ -21683,7 +21836,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 136 /* GetAccessor */ || node.kind === 137 /* SetAccessor */) { + else if (node.kind === 137 /* GetAccessor */ || node.kind === 138 /* 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); @@ -21693,26 +21846,26 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 140 /* IndexSignature */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: - case 180 /* VariableStatement */: - case 200 /* FunctionDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 215 /* ExportDeclaration */: - case 214 /* ExportAssignment */: - case 129 /* Parameter */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 141 /* IndexSignature */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: + case 181 /* VariableStatement */: + case 201 /* FunctionDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 216 /* ExportDeclaration */: + case 215 /* ExportAssignment */: + case 130 /* Parameter */: break; default: return false; @@ -21746,7 +21899,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 206 /* ModuleBlock */ || node.parent.kind === 227 /* SourceFile */) { + else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -21755,10 +21908,10 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 206 /* ModuleBlock */ || node.parent.kind === 227 /* SourceFile */) { + else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 129 /* Parameter */) { + else if (node.kind === 130 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; @@ -21771,10 +21924,10 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 129 /* Parameter */) { + else if (node.kind === 130 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -21783,13 +21936,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 129 /* Parameter */) { + else if (node.kind === 130 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 206 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -21797,7 +21950,7 @@ var ts; break; } } - if (node.kind === 135 /* Constructor */) { + if (node.kind === 136 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21808,13 +21961,13 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 209 /* ImportDeclaration */ || node.kind === 208 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 202 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 203 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } - else if (node.kind === 129 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 130 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -21878,7 +22031,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 163 /* ArrowFunction */) { + if (node.kind === 164 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21913,7 +22066,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 /* StringKeyword */ && parameter.type.kind !== 119 /* NumberKeyword */) { + if (parameter.type.kind !== 122 /* StringKeyword */ && parameter.type.kind !== 120 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21946,7 +22099,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 175 /* OmittedExpression */) { + if (arg.kind === 176 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -22020,11 +22173,11 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 127 /* ComputedPropertyName */) { + if (node.kind !== 128 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 169 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 170 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -22052,8 +22205,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_13 = prop.name; - if (prop.kind === 175 /* OmittedExpression */ || - name_13.kind === 127 /* ComputedPropertyName */) { + if (prop.kind === 176 /* OmittedExpression */ || + name_13.kind === 128 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_13); continue; @@ -22067,7 +22220,7 @@ 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 === 224 /* PropertyAssignment */ || prop.kind === 225 /* ShorthandPropertyAssignment */) { + if (prop.kind === 225 /* PropertyAssignment */ || prop.kind === 226 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_13.kind === 7 /* NumericLiteral */) { @@ -22075,13 +22228,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 134 /* MethodDeclaration */) { + else if (prop.kind === 135 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 136 /* GetAccessor */) { + else if (prop.kind === 137 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 137 /* SetAccessor */) { + else if (prop.kind === 138 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -22115,24 +22268,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 199 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 200 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 187 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 188 /* 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 = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 187 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 188 /* 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 === 187 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 188 /* 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); @@ -22155,10 +22308,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 136 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 137 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 137 /* SetAccessor */) { + else if (kind === 138 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22183,7 +22336,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 127 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 128 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22193,7 +22346,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 154 /* ObjectLiteralExpression */) { + if (node.parent.kind === 155 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22201,7 +22354,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.kind === 202 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22217,22 +22370,22 @@ 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 === 202 /* InterfaceDeclaration */) { + else if (node.parent.kind === 203 /* 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 === 145 /* TypeLiteral */) { + else if (node.parent.kind === 146 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: return true; - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22244,11 +22397,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 194 /* LabeledStatement */: + case 195 /* 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 === 189 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 190 /* ContinueStatement */ && !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); @@ -22256,8 +22409,8 @@ var ts; return false; } break; - case 193 /* SwitchStatement */: - if (node.kind === 190 /* BreakStatement */ && !node.label) { + case 194 /* SwitchStatement */: + if (node.kind === 191 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -22272,13 +22425,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 190 /* BreakStatement */ + var message = node.kind === 191 /* 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 === 190 /* BreakStatement */ + var message = node.kind === 191 /* 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); @@ -22287,10 +22440,10 @@ var ts; function checkGrammarBindingElement(node) { if (node.dotDotDotToken) { var elements = node.parent.elements; - if (node !== elements[elements.length - 1]) { + 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 === 151 /* ArrayBindingPattern */ || node.name.kind === 150 /* ObjectBindingPattern */) { + if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22303,7 +22456,7 @@ var ts; return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 187 /* ForInStatement */ && node.parent.parent.kind !== 188 /* ForOfStatement */) { + if (node.parent.parent.kind !== 188 /* ForInStatement */ && node.parent.parent.kind !== 189 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -22340,7 +22493,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 175 /* OmittedExpression */) { + if (element.kind !== 176 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22357,15 +22510,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 183 /* IfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 192 /* WithStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 184 /* IfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 193 /* WithStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: return false; - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22381,7 +22534,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 167 /* PrefixUnaryExpression */) { + if (expression.kind === 168 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; @@ -22410,7 +22563,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 === 127 /* ComputedPropertyName */) { + if (node.name.kind === 128 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -22483,18 +22636,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.kind === 202 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 202 /* InterfaceDeclaration */) { + else if (node.parent.kind === 203 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 145 /* TypeLiteral */) { + else if (node.parent.kind === 146 /* 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; } @@ -22514,11 +22667,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 202 /* InterfaceDeclaration */ || - node.kind === 209 /* ImportDeclaration */ || - node.kind === 208 /* ImportEqualsDeclaration */ || - node.kind === 215 /* ExportDeclaration */ || - node.kind === 214 /* ExportAssignment */ || + if (node.kind === 203 /* InterfaceDeclaration */ || + node.kind === 210 /* ImportDeclaration */ || + node.kind === 209 /* ImportEqualsDeclaration */ || + node.kind === 216 /* ExportDeclaration */ || + node.kind === 215 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 256 /* Default */))) { return false; @@ -22528,7 +22681,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 === 180 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 181 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22554,7 +22707,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 === 179 /* Block */ || node.parent.kind === 206 /* ModuleBlock */ || node.parent.kind === 227 /* SourceFile */) { + if (node.parent.kind === 180 /* Block */ || node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -22644,7 +22797,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 209 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 210 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22720,10 +22873,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 198 /* VariableDeclaration */) { + if (declaration.kind === 199 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 212 /* NamedImports */ || declaration.kind === 213 /* ImportSpecifier */ || declaration.kind === 210 /* ImportClause */) { + else if (declaration.kind === 213 /* NamedImports */ || declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 211 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22741,7 +22894,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 === 209 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 210 /* 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; @@ -22751,12 +22904,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 205 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 205 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22849,41 +23002,41 @@ var ts; function emitType(type) { switch (type.kind) { case 112 /* AnyKeyword */: - case 121 /* StringKeyword */: - case 119 /* NumberKeyword */: + case 122 /* StringKeyword */: + case 120 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 122 /* SymbolKeyword */: + case 123 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 177 /* HeritageClauseElement */: - return emitHeritageClauseElement(type); - case 141 /* TypeReference */: + case 177 /* ExpressionWithTypeArguments */: + return emitExpressionWithTypeArguments(type); + case 142 /* TypeReference */: return emitTypeReference(type); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return emitTypeQuery(type); - case 146 /* ArrayType */: + case 147 /* ArrayType */: return emitArrayType(type); - case 147 /* TupleType */: + case 148 /* TupleType */: return emitTupleType(type); - case 148 /* UnionType */: + case 149 /* UnionType */: return emitUnionType(type); - case 149 /* ParenthesizedType */: + case 150 /* ParenthesizedType */: return emitParenType(type); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 145 /* TypeLiteral */: + case 146 /* TypeLiteral */: return emitTypeLiteral(type); case 65 /* Identifier */: return emitEntityName(type); - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: return emitEntityName(type); } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 208 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 209 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -22891,17 +23044,17 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 126 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 126 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 127 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 127 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } } - function emitHeritageClauseElement(node) { - if (ts.isSupportedHeritageClauseElement(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 155 /* PropertyAccessExpression */); + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 156 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -23013,10 +23166,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 208 /* ImportEqualsDeclaration */ || - (node.parent.kind === 227 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 209 /* ImportEqualsDeclaration */ || + (node.parent.kind === 228 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 227 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -23026,7 +23179,7 @@ var ts; }); } else { - if (node.kind === 209 /* ImportDeclaration */) { + if (node.kind === 210 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -23044,23 +23197,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return writeVariableStatement(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return writeClassDeclaration(node); - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -23076,7 +23229,7 @@ var ts; if (node.flags & 256 /* Default */) { write("default "); } - else if (node.kind !== 202 /* InterfaceDeclaration */) { + else if (node.kind !== 203 /* InterfaceDeclaration */) { write("declare "); } } @@ -23122,7 +23275,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 211 /* NamespaceImport */) { + if (namedBindings.kind === 212 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -23150,7 +23303,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -23203,7 +23356,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 206 /* ModuleBlock */) { + while (node.body.kind !== 207 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -23264,7 +23417,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 134 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 135 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23275,15 +23428,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 === 142 /* FunctionType */ || - node.parent.kind === 143 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 145 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 134 /* MethodDeclaration */ || - node.parent.kind === 133 /* MethodSignature */ || - node.parent.kind === 142 /* FunctionType */ || - node.parent.kind === 143 /* ConstructorType */ || - node.parent.kind === 138 /* CallSignature */ || - node.parent.kind === 139 /* ConstructSignature */); + if (node.parent.kind === 143 /* FunctionType */ || + node.parent.kind === 144 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 146 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 135 /* MethodDeclaration */ || + node.parent.kind === 134 /* MethodSignature */ || + node.parent.kind === 143 /* FunctionType */ || + node.parent.kind === 144 /* ConstructorType */ || + node.parent.kind === 139 /* CallSignature */ || + node.parent.kind === 140 /* ConstructSignature */); emitType(node.constraint); } else { @@ -23294,31 +23447,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 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 138 /* CallSignature */: + case 139 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.parent.flags & 128 /* 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 === 201 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 202 /* 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 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23343,13 +23496,13 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - if (ts.isSupportedHeritageClauseElement(node)) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 201 /* ClassDeclaration */) { + if (node.parent.parent.kind === 202 /* 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 : @@ -23430,7 +23583,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 !== 198 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 199 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -23440,10 +23593,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 132 /* PropertyDeclaration */ || node.kind === 131 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 132 /* PropertyDeclaration */ || node.kind === 131 /* PropertySignature */) && node.parent.kind === 145 /* TypeLiteral */) { + if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && node.parent.kind === 146 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -23452,14 +23605,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 198 /* VariableDeclaration */) { + if (node.kind === 199 /* 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 === 132 /* PropertyDeclaration */ || node.kind === 131 /* PropertySignature */) { + else if (node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -23468,7 +23621,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 === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* 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 : @@ -23500,7 +23653,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 175 /* OmittedExpression */) { + if (element.kind !== 176 /* OmittedExpression */) { elements.push(element); } } @@ -23570,7 +23723,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 === 136 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 137 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23583,7 +23736,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 136 /* GetAccessor */ + return accessor.kind === 137 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -23592,7 +23745,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 137 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 138 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -23642,17 +23795,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 200 /* FunctionDeclaration */) { + if (node.kind === 201 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 134 /* MethodDeclaration */) { + else if (node.kind === 135 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 200 /* FunctionDeclaration */) { + if (node.kind === 201 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 135 /* Constructor */) { + else if (node.kind === 136 /* Constructor */) { write("constructor"); } else { @@ -23670,11 +23823,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 139 /* ConstructSignature */ || node.kind === 143 /* ConstructorType */) { + if (node.kind === 140 /* ConstructSignature */ || node.kind === 144 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 140 /* IndexSignature */) { + if (node.kind === 141 /* IndexSignature */) { write("["); } else { @@ -23684,22 +23837,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 140 /* IndexSignature */) { + if (node.kind === 141 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 142 /* FunctionType */ || node.kind === 143 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 145 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 143 /* FunctionType */ || node.kind === 144 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 146 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 135 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 136 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23710,26 +23863,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 139 /* ConstructSignature */: + case 140 /* 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 138 /* CallSignature */: + case 139 /* 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 140 /* IndexSignature */: + case 141 /* 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 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -23737,7 +23890,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 === 201 /* ClassDeclaration */) { + else if (node.parent.kind === 202 /* 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 : @@ -23751,7 +23904,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 200 /* FunctionDeclaration */: + case 201 /* 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 : @@ -23786,9 +23939,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 142 /* FunctionType */ || - node.parent.kind === 143 /* ConstructorType */ || - node.parent.parent.kind === 145 /* TypeLiteral */) { + if (node.parent.kind === 143 /* FunctionType */ || + node.parent.kind === 144 /* ConstructorType */ || + node.parent.parent.kind === 146 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -23804,24 +23957,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 135 /* Constructor */: + case 136 /* 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 139 /* ConstructSignature */: + case 140 /* 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 138 /* CallSignature */: + case 139 /* 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 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -23829,7 +23982,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 === 201 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 202 /* 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 : @@ -23842,7 +23995,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 200 /* FunctionDeclaration */: + case 201 /* 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 : @@ -23854,12 +24007,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 === 150 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 151 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 151 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 152 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23878,7 +24031,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 175 /* OmittedExpression */) { + if (bindingElement.kind === 176 /* 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) @@ -23887,7 +24040,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 152 /* BindingElement */) { + else if (bindingElement.kind === 153 /* 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" @@ -23928,40 +24081,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 202 /* InterfaceDeclaration */: - case 201 /* ClassDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: + case 201 /* FunctionDeclaration */: + case 206 /* ModuleDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 203 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return emitExportDeclaration(node); - case 135 /* Constructor */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 136 /* Constructor */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return writeFunctionDeclaration(node); - case 139 /* ConstructSignature */: - case 138 /* CallSignature */: - case 140 /* IndexSignature */: + case 140 /* ConstructSignature */: + case 139 /* CallSignature */: + case 141 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return emitAccessorDeclaration(node); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return emitPropertyDeclaration(node); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return emitExportAssignment(node); - case 227 /* SourceFile */: + case 228 /* SourceFile */: return emitSourceFile(node); } } @@ -24018,21 +24171,20 @@ var ts; TempFlags[TempFlags["Auto"] = 0] = "Auto"; TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; TempFlags[TempFlags["_i"] = 268435456] = "_i"; - TempFlags[TempFlags["_n"] = 536870912] = "_n"; })(TempFlags || (TempFlags = {})); // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; // emit output for the __decorate helper function - var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function - var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\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};"; // emit output for the __param helper function - var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; - var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); if (targetSourceFile === undefined) { @@ -24090,6 +24242,13 @@ var ts; var increaseIndent = writer.increaseIndent; var decreaseIndent = writer.decreaseIndent; var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; var blockScopedVariableToGeneratedName; @@ -24129,7 +24288,7 @@ var ts; var scopeEmitEnd = function () { }; /** Sourcemap data that will get encoded */ var sourceMapData; - if (compilerOptions.sourceMap) { + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } if (root) { @@ -24148,6 +24307,7 @@ var ts; return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; + exportFunctionForFile = undefined; emit(sourceFile); } function isUniqueName(name) { @@ -24234,25 +24394,25 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: + case 201 /* FunctionDeclaration */: + case 202 /* ClassDeclaration */: + case 175 /* ClassExpression */: generateNameForFunctionOrClassDeclaration(node); break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: generateNameForModuleOrEnum(node); generateNameForNode(node.body); break; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: generateNameForModuleOrEnum(node); break; - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: generateNameForImportDeclaration(node); break; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: generateNameForExportDeclaration(node); break; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: generateNameForExportAssignment(node); break; } @@ -24272,7 +24432,7 @@ var ts; var sourceMapNameIndexMap = {}; var sourceMapNameIndices = []; function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; } // Last recorded and encoded spans var lastRecordedSourceMapSpan; @@ -24408,6 +24568,12 @@ var ts; sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; // The one that can be used from program to get the actual source file sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } } function recordScopeNameOfNode(node, scopeName) { function recordScopeNameIndex(scopeNameIndex) { @@ -24422,7 +24588,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_17 = node.name; - if (!name_17 || name_17.kind !== 127 /* ComputedPropertyName */) { + if (!name_17 || name_17.kind !== 128 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -24440,20 +24606,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 200 /* FunctionDeclaration */ || - node.kind === 162 /* FunctionExpression */ || - node.kind === 134 /* MethodDeclaration */ || - node.kind === 133 /* MethodSignature */ || - node.kind === 136 /* GetAccessor */ || - node.kind === 137 /* SetAccessor */ || - node.kind === 205 /* ModuleDeclaration */ || - node.kind === 201 /* ClassDeclaration */ || - node.kind === 204 /* EnumDeclaration */) { + else if (node.kind === 201 /* FunctionDeclaration */ || + node.kind === 163 /* FunctionExpression */ || + node.kind === 135 /* MethodDeclaration */ || + node.kind === 134 /* MethodSignature */ || + node.kind === 137 /* GetAccessor */ || + node.kind === 138 /* SetAccessor */ || + node.kind === 206 /* ModuleDeclaration */ || + node.kind === 202 /* ClassDeclaration */ || + node.kind === 205 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_18 = node.name; // For computed property names, the text will include the brackets - scopeName = name_18.kind === 127 /* ComputedPropertyName */ + scopeName = name_18.kind === 128 /* ComputedPropertyName */ ? ts.getTextOfNode(name_18) : node.name.text; } @@ -24473,18 +24639,22 @@ var ts; ts.writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { if (typeof JSON !== "undefined") { - return JSON.stringify({ + var map_1 = { version: version, file: file, sourceRoot: sourceRoot, sources: sources, names: names, mappings: mappings - }); + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; function serializeStringArray(list) { var output = ""; for (var i = 0, n = list.length; i < n; i++) { @@ -24497,12 +24667,22 @@ var ts; } } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - // Write source map file encodeLastRecordedSourceMapSpan(); - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + // Write source map file + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); } // Initialize source map data var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); @@ -24515,6 +24695,7 @@ var ts; inputSourceFileNames: [], sourceMapNames: [], sourceMapMappings: "", + sourceMapSourcesContent: undefined, sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -24548,7 +24729,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node, false); } - if (node.kind != 227 /* SourceFile */) { + if (node.kind != 228 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); @@ -24722,7 +24903,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if (compilerOptions.sourceMap && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -24811,10 +24992,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 171 /* TemplateExpression */) { + if (node.template.kind === 172 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 169 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 170 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -24849,7 +25030,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 161 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 162 /* 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 @@ -24891,11 +25072,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return parent.expression === template; - case 159 /* TaggedTemplateExpression */: - case 161 /* ParenthesizedExpression */: + case 160 /* TaggedTemplateExpression */: + case 162 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -24916,7 +25097,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 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 35 /* AsteriskToken */: case 36 /* SlashToken */: @@ -24928,8 +25109,8 @@ var ts; default: return -1 /* LessThan */; } - case 172 /* YieldExpression */: - case 170 /* ConditionalExpression */: + case 173 /* YieldExpression */: + case 171 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -24944,11 +25125,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 !== 152 /* BindingElement */); + ts.Debug.assert(node.kind !== 153 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 127 /* ComputedPropertyName */) { + else if (node.kind === 128 /* 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: @@ -24992,36 +25173,36 @@ var ts; function isNotExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 200 /* FunctionDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: + case 227 /* EnumMember */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 206 /* ModuleDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: return parent.name === node; - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: return parent.name === node || parent.propertyName === node; - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 214 /* ExportAssignment */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 215 /* ExportAssignment */: return false; - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return node.parent.label === node; } } @@ -25129,11 +25310,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: - case 153 /* ArrayLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 161 /* ParenthesizedExpression */: + case 154 /* ArrayLiteralExpression */: + case 156 /* PropertyAccessExpression */: + case 157 /* ElementAccessExpression */: + case 158 /* CallExpression */: + case 162 /* 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; @@ -25153,14 +25334,14 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 173 /* SpreadElementExpression */) { + if (e.kind === 174 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { var i = pos; - while (i < length && elements[i].kind !== 173 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 174 /* SpreadElementExpression */) { i++; } write("["); @@ -25181,7 +25362,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 173 /* SpreadElementExpression */; + return node.kind === 174 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -25251,7 +25432,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 136 /* GetAccessor */ || property.kind === 137 /* SetAccessor */) { + if (property.kind === 137 /* GetAccessor */ || property.kind === 138 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -25303,13 +25484,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 224 /* PropertyAssignment */) { + if (property.kind === 225 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 225 /* ShorthandPropertyAssignment */) { + else if (property.kind === 226 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 134 /* MethodDeclaration */) { + else if (property.kind === 135 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -25343,7 +25524,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 === 127 /* ComputedPropertyName */) { + if (properties[i].name.kind === 128 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -25359,21 +25540,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(169 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(170 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(155 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(156 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(156 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(157 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -25387,10 +25568,10 @@ var ts; // NumberLiteral // 1.x -> not the same as (1).x // - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 158 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { + if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(161 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -25454,7 +25635,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 155 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 156 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -25506,10 +25687,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 173 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 174 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 161 /* ParenthesizedExpression */ || node.kind === 160 /* TypeAssertionExpression */) { + while (node.kind === 162 /* ParenthesizedExpression */ || node.kind === 161 /* TypeAssertionExpression */) { node = node.expression; } return node; @@ -25530,13 +25711,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 155 /* PropertyAccessExpression */) { + if (expr.kind === 156 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 156 /* ElementAccessExpression */) { + else if (expr.kind === 157 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -25581,7 +25762,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 155 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 156 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -25618,12 +25799,12 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 163 /* ArrowFunction */) { - if (node.expression.kind === 160 /* TypeAssertionExpression */) { + if (!node.parent || node.parent.kind !== 164 /* ArrowFunction */) { + if (node.expression.kind === 161 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == 160 /* TypeAssertionExpression */) { + while (operand.kind == 161 /* TypeAssertionExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -25634,14 +25815,14 @@ 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 !== 167 /* PrefixUnaryExpression */ && - operand.kind !== 166 /* VoidExpression */ && - operand.kind !== 165 /* TypeOfExpression */ && - operand.kind !== 164 /* DeleteExpression */ && - operand.kind !== 168 /* PostfixUnaryExpression */ && - operand.kind !== 158 /* NewExpression */ && - !(operand.kind === 157 /* CallExpression */ && node.parent.kind === 158 /* NewExpression */) && - !(operand.kind === 162 /* FunctionExpression */ && node.parent.kind === 157 /* CallExpression */)) { + if (operand.kind !== 168 /* PrefixUnaryExpression */ && + operand.kind !== 167 /* VoidExpression */ && + operand.kind !== 166 /* TypeOfExpression */ && + operand.kind !== 165 /* DeleteExpression */ && + operand.kind !== 169 /* PostfixUnaryExpression */ && + operand.kind !== 159 /* NewExpression */ && + !(operand.kind === 158 /* CallExpression */ && node.parent.kind === 159 /* NewExpression */) && + !(operand.kind === 163 /* FunctionExpression */ && node.parent.kind === 158 /* CallExpression */)) { emit(operand); return; } @@ -25666,7 +25847,27 @@ var ts; write(" "); emit(node.expression); } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 /* VariableDeclaration */ || node.parent.kind === 153 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } write(ts.tokenToString(node.operator)); // In some cases, we need to emit a space between the operator and the operand. One obvious case // is when the operator is an identifier, like delete or typeof. We also need to do this for plus @@ -25680,7 +25881,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 === 167 /* PrefixUnaryExpression */) { + if (node.operand.kind === 168 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); @@ -25690,23 +25891,87 @@ var ts; } } emit(node.operand); + if (exportChanged) { + write(")"); + } } function emitPostfixUnaryExpression(node) { - emit(node.operand); - write(ts.tokenToString(node.operator)); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 38 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 228 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 207 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 154 /* ObjectLiteralExpression */ || node.left.kind === 153 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 182 /* ExpressionStatement */); + (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 183 /* ExpressionStatement */); } else { + var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && + node.operatorToken.kind <= 64 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } emit(node.left); var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (exportChanged) { + write(")"); + } } } function synthesizedNodeStartsOnNewLine(node) { @@ -25738,7 +26003,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 179 /* Block */) { + if (node && node.kind === 180 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -25753,12 +26018,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 206 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 205 /* ModuleDeclaration */); + if (node.kind === 207 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 206 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 206 /* ModuleBlock */) { + if (node.kind === 207 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -25767,7 +26032,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 179 /* Block */) { + if (node.kind === 180 /* Block */) { write(" "); emit(node); } @@ -25779,7 +26044,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 163 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 164 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -25792,7 +26057,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 183 /* IfStatement */) { + if (node.elseStatement.kind === 184 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -25804,7 +26069,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 179 /* Block */) { + if (node.statement.kind === 180 /* Block */) { write(" "); } else { @@ -25820,7 +26085,15 @@ var ts; write(")"); emitEmbeddedStatement(node.statement); } - function emitStartOfVariableDeclarationList(decl, startPos) { + /* Returns true if start of variable declaration list was emitted. + * Return false if nothing was written - this can happen for source file level variable declarations + * in system modules - such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + // variables in variable declaration list were already hoisted + return false; + } var tokenKind = 98 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { @@ -25832,28 +26105,53 @@ var ts; } if (startPos !== undefined) { emitToken(tokenKind, startPos); + write(" "); } else { switch (tokenKind) { case 98 /* VarKeyword */: - return write("var "); + write("var "); + break; case 104 /* LetKeyword */: - return write("let "); + write("let "); + break; case 70 /* ConstKeyword */: - return write("const "); + write("const "); + break; } } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; } function emitForStatement(node) { var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 200 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; - var declarations = variableDeclarationList.declarations; - emitStartOfVariableDeclarationList(declarations[0], endPos); - write(" "); - emitCommaList(declarations); + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } } else if (node.initializer) { emit(node.initializer); @@ -25866,25 +26164,23 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 188 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 189 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - emitStartOfVariableDeclarationList(decl, endPos); - write(" "); - emit(decl); + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); } } else { emit(node.initializer); } - if (node.kind === 187 /* ForInStatement */) { + if (node.kind === 188 /* ForInStatement */) { write(" in "); } else { @@ -25969,7 +26265,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 199 /* VariableDeclarationList */) { + if (node.initializer.kind === 200 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25999,7 +26295,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, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 153 /* ArrayLiteralExpression */ || node.initializer.kind === 154 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 154 /* ArrayLiteralExpression */ || node.initializer.kind === 155 /* 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, true, undefined); @@ -26010,7 +26306,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 179 /* Block */) { + if (node.statement.kind === 180 /* Block */) { emitLines(node.statement.statements); } else { @@ -26022,7 +26318,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 190 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -26067,7 +26363,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 220 /* CaseClause */) { + if (node.kind === 221 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -26122,7 +26418,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 205 /* ModuleDeclaration */); + } while (node && node.kind !== 206 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -26137,7 +26433,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2 /* ES6 */) { + else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); } } @@ -26147,7 +26443,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(166 /* VoidExpression */); + var result = ts.createSynthesizedNode(167 /* VoidExpression */); result.expression = zero; return result; } @@ -26155,19 +26451,35 @@ var ts; if (node.flags & 1 /* Export */) { writeLine(); emitStart(node); - if (node.flags & 256 /* Default */) { - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); + if (compilerOptions.module === 4 /* System */) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 256 /* Default */) { + write("default"); } else { - write("exports.default"); + emitNodeWithoutSourceMap(node.name); } + write("\", "); + emitDeclarationName(node); + write(")"); } else { - emitModuleMemberName(node); + if (node.flags & 256 /* Default */) { + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); } - write(" = "); - emitDeclarationName(node); emitEnd(node); write(";"); } @@ -26177,13 +26489,24 @@ var ts; for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); + if (compilerOptions.module === 4 /* System */) { + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(specifier.name); + write("\", "); + emitExpressionIdentifier(name); + write(")"); + emitEnd(specifier.name); + } + else { + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + } write(";"); } } @@ -26192,8 +26515,18 @@ var ts; var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so // temporary variables in an exported declaration need to have real declarations elsewhere - var isDeclaration = (root.kind === 198 /* VariableDeclaration */ && !(ts.getCombinedNodeFlags(root) & 1 /* Export */)) || root.kind === 129 /* Parameter */; - if (root.kind === 169 /* BinaryExpression */) { + // 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 === 199 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 130 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 170 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -26205,7 +26538,14 @@ var ts; write(", "); } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === 198 /* VariableDeclaration */ || name.parent.kind === 152 /* BindingElement */)) { + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 /* VariableDeclaration */ || name.parent.kind === 153 /* BindingElement */); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(name); + write("\", "); + } + if (isVariableDeclarationOrBindingElement) { emitModuleMemberName(name.parent); } else { @@ -26213,11 +26553,14 @@ var ts; } write(" = "); emit(value); + if (exportChanged) { + write(")"); + } } function ensureIdentifier(expr) { if (expr.kind !== 65 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); - if (!isDeclaration) { + if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -26230,14 +26573,14 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(169 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(170 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(170 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(171 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -26257,7 +26600,7 @@ var ts; return createPropertyAccessExpression(object, propName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(157 /* CallExpression */); + var call = ts.createSynthesizedNode(158 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -26274,7 +26617,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 224 /* PropertyAssignment */ || p.kind === 225 /* ShorthandPropertyAssignment */) { + if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var propName = (p.name); emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); @@ -26290,8 +26633,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 175 /* OmittedExpression */) { - if (e.kind !== 173 /* SpreadElementExpression */) { + if (e.kind !== 176 /* OmittedExpression */) { + if (e.kind !== 174 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26301,14 +26644,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 169 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 154 /* ObjectLiteralExpression */) { + if (target.kind === 155 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 153 /* ArrayLiteralExpression */) { + else if (target.kind === 154 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -26322,14 +26665,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 161 /* ParenthesizedExpression */) { + if (root.parent.kind !== 162 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 161 /* ParenthesizedExpression */) { + if (root.parent.kind !== 162 /* ParenthesizedExpression */) { write(")"); } } @@ -26353,12 +26696,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 150 /* ObjectBindingPattern */) { + if (pattern.kind === 151 /* 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 !== 175 /* OmittedExpression */) { + else if (element.kind !== 176 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -26386,7 +26729,6 @@ var ts; } else { renameNonTopLevelLetAndConst(node.name); - emitModuleMemberName(node); var initializer = node.initializer; if (!initializer && languageVersion < 2 /* ES6 */) { // downlevel emit for non-initialized let bindings defined in loops @@ -26399,16 +26741,26 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 187 /* ForInStatement */ && - node.parent.parent.kind !== 188 /* ForOfStatement */) { + node.parent.parent.kind !== 188 /* ForInStatement */ && + node.parent.parent.kind !== 189 /* ForOfStatement */) { initializer = createVoidZero(); } } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } } } function emitExportVariableAssignments(node) { - if (node.kind === 175 /* OmittedExpression */) { + if (node.kind === 176 /* OmittedExpression */) { return; } var name = node.name; @@ -26420,7 +26772,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -26435,7 +26787,7 @@ var ts; if (languageVersion >= 2 /* ES6 */ || ts.nodeIsSynthesized(node) || node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { + (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { return; } var combinedFlags = getCombinedFlagsForIdentifier(node); @@ -26444,17 +26796,17 @@ var ts; return; } // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 199 /* VariableDeclarationList */); - if (list.parent.kind === 180 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 227 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 206 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 179 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); + var list = ts.getAncestor(node, 200 /* VariableDeclarationList */); + if (list.parent.kind === 181 /* VariableStatement */) { + var isSourceFileLevelBinding = list.parent.parent.kind === 228 /* SourceFile */; + var isModuleLevelBinding = list.parent.parent.kind === 207 /* ModuleBlock */; + var isFunctionLevelBinding = list.parent.parent.kind === 180 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { return; } } var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 227 /* SourceFile */ + var parent = blockScopeContainer.kind === 228 /* SourceFile */ ? blockScopeContainer : blockScopeContainer.parent; if (resolver.resolvesToSomeValue(parent, node.text)) { @@ -26469,19 +26821,28 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 227 /* SourceFile */; + node.parent.kind === 228 /* SourceFile */; } function emitVariableStatement(node) { + var startIsEmitted = true; if (!(node.flags & 1 /* Export */)) { - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); } else if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } } - emitCommaList(node.declarationList.declarations); - write(";"); if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } @@ -26585,12 +26946,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 136 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 137 /* GetAccessor */ ? "get " : "set "); emit(node.name, false); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 163 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 164 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -26601,11 +26962,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 162 /* FunctionExpression */) { + if (node.kind === 163 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 200 /* FunctionDeclaration */) { + if (node.kind === 201 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -26614,7 +26975,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -26637,10 +26998,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 200 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { emitTrailingComments(node); } } @@ -26691,7 +27052,7 @@ var ts; // in that case. write(" { }"); } - else if (node.body.kind === 179 /* Block */) { + else if (node.body.kind === 180 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -26722,10 +27083,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 160 /* TypeAssertionExpression */) { + while (current.kind === 161 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 154 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 155 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26801,9 +27162,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 182 /* ExpressionStatement */) { + if (statement && statement.kind === 183 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 157 /* CallExpression */) { + if (expr && expr.kind === 158 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 91 /* SuperKeyword */) { return statement; @@ -26835,7 +27196,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 127 /* ComputedPropertyName */) { + else if (memberName.kind === 128 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -26843,11 +27204,11 @@ var ts; emitNodeWithoutSourceMap(memberName); } } - function getInitializedProperties(node, static) { + function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 132 /* PropertyDeclaration */ && static === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -26887,11 +27248,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 178 /* SemicolonClassElement */) { + if (member.kind === 179 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) { + else if (member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -26910,7 +27271,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 136 /* GetAccessor */ || member.kind === 137 /* SetAccessor */) { + else if (member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26960,22 +27321,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) && !member.body) { + if ((member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 134 /* MethodDeclaration */ || - member.kind === 136 /* GetAccessor */ || - member.kind === 137 /* SetAccessor */) { + else if (member.kind === 135 /* MethodDeclaration */ || + member.kind === 137 /* GetAccessor */ || + member.kind === 138 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 136 /* GetAccessor */) { + if (member.kind === 137 /* GetAccessor */) { write("get "); } - else if (member.kind === 137 /* SetAccessor */) { + else if (member.kind === 138 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -26986,7 +27347,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 178 /* SemicolonClassElement */) { + else if (member.kind === 179 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -27011,11 +27372,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 135 /* Constructor */ && !member.body) { + if (member.kind === 136 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 132 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 133 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -27123,7 +27484,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* 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: @@ -27203,7 +27564,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, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 174 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -27233,6 +27594,7 @@ var ts; writeLine(); emitToken(15 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. // For a decorated class, we need to assign its name (if it has one). This is because we emit // the class as a class expression to avoid the double-binding of the identifier: // @@ -27242,15 +27604,6 @@ var ts; // if (thisNodeIsDecorated) { write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } } // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration @@ -27295,8 +27648,11 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 201 /* ClassDeclaration */) { - write("var "); + if (node.kind === 202 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } emitDeclarationName(node); write(" = "); } @@ -27351,11 +27707,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 201 /* ClassDeclaration */) { + if (node.kind === 202 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -27447,7 +27803,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 134 /* MethodDeclaration */) { + if (member.kind === 135 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -27485,7 +27841,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 132 /* PropertyDeclaration */) { + if (member.kind !== 133 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27515,7 +27871,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 132 /* PropertyDeclaration */) { + if (member.kind !== 133 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27557,10 +27913,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 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 132 /* PropertyDeclaration */: + case 135 /* MethodDeclaration */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 133 /* PropertyDeclaration */: return true; } return false; @@ -27570,7 +27926,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 134 /* MethodDeclaration */: + case 135 /* MethodDeclaration */: return true; } return false; @@ -27580,9 +27936,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 201 /* ClassDeclaration */: - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: + case 202 /* ClassDeclaration */: + case 135 /* MethodDeclaration */: + case 138 /* SetAccessor */: return true; } return false; @@ -27745,7 +28101,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 205 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27762,7 +28118,9 @@ var ts; if (!shouldEmit) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (!isModuleMergedWithES6Class(node)) { + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -27779,7 +28137,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 206 /* ModuleBlock */) { + if (node.body.kind === 207 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27813,6 +28171,14 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 65 /* Identifier */ && node.parent === currentSourceFile) { + if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -27829,16 +28195,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 208 /* ImportEqualsDeclaration */) { + if (node.kind === 209 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 209 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 210 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27866,7 +28232,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27892,7 +28258,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 208 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 209 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -27911,7 +28277,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 209 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 210 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27979,6 +28345,7 @@ var ts; } } function emitExportDeclaration(node) { + ts.Debug.assert(compilerOptions.module !== 4 /* System */); if (languageVersion < 2 /* ES6 */) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); @@ -28074,8 +28441,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 200 /* FunctionDeclaration */ && - expression.kind !== 201 /* ClassDeclaration */) { + if (expression.kind !== 201 /* FunctionDeclaration */ && + expression.kind !== 202 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -28083,14 +28450,21 @@ var ts; else { writeLine(); emitStart(node); - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); + if (compilerOptions.module === 4 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); } else { - write(".default = "); + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); } - emit(node.expression); write(";"); emitEnd(node); } @@ -28104,7 +28478,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -28114,13 +28488,13 @@ var ts; externalImports.push(node); } break; - case 208 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 219 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 209 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 220 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -28141,7 +28515,7 @@ var ts; } } break; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -28162,6 +28536,476 @@ var ts; write("}"); } } + function getLocalNameForExternalImport(importNode) { + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + else { + return getGeneratedNameForNode(importNode); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 8 /* StringLiteral */) { + return getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 216 /* ExportDeclaration */ || + (importNode.kind === 210 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + if (!hasExportStars) { + // local names set is needed only in presence of star exports + return undefined; + } + // local names set should only be added if we have anything exported + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 216 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + // write name of exported declaration, i.e 'export var x...' + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + // write name of export specified, i.e. 'export {x}' + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 216 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + // define an export star helper function + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") " + exportFunctionForFile + "(n, m[n]);"); + decreaseIndent(); + writeLine(); + write("}"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + // do not record default exports + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 65 /* Identifier */ && node.flags & 256 /* Default */) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 65 /* Identifier */) { + emitNodeWithoutSourceMap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + if (i !== 0) { + write(", "); + } + if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 65 /* Identifier */ ? local.parent : local); + if (flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.kind === 201 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 202 /* ClassDeclaration */) { + // TODO: rename block scoped classes + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 206 /* ModuleDeclaration */ && shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (shouldHoistVariable(node, false)) { + var name_21 = node.name; + if (name_21.kind === 65 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_21); + } + else { + ts.forEachChild(name_21, visit); + } + } + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // 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) & 12288 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 228 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, startIndex) { + // shape of the body in system modules: + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // I.e: + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // will be transformed to + // function(exports) { + // var file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction); + writeLine(); + emitExecute(node, startIndex); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + write("}"); // return + } + function emitSetters(exportStarFunction) { + write("setters:["); + for (var i = 0; i < externalImports.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var importNode = externalImports[i]; + var importVariableName = getLocalNameForExternalImport(importNode) || ""; + var parameterName = "_" + importVariableName; + write("function (" + parameterName + ") {"); + switch (importNode.kind) { + case 210 /* ImportDeclaration */: + if (!importNode.importClause) { + // 'import "..."' case + // module is imported only for side-effects, setter body will be empty + break; + } + // fall-through + case 209 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + var defaultName = importNode.kind === 210 /* ImportDeclaration */ + ? importNode.importClause.name + : importNode.name; + if (defaultName) { + // emit re-export for imported default name + // import n1 from 'foo1' + // import n2 = require('foo2') + // export {n1} + // export {n2} + emitExportMemberAssignments(defaultName); + writeLine(); + } + if (importNode.kind === 210 /* ImportDeclaration */ && + importNode.importClause.namedBindings) { + var namedBindings = importNode.importClause.namedBindings; + if (namedBindings.kind === 212 /* NamespaceImport */) { + // emit re-export for namespace + // import * as n from 'foo' + // export {n} + emitExportMemberAssignments(namedBindings.name); + writeLine(); + } + else { + // emit re-exports for named imports + // import {a, b} from 'foo' + // export {a, b as c} + for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportMemberAssignments(element.name || element.propertyName); + writeLine(); + } + } + } + decreaseIndent(); + break; + case 216 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + if (importNode.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports('a', _foo["a"]) + // exports('c', _foo["b"]) + for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + writeLine(); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(e.name); + write("\", " + parameterName + "[\""); + emitNodeWithoutSourceMap(e.propertyName || e.name); + write("\"]);"); + } + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + decreaseIndent(); + break; + } + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + // - imports/exports are not emitted for system modules + // - function declarations are not emitted because they were already hoisted + switch (statement.kind) { + case 216 /* ExportDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 201 /* FunctionDeclaration */: + continue; + } + writeLine(); + emit(statement); + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node, startIndex) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. + // 'exports' returns its 'value' argument so in most cases expressions + // that mutate exported values can be rewritten as: + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, + // see comment to 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + write("System.register(["); + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } function emitAMDDependencies(node, includeNonAmdDependencies) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); @@ -28178,8 +29022,8 @@ var ts; // factory function. var unaliasedModuleNames = []; // names of modules with no corresponding parameters in // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { @@ -28195,20 +29039,9 @@ var ts; for (var _c = 0; _c < externalImports.length; _c++) { var importNode = externalImports[_c]; // Find the name of the external module - var externalModuleName = ""; - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - externalModuleName = getLiteralText(moduleName); - } + var externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one - var importAliasName = void 0; - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { - importAliasName = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - else { - importAliasName = getGeneratedNameForNode(importNode); - } + var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); @@ -28327,30 +29160,36 @@ var ts; emitDetachedComments(node); // emit prologue directives prior to __extends var startIndex = emitDirectivePrologues(node.statements, false); - // 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 */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); + // Only emit helpers if the user did not say otherwise. + 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 */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; } - decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (ts.isExternalModule(node)) { + if (ts.isExternalModule(node) || compilerOptions.separateCompilation) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); } else if (compilerOptions.module === 2 /* AMD */) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 4 /* System */) { + emitSystemModule(node, startIndex); + } else if (compilerOptions.module === 3 /* UMD */) { emitUMDModule(node, startIndex); } @@ -28389,18 +29228,18 @@ var ts; 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 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 214 /* ExportAssignment */: + case 203 /* InterfaceDeclaration */: + case 201 /* FunctionDeclaration */: + case 210 /* ImportDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 215 /* ExportAssignment */: return false; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -28409,9 +29248,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 !== 179 /* Block */ && + if (node.kind !== 180 /* Block */ && node.parent && - node.parent.kind === 163 /* ArrowFunction */ && + node.parent.kind === 164 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -28425,13 +29264,13 @@ var ts; switch (node.kind) { case 65 /* Identifier */: return emitIdentifier(node, allowGeneratedIdentifiers); - case 129 /* Parameter */: + case 130 /* Parameter */: return emitParameter(node); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return emitMethod(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: return emitAccessor(node); case 93 /* ThisKeyword */: return emitThis(node); @@ -28451,140 +29290,140 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: return emitTemplateExpression(node); - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return emitTemplateSpan(node); - case 126 /* QualifiedName */: + case 127 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ObjectBindingPattern */: + case 151 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 151 /* ArrayBindingPattern */: + case 152 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 152 /* BindingElement */: + case 153 /* BindingElement */: return emitBindingElement(node); - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 224 /* PropertyAssignment */: + case 225 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 225 /* ShorthandPropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 127 /* ComputedPropertyName */: + case 128 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 155 /* PropertyAccessExpression */: + case 156 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 157 /* CallExpression */: + case 158 /* CallExpression */: return emitCallExpression(node); - case 158 /* NewExpression */: + case 159 /* NewExpression */: return emitNewExpression(node); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 160 /* TypeAssertionExpression */: + case 161 /* TypeAssertionExpression */: return emit(node.expression); - case 161 /* ParenthesizedExpression */: + case 162 /* ParenthesizedExpression */: return emitParenExpression(node); - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 164 /* DeleteExpression */: + case 165 /* DeleteExpression */: return emitDeleteExpression(node); - case 165 /* TypeOfExpression */: + case 166 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 166 /* VoidExpression */: + case 167 /* VoidExpression */: return emitVoidExpression(node); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 168 /* PostfixUnaryExpression */: + case 169 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return emitBinaryExpression(node); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return emitConditionalExpression(node); - case 173 /* SpreadElementExpression */: + case 174 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 172 /* YieldExpression */: + case 173 /* YieldExpression */: return emitYieldExpression(node); - case 175 /* OmittedExpression */: + case 176 /* OmittedExpression */: return; - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return emitBlock(node); - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: return emitVariableStatement(node); - case 181 /* EmptyStatement */: + case 182 /* EmptyStatement */: return write(";"); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return emitExpressionStatement(node); - case 183 /* IfStatement */: + case 184 /* IfStatement */: return emitIfStatement(node); - case 184 /* DoStatement */: + case 185 /* DoStatement */: return emitDoStatement(node); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: return emitWhileStatement(node); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return emitForStatement(node); - case 188 /* ForOfStatement */: - case 187 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 188 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: + case 190 /* ContinueStatement */: + case 191 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: return emitReturnStatement(node); - case 192 /* WithStatement */: + case 193 /* WithStatement */: return emitWithStatement(node); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return emitSwitchStatement(node); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: return emitLabelledStatement(node); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: return emitThrowStatement(node); - case 196 /* TryStatement */: + case 197 /* TryStatement */: return emitTryStatement(node); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return emitCatchClause(node); - case 197 /* DebuggerStatement */: + case 198 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 174 /* ClassExpression */: + case 175 /* ClassExpression */: return emitClassExpression(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return emitClassDeclaration(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return emitEnumMember(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: return emitImportDeclaration(node); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: return emitExportDeclaration(node); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: return emitExportAssignment(node); - case 227 /* SourceFile */: + case 228 /* SourceFile */: return emitSourceFileNode(node); } } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -28607,7 +29446,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 === 227 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 228 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -28622,7 +29461,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 === 227 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 228 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -28685,13 +29524,13 @@ var ts; // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); } @@ -28733,6 +29572,8 @@ var ts; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ ts.version = "1.5.0"; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -28806,6 +29647,9 @@ var ts; } } } + var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed : + options.newLine === 1 /* LineFeed */ ? lineFeed : + ts.sys.newLine; return { getSourceFile: getSourceFile, getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, @@ -28813,14 +29657,14 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return ts.sys.newLine; } + getNewLine: function () { return newLine; } }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program) { - var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + function getPreEmitDiagnostics(program, sourceFile) { + var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics()); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -29068,7 +29912,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 209 /* ImportDeclaration */ || node.kind === 208 /* ImportEqualsDeclaration */ || node.kind === 215 /* ExportDeclaration */) { + if (node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */ || node.kind === 216 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -29088,7 +29932,7 @@ var ts; } } } - else if (node.kind === 205 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -29183,6 +30027,22 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation)); } } + if (options.inlineSourceMap) { + if (options.sourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.mapRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.sourceRoot) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { @@ -29202,17 +30062,17 @@ var ts; var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -29279,6 +30139,14 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "inlineSourceMap", + type: "boolean" + }, + { + name: "inlineSources", + type: "boolean" + }, { name: "listFiles", type: "boolean" @@ -29300,17 +30168,32 @@ var ts; type: { "commonjs": 1 /* CommonJS */, "amd": 2 /* AMD */, + "system": 4 /* System */, "umd": 3 /* UMD */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + }, + { + name: "newLine", + type: { + "crlf": 0 /* CarriageReturnLineFeed */, + "lf": 1 /* LineFeed */ + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF }, { name: "noEmit", type: "boolean", description: ts.Diagnostics.Do_not_emit_outputs }, + { + name: "noEmitHelpers", + type: "boolean" + }, { name: "noEmitOnError", type: "boolean", @@ -29531,19 +30414,34 @@ var ts; function readConfigFile(fileName) { try { var text = ts.sys.readFile(fileName); - return /\S/.test(text) ? JSON.parse(text) : {}; } catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } + return parseConfigFileText(fileName, text); } ts.readConfigFile = readConfigFile; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileText(fileName, jsonText) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileText = parseConfigFileText; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseConfigFile(json, basePath) { + function parseConfigFile(json, host, basePath) { var errors = []; return { options: getCompilerOptions(), @@ -29599,7 +30497,7 @@ var ts; } } else { - var sysFiles = ts.sys.readDirectory(basePath, ".ts"); + var sysFiles = host.readDirectory(basePath, ".ts"); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { @@ -29684,7 +30582,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 163 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 164 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -29696,7 +30594,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 179 /* Block */: + case 180 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_6 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); @@ -29704,18 +30602,18 @@ var ts; // 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_6.kind === 184 /* DoStatement */ || - parent_6.kind === 187 /* ForInStatement */ || - parent_6.kind === 188 /* ForOfStatement */ || - parent_6.kind === 186 /* ForStatement */ || - parent_6.kind === 183 /* IfStatement */ || - parent_6.kind === 185 /* WhileStatement */ || - parent_6.kind === 192 /* WithStatement */ || - parent_6.kind === 223 /* CatchClause */) { + if (parent_6.kind === 185 /* DoStatement */ || + parent_6.kind === 188 /* ForInStatement */ || + parent_6.kind === 189 /* ForOfStatement */ || + parent_6.kind === 187 /* ForStatement */ || + parent_6.kind === 184 /* IfStatement */ || + parent_6.kind === 186 /* WhileStatement */ || + parent_6.kind === 193 /* WithStatement */ || + parent_6.kind === 224 /* CatchClause */) { addOutliningSpan(parent_6, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_6.kind === 196 /* TryStatement */) { + if (parent_6.kind === 197 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_6; if (tryStatement.tryBlock === n) { @@ -29742,23 +30640,23 @@ var ts; break; } // Fallthrough. - case 206 /* ModuleBlock */: { + case 207 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 154 /* ObjectLiteralExpression */: - case 207 /* CaseBlock */: { + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 155 /* ObjectLiteralExpression */: + case 208 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -29786,12 +30684,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_21 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_21); + for (var name_22 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_22); 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_21); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_22); if (!matches) { continue; } @@ -29804,14 +30702,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_21); + matches = patternMatcher.getMatches(containers, name_22); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_21, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_22, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -29849,7 +30747,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 127 /* ComputedPropertyName */) { + else if (declaration.name.kind === 128 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -29870,7 +30768,7 @@ var ts; } return true; } - if (expression.kind === 155 /* PropertyAccessExpression */) { + if (expression.kind === 156 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -29883,7 +30781,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 === 127 /* ComputedPropertyName */) { + if (declaration.name.kind === 128 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -29959,17 +30857,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* 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 === 205 /* ModuleDeclaration */); + } while (current.kind === 206 /* ModuleDeclaration */); // fall through - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 203 /* InterfaceDeclaration */: + case 201 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -29980,21 +30878,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 215 /* ExportDeclaration */: + case 216 /* 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 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -30006,7 +30904,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -30015,21 +30913,21 @@ var ts; } } break; - case 152 /* BindingElement */: - case 198 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 199 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 202 /* InterfaceDeclaration */: - case 205 /* ModuleDeclaration */: - case 200 /* FunctionDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 203 /* InterfaceDeclaration */: + case 206 /* ModuleDeclaration */: + case 201 /* FunctionDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 214 /* ImportSpecifier */: + case 218 /* ExportSpecifier */: childNodes.push(node); break; } @@ -30077,17 +30975,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 203 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -30098,12 +30996,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 200 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 201 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 179 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 180 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 200 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -30163,7 +31061,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 129 /* Parameter */: + case 130 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -30171,36 +31069,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 136 /* GetAccessor */: + case 137 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 137 /* SetAccessor */: + case 138 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 226 /* EnumMember */: + case 227 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 138 /* CallSignature */: + case 139 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 139 /* ConstructSignature */: + case 140 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: var variableDeclarationNode; - var name_22; - if (node.kind === 152 /* BindingElement */) { - name_22 = node.name; + var name_23; + if (node.kind === 153 /* BindingElement */) { + name_23 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 198 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 199 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -30208,24 +31106,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_22 = node.name; + name_23 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_23), ts.ScriptElementKind.variableElement); } - case 135 /* Constructor */: + case 136 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 217 /* ExportSpecifier */: - case 213 /* ImportSpecifier */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: + case 218 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -30255,17 +31153,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 227 /* SourceFile */: + case 228 /* SourceFile */: return createSourceFileItem(node); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: return createClassItem(node); - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: return createEnumItem(node); - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return createModuleItem(node); - case 200 /* FunctionDeclaration */: + case 201 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -30277,7 +31175,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 205 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -30289,7 +31187,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 === 179 /* Block */) { + if (node.body && node.body.kind === 180 /* 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)); } @@ -30310,7 +31208,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 135 /* Constructor */ && member; + return member.kind === 136 /* 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 @@ -30334,7 +31232,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 127 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -30343,13 +31241,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 205 /* ModuleDeclaration */) { + while (node.body.kind === 206 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 227 /* SourceFile */ + return node.kind === 228 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -31144,7 +32042,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 157 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 158 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -31152,7 +32050,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 65 /* Identifier */ ? expression - : expression.kind === 155 /* PropertyAccessExpression */ + : expression.kind === 156 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -31185,7 +32083,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 157 /* CallExpression */ || node.parent.kind === 158 /* NewExpression */) { + if (node.parent.kind === 158 /* CallExpression */ || node.parent.kind === 159 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -31238,25 +32136,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 159 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 160 /* 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, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 159 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 160 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 171 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 176 /* TemplateSpan */ && node.parent.parent.parent.kind === 159 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 178 /* TemplateSpan */ && node.parent.parent.parent.kind === 160 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 171 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -31374,7 +32272,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 === 171 /* TemplateExpression */) { + if (template.kind === 172 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -31383,7 +32281,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 227 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 228 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -31584,40 +32482,40 @@ var ts; return false; } switch (n.kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 154 /* ObjectLiteralExpression */: - case 150 /* ObjectBindingPattern */: - case 145 /* TypeLiteral */: - case 179 /* Block */: - case 206 /* ModuleBlock */: - case 207 /* CaseBlock */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 155 /* ObjectLiteralExpression */: + case 151 /* ObjectBindingPattern */: + case 146 /* TypeLiteral */: + case 180 /* Block */: + case 207 /* ModuleBlock */: + case 208 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 158 /* NewExpression */: + case 159 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 157 /* CallExpression */: - case 161 /* ParenthesizedExpression */: - case 149 /* ParenthesizedType */: + case 158 /* CallExpression */: + case 162 /* ParenthesizedExpression */: + case 150 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 142 /* FunctionType */: - case 143 /* ConstructorType */: + case 143 /* FunctionType */: + case 144 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 139 /* ConstructSignature */: - case 138 /* CallSignature */: - case 163 /* ArrowFunction */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 140 /* ConstructSignature */: + case 139 /* CallSignature */: + case 164 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -31627,63 +32525,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 183 /* IfStatement */: + case 184 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 153 /* ArrayLiteralExpression */: - case 151 /* ArrayBindingPattern */: - case 156 /* ElementAccessExpression */: - case 127 /* ComputedPropertyName */: - case 147 /* TupleType */: + case 154 /* ArrayLiteralExpression */: + case 152 /* ArrayBindingPattern */: + case 157 /* ElementAccessExpression */: + case 128 /* ComputedPropertyName */: + case 148 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 140 /* IndexSignature */: + case 141 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 185 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 186 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 184 /* DoStatement */: + case 185 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 144 /* TypeQuery */: + case 145 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 165 /* TypeOfExpression */: - case 164 /* DeleteExpression */: - case 166 /* VoidExpression */: - case 172 /* YieldExpression */: - case 173 /* SpreadElementExpression */: + case 166 /* TypeOfExpression */: + case 165 /* DeleteExpression */: + case 167 /* VoidExpression */: + case 173 /* YieldExpression */: + case 174 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 159 /* TaggedTemplateExpression */: + case 160 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 171 /* TemplateExpression */: + case 172 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 176 /* TemplateSpan */: + case 178 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 167 /* PrefixUnaryExpression */: + case 168 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 169 /* BinaryExpression */: + case 170 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 170 /* ConditionalExpression */: + case 171 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -31697,7 +32595,7 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last = children[children.length - 1]; + var last = ts.lastOrUndefined(children); if (last.kind === expectedLastToken) { return true; } @@ -31739,7 +32637,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 === 228 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 229 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -31873,7 +32771,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 227 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 228 /* 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. @@ -31917,17 +32815,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 141 /* TypeReference */ || node.kind === 157 /* CallExpression */) { + if (node.kind === 142 /* TypeReference */ || node.kind === 158 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 201 /* ClassDeclaration */ || node.kind === 202 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 202 /* ClassDeclaration */ || node.kind === 203 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 125 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 126 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -31982,7 +32880,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 129 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -32191,7 +33089,7 @@ var ts; if (isStarted) { if (trailingTrivia) { ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === 4 /* NewLineTrivia */; + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; } else { wasNewLine = false; @@ -32684,7 +33582,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 120 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 121 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -32692,9 +33590,9 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 118 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 119 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 120 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 118 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 121 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -32714,7 +33612,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 120 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 121 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -32804,9 +33702,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_23 in o) { - if (o[name_23] === rule) { - return name_23; + for (var name_24 in o) { + if (o[name_24] === rule) { + return name_24; } } throw new Error("Unknown rule"); @@ -32815,36 +33713,36 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 186 /* ForStatement */; + return context.contextNode.kind === 187 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 169 /* BinaryExpression */: - case 170 /* ConditionalExpression */: + case 170 /* BinaryExpression */: + case 171 /* ConditionalExpression */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 152 /* BindingElement */: + case 153 /* BindingElement */: // equals in type X = ... - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: // equal in p = 0; - case 129 /* Parameter */: - case 226 /* EnumMember */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 130 /* Parameter */: + case 227 /* EnumMember */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 187 /* ForInStatement */: + case 188 /* ForInStatement */: return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 188 /* ForOfStatement */: - return context.currentTokenSpan.kind === 125 /* OfKeyword */ || context.nextTokenSpan.kind === 125 /* OfKeyword */; + case 189 /* ForOfStatement */: + return context.currentTokenSpan.kind === 126 /* OfKeyword */ || context.nextTokenSpan.kind === 126 /* OfKeyword */; } return false; }; @@ -32852,7 +33750,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 170 /* ConditionalExpression */; + return context.contextNode.kind === 171 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -32896,31 +33794,31 @@ var ts; return true; } switch (node.kind) { - case 179 /* Block */: - case 207 /* CaseBlock */: - case 154 /* ObjectLiteralExpression */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 208 /* CaseBlock */: + case 155 /* ObjectLiteralExpression */: + case 207 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 138 /* CallSignature */: - case 162 /* FunctionExpression */: - case 135 /* Constructor */: - case 163 /* ArrowFunction */: + case 139 /* CallSignature */: + case 163 /* FunctionExpression */: + case 136 /* Constructor */: + case 164 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: return true; } return false; @@ -32930,55 +33828,55 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 145 /* TypeLiteral */: - case 205 /* ModuleDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 146 /* TypeLiteral */: + case 206 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 201 /* ClassDeclaration */: - case 205 /* ModuleDeclaration */: - case 204 /* EnumDeclaration */: - case 179 /* Block */: - case 223 /* CatchClause */: - case 206 /* ModuleBlock */: - case 193 /* SwitchStatement */: + case 202 /* ClassDeclaration */: + case 206 /* ModuleDeclaration */: + case 205 /* EnumDeclaration */: + case 180 /* Block */: + case 224 /* CatchClause */: + case 207 /* ModuleBlock */: + case 194 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 183 /* IfStatement */: - case 193 /* SwitchStatement */: - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 185 /* WhileStatement */: - case 196 /* TryStatement */: - case 184 /* DoStatement */: - case 192 /* WithStatement */: + case 184 /* IfStatement */: + case 194 /* SwitchStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 186 /* WhileStatement */: + case 197 /* TryStatement */: + case 185 /* DoStatement */: + case 193 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 223 /* CatchClause */: + case 224 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 154 /* ObjectLiteralExpression */; + return context.contextNode.kind === 155 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 157 /* CallExpression */; + return context.contextNode.kind === 158 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 158 /* NewExpression */; + return context.contextNode.kind === 159 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -32999,38 +33897,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 130 /* Decorator */; + return node.kind === 131 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 199 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 200 /* 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 === 205 /* ModuleDeclaration */; + return context.contextNode.kind === 206 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 145 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 146 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 141 /* TypeReference */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 142 /* TypeReference */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: return true; default: return false; @@ -33041,7 +33939,7 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 166 /* VoidExpression */; + return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 167 /* VoidExpression */; }; return Rules; })(); @@ -33065,7 +33963,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 125 /* LastToken */ + 1; + this.mapRowLength = 126 /* 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); @@ -33260,7 +34158,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 125 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 126 /* LastToken */; token++) { result.push(token); } return result; @@ -33302,9 +34200,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 125 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 126 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 125 /* OfKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 126 /* OfKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); @@ -33312,7 +34210,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 119 /* NumberKeyword */, 121 /* StringKeyword */, 113 /* BooleanKeyword */, 122 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 120 /* NumberKeyword */, 122 /* StringKeyword */, 113 /* BooleanKeyword */, 123 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -33515,17 +34413,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 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 179 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 227 /* SourceFile */: - case 179 /* Block */: - case 206 /* ModuleBlock */: + return body && body.kind === 180 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 228 /* SourceFile */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -33650,6 +34548,8 @@ var ts; var previousRange; var previousParent; var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -33696,9 +34596,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 227 /* SourceFile */ || - parent.kind === 220 /* CaseClause */ || - parent.kind === 221 /* DefaultClause */) { + parent.kind === 228 /* SourceFile */ || + parent.kind === 221 /* CaseClause */ || + parent.kind === 222 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -33719,7 +34619,9 @@ var ts; // if node is located on the same line with the parent // - inherit indentation from the parent // - push children if either parent of node itself has non-zero delta - indentation = parentDynamicIndentation.getIndentation(); + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); } return { @@ -33732,19 +34634,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 201 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 202 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 200 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 204 /* EnumDeclaration */: return 204 /* EnumDeclaration */; - case 136 /* GetAccessor */: return 116 /* GetKeyword */; - case 137 /* SetAccessor */: return 120 /* SetKeyword */; - case 134 /* MethodDeclaration */: + case 202 /* ClassDeclaration */: return 69 /* ClassKeyword */; + case 203 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; + case 201 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; + case 205 /* EnumDeclaration */: return 205 /* EnumDeclaration */; + case 137 /* GetAccessor */: return 116 /* GetKeyword */; + case 138 /* SetAccessor */: return 121 /* SetKeyword */; + case 135 /* MethodDeclaration */: if (node.asteriskToken) { return 35 /* AsteriskToken */; } // fall-through - case 132 /* PropertyDeclaration */: - case 129 /* Parameter */: + case 133 /* PropertyDeclaration */: + case 130 /* Parameter */: return node.name.kind; } } @@ -33877,7 +34779,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 130 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 131 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -33967,7 +34869,6 @@ var ts; if (!ts.rangeContainsRange(originalRange, triviaItem)) { continue; } - var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); @@ -33991,6 +34892,8 @@ var ts; if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; } } formattingScanner.advance(); @@ -34199,20 +35102,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 179 /* Block */: - case 206 /* ModuleBlock */: + case 180 /* Block */: + case 207 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 135 /* Constructor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 163 /* ArrowFunction */: + case 136 /* Constructor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 164 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -34220,8 +35123,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -34229,7 +35132,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 141 /* TypeReference */: + case 142 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -34328,7 +35231,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 169 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 170 /* 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 */) { @@ -34439,7 +35342,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 === 227 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 228 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -34472,7 +35375,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 183 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 184 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -34484,23 +35387,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 141 /* TypeReference */: + case 142 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 154 /* ObjectLiteralExpression */: + case 155 /* ObjectLiteralExpression */: return node.parent.properties; - case 153 /* ArrayLiteralExpression */: + case 154 /* ArrayLiteralExpression */: return node.parent.elements; - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: { + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -34511,8 +35414,8 @@ var ts; } break; } - case 158 /* NewExpression */: - case 157 /* CallExpression */: { + case 159 /* NewExpression */: + case 158 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -34591,28 +35494,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 153 /* ArrayLiteralExpression */: - case 179 /* Block */: - case 206 /* ModuleBlock */: - case 154 /* ObjectLiteralExpression */: - case 145 /* TypeLiteral */: - case 147 /* TupleType */: - case 207 /* CaseBlock */: - case 221 /* DefaultClause */: - case 220 /* CaseClause */: - case 161 /* ParenthesizedExpression */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: - case 180 /* VariableStatement */: - case 198 /* VariableDeclaration */: - case 214 /* ExportAssignment */: - case 191 /* ReturnStatement */: - case 170 /* ConditionalExpression */: - case 151 /* ArrayBindingPattern */: - case 150 /* ObjectBindingPattern */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 154 /* ArrayLiteralExpression */: + case 180 /* Block */: + case 207 /* ModuleBlock */: + case 155 /* ObjectLiteralExpression */: + case 146 /* TypeLiteral */: + case 148 /* TupleType */: + case 208 /* CaseBlock */: + case 222 /* DefaultClause */: + case 221 /* CaseClause */: + case 162 /* ParenthesizedExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: + case 181 /* VariableStatement */: + case 199 /* VariableDeclaration */: + case 215 /* ExportAssignment */: + case 192 /* ReturnStatement */: + case 171 /* ConditionalExpression */: + case 152 /* ArrayBindingPattern */: + case 151 /* ObjectBindingPattern */: return true; } return false; @@ -34622,22 +35525,22 @@ var ts; return true; } switch (parent) { - case 184 /* DoStatement */: - case 185 /* WhileStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 186 /* ForStatement */: - case 183 /* IfStatement */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 138 /* CallSignature */: - case 163 /* ArrowFunction */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - return child !== 179 /* Block */; + case 185 /* DoStatement */: + case 186 /* WhileStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 187 /* ForStatement */: + case 184 /* IfStatement */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 139 /* CallSignature */: + case 164 /* ArrowFunction */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + return child !== 180 /* Block */; default: return false; } @@ -34647,7 +35550,7 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -34742,7 +35645,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(228 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(229 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -34761,7 +35664,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 126 /* FirstNode */) { + if (this.kind >= 127 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -34806,7 +35709,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 126 /* FirstNode */) { + if (child.kind < 127 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -34816,7 +35719,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 126 /* FirstNode */) { + if (child.kind < 127 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -34869,7 +35772,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 === 129 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 130 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -34878,15 +35781,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 205 /* ModuleDeclaration */ && declaration.body.kind === 205 /* ModuleDeclaration */) { + if (declaration.kind === 206 /* ModuleDeclaration */ && declaration.body.kind === 206 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 205 /* ModuleDeclaration */ && declaration.parent.kind === 205 /* ModuleDeclaration */) { + while (declaration.kind === 206 /* ModuleDeclaration */ && declaration.parent.kind === 206 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 198 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -35225,9 +36128,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 127 /* ComputedPropertyName */) { + if (declaration.name.kind === 128 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 155 /* PropertyAccessExpression */) { + if (expr.kind === 156 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -35247,9 +36150,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -35269,60 +36172,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 217 /* ExportSpecifier */: - case 213 /* ImportSpecifier */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 145 /* TypeLiteral */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 205 /* EnumDeclaration */: + case 206 /* ModuleDeclaration */: + case 209 /* ImportEqualsDeclaration */: + case 218 /* ExportSpecifier */: + case 214 /* ImportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportClause */: + case 212 /* NamespaceImport */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 146 /* TypeLiteral */: addDeclaration(node); // fall through - case 135 /* Constructor */: - case 180 /* VariableStatement */: - case 199 /* VariableDeclarationList */: - case 150 /* ObjectBindingPattern */: - case 151 /* ArrayBindingPattern */: - case 206 /* ModuleBlock */: + case 136 /* Constructor */: + case 181 /* VariableStatement */: + case 200 /* VariableDeclarationList */: + case 151 /* ObjectBindingPattern */: + case 152 /* ArrayBindingPattern */: + case 207 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 179 /* Block */: + case 180 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 129 /* Parameter */: + case 130 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 226 /* EnumMember */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 227 /* EnumMember */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: addDeclaration(node); break; - case 215 /* ExportDeclaration */: + case 216 /* 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 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35334,7 +36237,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 211 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -35393,7 +36296,7 @@ var ts; })(ts.OutputFileType || (ts.OutputFileType = {})); var OutputFileType = ts.OutputFileType; (function (EndOfLineState) { - EndOfLineState[EndOfLineState["Start"] = 0] = "Start"; + EndOfLineState[EndOfLineState["None"] = 0] = "None"; EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; @@ -35495,10 +36398,31 @@ var ts; ClassificationTypeNames.interfaceName = "interface name"; ClassificationTypeNames.moduleName = "module name"; ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAlias = "type alias name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; return ClassificationTypeNames; })(); ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -35512,16 +36436,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 162 /* FunctionExpression */) { + if (declaration.kind === 163 /* FunctionExpression */) { return true; } - if (declaration.kind !== 198 /* VariableDeclaration */ && declaration.kind !== 200 /* FunctionDeclaration */) { + if (declaration.kind !== 199 /* VariableDeclaration */ && declaration.kind !== 201 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_7 = declaration.parent; !ts.isFunctionBlock(parent_7); parent_7 = parent_7.parent) { // Reached source file or module block - if (parent_7.kind === 227 /* SourceFile */ || parent_7.kind === 206 /* ModuleBlock */) { + if (parent_7.kind === 228 /* SourceFile */ || parent_7.kind === 207 /* ModuleBlock */) { return false; } } @@ -35873,7 +36797,7 @@ var ts; else { if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -35883,7 +36807,7 @@ var ts; } else if (token === 53 /* EqualsToken */) { token = scanner.scan(); - if (token === 118 /* RequireKeyword */) { + if (token === 119 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -35912,7 +36836,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -35928,7 +36852,7 @@ var ts; token = scanner.scan(); if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -35951,7 +36875,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -35963,7 +36887,7 @@ var ts; } else if (token === 35 /* AsteriskToken */) { token = scanner.scan(); - if (token === 124 /* FromKeyword */) { + if (token === 125 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -35986,7 +36910,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 194 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 195 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -35995,12 +36919,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 /* Identifier */ && - (node.parent.kind === 190 /* BreakStatement */ || node.parent.kind === 189 /* ContinueStatement */) && + (node.parent.kind === 191 /* BreakStatement */ || node.parent.kind === 190 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 /* Identifier */ && - node.parent.kind === 194 /* LabeledStatement */ && + node.parent.kind === 195 /* LabeledStatement */ && node.parent.label === node; } /** @@ -36008,7 +36932,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 194 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 195 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -36019,25 +36943,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 126 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 155 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 157 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 205 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 206 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 /* Identifier */ && @@ -36046,22 +36970,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 === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 224 /* PropertyAssignment */ || node.parent.kind === 225 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 225 /* PropertyAssignment */ || node.parent.kind === 226 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 205 /* ModuleDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 227 /* EnumMember */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 206 /* ModuleDeclaration */: return node.parent.name === node; - case 156 /* ElementAccessExpression */: + case 157 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -36120,7 +37044,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 125 /* LastKeyword */; i++) { + for (var i = 66 /* FirstKeyword */; i <= 126 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -36135,17 +37059,17 @@ var ts; return undefined; } switch (node.kind) { - case 227 /* SourceFile */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: + case 228 /* SourceFile */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 202 /* ClassDeclaration */: + case 203 /* InterfaceDeclaration */: + case 205 /* EnumDeclaration */: + case 206 /* ModuleDeclaration */: return node; } } @@ -36153,38 +37077,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 205 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 201 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 202 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 203 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 204 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 198 /* VariableDeclaration */: + case 206 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 202 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 203 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 204 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 205 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 199 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 200 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 136 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 137 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 201 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 137 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 138 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 140 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 139 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 138 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 135 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 128 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 226 /* EnumMember */: return ScriptElementKind.variableElement; - case 129 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 208 /* ImportEqualsDeclaration */: - case 213 /* ImportSpecifier */: - case 210 /* ImportClause */: - case 217 /* ExportSpecifier */: - case 211 /* NamespaceImport */: + case 141 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 140 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 139 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 136 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 129 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 227 /* EnumMember */: return ScriptElementKind.variableElement; + case 130 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 209 /* ImportEqualsDeclaration */: + case 214 /* ImportSpecifier */: + case 211 /* ImportClause */: + case 218 /* ExportSpecifier */: + case 212 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -36385,44 +37309,44 @@ var ts; return false; } switch (node.kind) { - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 222 /* HeritageClause */: + case 223 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 102 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 203 /* TypeAliasDeclaration */: + case 204 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 200 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -36430,20 +37354,20 @@ var ts; return true; } break; - case 180 /* VariableStatement */: + case 181 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 198 /* VariableDeclaration */: + case 199 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -36451,7 +37375,7 @@ var ts; return true; } break; - case 129 /* Parameter */: + case 130 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -36467,17 +37391,17 @@ var ts; return true; } break; - case 132 /* PropertyDeclaration */: + case 133 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 160 /* TypeAssertionExpression */: + case 161 /* 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 130 /* Decorator */: + case 131 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -36610,11 +37534,11 @@ var ts; // visible symbols in the scope, and the node is the current location. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 155 /* PropertyAccessExpression */) { + if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 156 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 126 /* QualifiedName */) { + else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 127 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -36641,7 +37565,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */ || node.kind === 155 /* PropertyAccessExpression */) { + if (node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -36683,13 +37607,13 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 210 /* ImportClause */)) { + else if (ts.getAncestor(contextToken, 211 /* ImportClause */)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 209 /* ImportDeclaration */); + var importDeclaration = ts.getAncestor(contextToken, 210 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); var exports; if (importDeclaration.moduleSpecifier) { @@ -36768,7 +37692,7 @@ var ts; // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 212 /* NamedImports */; + return node.parent.kind === 213 /* NamedImports */; } } return false; @@ -36778,35 +37702,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 157 /* CallExpression */ // func( a, | - || containingNodeKind === 135 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 158 /* NewExpression */ // new C(a, | - || containingNodeKind === 153 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 169 /* BinaryExpression */; // let x = (a, | + return containingNodeKind === 158 /* CallExpression */ // func( a, | + || containingNodeKind === 136 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === 159 /* NewExpression */ // new C(a, | + || containingNodeKind === 154 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 170 /* BinaryExpression */; // let x = (a, | case 16 /* OpenParenToken */: - return containingNodeKind === 157 /* CallExpression */ // func( | - || containingNodeKind === 135 /* Constructor */ // constructor( | - || containingNodeKind === 158 /* NewExpression */ // new C(a| - || containingNodeKind === 161 /* ParenthesizedExpression */; // let x = (a| + return containingNodeKind === 158 /* CallExpression */ // func( | + || containingNodeKind === 136 /* Constructor */ // constructor( | + || containingNodeKind === 159 /* NewExpression */ // new C(a| + || containingNodeKind === 162 /* ParenthesizedExpression */; // let x = (a| case 18 /* OpenBracketToken */: - return containingNodeKind === 153 /* ArrayLiteralExpression */; // [ | - case 117 /* ModuleKeyword */: + return containingNodeKind === 154 /* ArrayLiteralExpression */; // [ | + case 117 /* ModuleKeyword */: // module | + case 118 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 205 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 206 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 201 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 202 /* ClassDeclaration */; // class A{ | case 53 /* EqualsToken */: - return containingNodeKind === 198 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 169 /* BinaryExpression */; // x = a| + return containingNodeKind === 199 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 170 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 171 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 172 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 176 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 178 /* TemplateSpan */; // `aa ${10} dd ${| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 132 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 133 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -36842,7 +37767,7 @@ var ts; switch (previousToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_8 && parent_8.kind === 154 /* ObjectLiteralExpression */) { + if (parent_8 && parent_8.kind === 155 /* ObjectLiteralExpression */) { return parent_8; } break; @@ -36852,16 +37777,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 138 /* CallSignature */: - case 139 /* ConstructSignature */: - case 140 /* IndexSignature */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 139 /* CallSignature */: + case 140 /* ConstructSignature */: + case 141 /* IndexSignature */: return true; } return false; @@ -36871,56 +37796,56 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 198 /* VariableDeclaration */ || - containingNodeKind === 199 /* VariableDeclarationList */ || - containingNodeKind === 180 /* VariableStatement */ || - containingNodeKind === 204 /* EnumDeclaration */ || + return containingNodeKind === 199 /* VariableDeclaration */ || + containingNodeKind === 200 /* VariableDeclarationList */ || + containingNodeKind === 181 /* VariableStatement */ || + containingNodeKind === 205 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 201 /* ClassDeclaration */ || - containingNodeKind === 200 /* FunctionDeclaration */ || - containingNodeKind === 202 /* InterfaceDeclaration */ || - containingNodeKind === 151 /* ArrayBindingPattern */ || - containingNodeKind === 150 /* ObjectBindingPattern */; // function func({ x, y| + containingNodeKind === 202 /* ClassDeclaration */ || + containingNodeKind === 201 /* FunctionDeclaration */ || + containingNodeKind === 203 /* InterfaceDeclaration */ || + containingNodeKind === 152 /* ArrayBindingPattern */ || + containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x, y| case 20 /* DotToken */: - return containingNodeKind === 151 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 152 /* ArrayBindingPattern */; // var [.| case 18 /* OpenBracketToken */: - return containingNodeKind === 151 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 152 /* ArrayBindingPattern */; // var [x| case 16 /* OpenParenToken */: - return containingNodeKind === 223 /* CatchClause */ || + return containingNodeKind === 224 /* CatchClause */ || isFunction(containingNodeKind); case 14 /* OpenBraceToken */: - return containingNodeKind === 204 /* EnumDeclaration */ || - containingNodeKind === 202 /* InterfaceDeclaration */ || - containingNodeKind === 145 /* TypeLiteral */ || - containingNodeKind === 150 /* ObjectBindingPattern */; // function func({ x| + return containingNodeKind === 205 /* EnumDeclaration */ || + containingNodeKind === 203 /* InterfaceDeclaration */ || + containingNodeKind === 146 /* TypeLiteral */ || + containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x| case 22 /* SemicolonToken */: - return containingNodeKind === 131 /* PropertySignature */ && + return containingNodeKind === 132 /* PropertySignature */ && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 202 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 145 /* TypeLiteral */); // let x : { a; | + (previousToken.parent.parent.kind === 203 /* InterfaceDeclaration */ || + previousToken.parent.parent.kind === 146 /* TypeLiteral */); // let x : { a; | case 24 /* LessThanToken */: - return containingNodeKind === 201 /* ClassDeclaration */ || - containingNodeKind === 200 /* FunctionDeclaration */ || - containingNodeKind === 202 /* InterfaceDeclaration */ || + return containingNodeKind === 202 /* ClassDeclaration */ || + containingNodeKind === 201 /* FunctionDeclaration */ || + containingNodeKind === 203 /* InterfaceDeclaration */ || isFunction(containingNodeKind); case 109 /* StaticKeyword */: - return containingNodeKind === 132 /* PropertyDeclaration */; + return containingNodeKind === 133 /* PropertyDeclaration */; case 21 /* DotDotDotToken */: - return containingNodeKind === 129 /* Parameter */ || - containingNodeKind === 135 /* Constructor */ || + return containingNodeKind === 130 /* Parameter */ || + containingNodeKind === 136 /* Constructor */ || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 151 /* ArrayBindingPattern */); // var [ ...z| + previousToken.parent.parent.kind === 152 /* ArrayBindingPattern */); // var [ ...z| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 129 /* Parameter */; + return containingNodeKind === 130 /* Parameter */; case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: case 103 /* InterfaceKeyword */: case 83 /* FunctionKeyword */: case 98 /* VarKeyword */: case 116 /* GetKeyword */: - case 120 /* SetKeyword */: + case 121 /* SetKeyword */: case 85 /* ImportKeyword */: case 104 /* LetKeyword */: case 70 /* ConstKeyword */: @@ -36956,7 +37881,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 212 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 213 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -36973,7 +37898,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 224 /* PropertyAssignment */ && m.kind !== 225 /* ShorthandPropertyAssignment */) { + if (m.kind !== 225 /* PropertyAssignment */ && m.kind !== 226 /* ShorthandPropertyAssignment */) { // Ignore omitted expressions for missing members in the object literal return; } @@ -37023,10 +37948,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_24 in nameTable) { - if (!allNames[name_24]) { - allNames[name_24] = name_24; - var displayName = getCompletionEntryDisplayName(name_24, target, true); + for (var name_25 in nameTable) { + if (!allNames[name_25]) { + allNames[name_25] = name_25; + var displayName = getCompletionEntryDisplayName(name_25, target, true); if (displayName) { var entry = { name: displayName, @@ -37201,22 +38126,6 @@ var ts; } return ScriptElementKind.unknown; } - function getTypeKind(type) { - var flags = type.getFlags(); - if (flags & 128 /* Enum */) - return ScriptElementKind.enumElement; - if (flags & 1024 /* Class */) - return ScriptElementKind.classElement; - if (flags & 2048 /* Interface */) - return ScriptElementKind.interfaceElement; - if (flags & 512 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - if (flags & 1048703 /* Intrinsic */) - return ScriptElementKind.primitiveType; - if (flags & 256 /* StringLiteral */) - return ScriptElementKind.primitiveType; - return ScriptElementKind.unknown; - } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) @@ -37241,7 +38150,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 155 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 156 /* 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)) { @@ -37250,7 +38159,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 157 /* CallExpression */ || location.kind === 158 /* NewExpression */) { + if (location.kind === 158 /* CallExpression */ || location.kind === 159 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -37263,7 +38172,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 158 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 159 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -37315,24 +38224,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 135 /* Constructor */)) { + (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 136 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 135 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 136 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 135 /* Constructor */) { + if (functionDeclaration.kind === 136 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 138 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -37355,7 +38264,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(123 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(124 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -37375,7 +38284,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(117 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 206 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 118 /* NamespaceKeyword */ : 117 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -37396,13 +38307,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 139 /* ConstructSignature */) { + if (signatureDeclaration.kind === 140 /* ConstructSignature */) { displayParts.push(ts.keywordPart(88 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 138 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 139 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -37411,7 +38322,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 226 /* EnumMember */) { + if (declaration.kind === 227 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -37427,13 +38338,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 208 /* ImportEqualsDeclaration */) { + if (declaration.kind === 209 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(118 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(119 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -37560,8 +38471,8 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 65 /* Identifier */: - case 155 /* PropertyAccessExpression */: - case 126 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position @@ -37597,6 +38508,62 @@ var ts; containerName: containerName }; } + function getDefinitionFromSymbol(symbol, node) { + var typeChecker = program.getTypeChecker(); + var result = []; + var declarations = symbol.getDeclarations(); + var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol + var symbolKind = getSymbolKind(symbol, node); + var containerSymbol = symbol.parent; + var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + // Just add all the declarations. + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + // Applicable only if we are in a new expression, or we are on a constructor declaration + // and in either case the symbol has a construct signature definition, i.e. class + if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { + if (symbol.flags & 32 /* Class */) { + var classDeclaration = symbol.getDeclarations()[0]; + ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */); + return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + } + } + return false; + } + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + } + return false; + } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 136 /* Constructor */) || + (!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; + } + } /// Goto definition function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); @@ -37649,7 +38616,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 === 225 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 226 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -37660,59 +38627,38 @@ var ts; var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); } - var result = []; - var declarations = symbol.getDeclarations(); - var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - var symbolKind = getSymbolKind(symbol, node); - var containerSymbol = symbol.parent; - var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. - ts.forEach(declarations, function (declaration) { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); + return getDefinitionFromSymbol(symbol, node); + } + /// Goto type + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; } - return result; - function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - // Applicable only if we are in a new expression, or we are on a constructor declaration - // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { - if (symbol.flags & 32 /* Class */) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 201 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); - } - } - return false; + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; } - function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); - } - return false; + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 135 /* Constructor */) || - (!selectConstructors && (d.kind === 200 /* FunctionDeclaration */ || d.kind === 134 /* MethodDeclaration */ || d.kind === 133 /* MethodSignature */))) { - declarations.push(d); - if (d.body) - definition = d; + if (type.flags & 16384 /* Union */) { + var result = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); } }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - return false; + return result; } + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(type.symbol, node); } function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); @@ -37799,74 +38745,74 @@ var ts; switch (node.kind) { case 84 /* IfKeyword */: case 76 /* ElseKeyword */: - if (hasKind(node.parent, 183 /* IfStatement */)) { + if (hasKind(node.parent, 184 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 191 /* ReturnStatement */)) { + if (hasKind(node.parent, 192 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 195 /* ThrowStatement */)) { + if (hasKind(node.parent, 196 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 196 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 197 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96 /* TryKeyword */: case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 196 /* TryStatement */)) { + if (hasKind(parent(node), 197 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 193 /* SwitchStatement */)) { + if (hasKind(node.parent, 194 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67 /* CaseKeyword */: case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 193 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 194 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66 /* BreakKeyword */: case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 190 /* BreakStatement */) || hasKind(node.parent, 189 /* ContinueStatement */)) { + if (hasKind(node.parent, 191 /* BreakStatement */) || hasKind(node.parent, 190 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82 /* ForKeyword */: - if (hasKind(node.parent, 186 /* ForStatement */) || - hasKind(node.parent, 187 /* ForInStatement */) || - hasKind(node.parent, 188 /* ForOfStatement */)) { + if (hasKind(node.parent, 187 /* ForStatement */) || + hasKind(node.parent, 188 /* ForInStatement */) || + hasKind(node.parent, 189 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100 /* WhileKeyword */: case 75 /* DoKeyword */: - if (hasKind(node.parent, 185 /* WhileStatement */) || hasKind(node.parent, 184 /* DoStatement */)) { + if (hasKind(node.parent, 186 /* WhileStatement */) || hasKind(node.parent, 185 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 135 /* Constructor */)) { + if (hasKind(node.parent, 136 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 116 /* GetKeyword */: - case 120 /* SetKeyword */: - if (hasKind(node.parent, 136 /* GetAccessor */) || hasKind(node.parent, 137 /* SetAccessor */)) { + case 121 /* SetKeyword */: + if (hasKind(node.parent, 137 /* GetAccessor */) || hasKind(node.parent, 138 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 180 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 181 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -37882,10 +38828,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 195 /* ThrowStatement */) { + if (node.kind === 196 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 196 /* TryStatement */) { + else if (node.kind === 197 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -37914,12 +38860,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent_9 = child.parent; - if (ts.isFunctionBlock(parent_9) || parent_9.kind === 227 /* SourceFile */) { + if (ts.isFunctionBlock(parent_9) || parent_9.kind === 228 /* SourceFile */) { return parent_9; } // 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_9.kind === 196 /* TryStatement */) { + if (parent_9.kind === 197 /* TryStatement */) { var tryStatement = parent_9; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -37934,7 +38880,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 190 /* BreakStatement */ || node.kind === 189 /* ContinueStatement */) { + if (node.kind === 191 /* BreakStatement */ || node.kind === 190 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -37950,16 +38896,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 193 /* SwitchStatement */: - if (statement.kind === 189 /* ContinueStatement */) { + case 194 /* SwitchStatement */: + if (statement.kind === 190 /* ContinueStatement */) { continue; } // Fall through. - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 185 /* WhileStatement */: - case 184 /* DoStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 186 /* WhileStatement */: + case 185 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -37978,18 +38924,18 @@ 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 === 201 /* ClassDeclaration */ || - (declaration.kind === 129 /* Parameter */ && hasKind(container, 135 /* Constructor */)))) { + if (!(container.kind === 202 /* ClassDeclaration */ || + (declaration.kind === 130 /* Parameter */ && hasKind(container, 136 /* Constructor */)))) { return undefined; } } else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 201 /* ClassDeclaration */) { + if (container.kind !== 202 /* ClassDeclaration */) { return undefined; } } else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 206 /* ModuleBlock */ || container.kind === 227 /* SourceFile */)) { + if (!(container.kind === 207 /* ModuleBlock */ || container.kind === 228 /* SourceFile */)) { return undefined; } } @@ -38001,20 +38947,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 206 /* ModuleBlock */: - case 227 /* SourceFile */: + case 207 /* ModuleBlock */: + case 228 /* SourceFile */: nodes = container.statements; break; - case 135 /* Constructor */: + case 136 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: 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 & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 135 /* Constructor */ && member; + return member.kind === 136 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -38062,13 +39008,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 136 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 120 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 121 /* SetKeyword */); }); } } } @@ -38086,7 +39032,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 184 /* DoStatement */) { + if (loopNode.kind === 185 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { @@ -38107,13 +39053,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 186 /* ForStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: - case 184 /* DoStatement */: - case 185 /* WhileStatement */: + case 187 /* ForStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: + case 185 /* DoStatement */: + case 186 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -38167,7 +39113,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, 179 /* Block */))) { + if (!(func && hasKind(func.body, 180 /* Block */))) { return undefined; } var keywords = []; @@ -38183,7 +39129,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 183 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 184 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -38196,7 +39142,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 183 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 184 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -38375,17 +39321,17 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 213 /* ImportSpecifier */ || location.parent.kind === 217 /* ExportSpecifier */) && + (location.parent.kind === 214 /* ImportSpecifier */ || location.parent.kind === 218 /* ExportSpecifier */) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 213 /* ImportSpecifier */ || declaration.kind === 217 /* ExportSpecifier */; + return declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 218 /* ExportSpecifier */; }); } function getDeclaredName(symbol, location) { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 162 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -38412,7 +39358,7 @@ var ts; return location.getText(); } // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 162 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -38436,7 +39382,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 201 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 202 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -38462,7 +39408,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 227 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 228 /* 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; @@ -38650,13 +39596,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -38688,27 +39634,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 227 /* SourceFile */: + case 228 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 163 /* 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. @@ -38717,7 +39663,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 227 /* SourceFile */) { + if (searchSpaceNode.kind === 228 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -38748,27 +39694,27 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 201 /* ClassDeclaration */: + case 202 /* 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 & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 227 /* SourceFile */: - if (container.kind === 227 /* SourceFile */ && !ts.isExternalModule(container)) { + case 228 /* SourceFile */: + if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -38822,11 +39768,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 201 /* ClassDeclaration */) { + if (declaration.kind === 202 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 202 /* InterfaceDeclaration */) { + else if (declaration.kind === 203 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -38887,19 +39833,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_25 = node.text; + var name_26 = 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_25); + var unionProperty = contextualType.getProperty(name_26); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_25); + var symbol = t.getProperty(name_26); if (symbol) { result_4.push(symbol); } @@ -38908,7 +39854,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_25); + var symbol_1 = contextualType.getProperty(name_26); if (symbol_1) { return [symbol_1]; } @@ -38966,10 +39912,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 168 /* PostfixUnaryExpression */ || parent.kind === 167 /* PrefixUnaryExpression */) { + if (parent.kind === 169 /* PostfixUnaryExpression */ || parent.kind === 168 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 169 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 170 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; } @@ -39003,33 +39949,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 135 /* Constructor */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - case 223 /* CatchClause */: + case 130 /* Parameter */: + case 199 /* VariableDeclaration */: + case 153 /* BindingElement */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: + case 225 /* PropertyAssignment */: + case 226 /* ShorthandPropertyAssignment */: + case 227 /* EnumMember */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 136 /* Constructor */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 201 /* FunctionDeclaration */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: + case 224 /* CatchClause */: return 1 /* Value */; - case 128 /* TypeParameter */: - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 145 /* TypeLiteral */: + case 129 /* TypeParameter */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: + case 146 /* TypeLiteral */: return 2 /* Type */; - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -39039,15 +39985,15 @@ var ts; else { return 4 /* Namespace */; } - case 212 /* NamedImports */: - case 213 /* ImportSpecifier */: - case 208 /* ImportEqualsDeclaration */: - case 209 /* ImportDeclaration */: - case 214 /* ExportAssignment */: - case 215 /* ExportDeclaration */: + case 213 /* NamedImports */: + case 214 /* ImportSpecifier */: + case 209 /* ImportEqualsDeclaration */: + case 210 /* ImportDeclaration */: + case 215 /* ExportAssignment */: + case 216 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 227 /* SourceFile */: + case 228 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -39057,7 +40003,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 141 /* TypeReference */ || node.parent.kind === 177 /* HeritageClauseElement */; + return node.parent.kind === 142 /* TypeReference */ || node.parent.kind === 177 /* ExpressionWithTypeArguments */; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -39065,32 +40011,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 155 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 155 /* PropertyAccessExpression */) { + if (root.parent.kind === 156 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 156 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 /* HeritageClauseElement */ && root.parent.parent.kind === 222 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 177 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 223 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 201 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 202 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 202 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || + (decl.kind === 203 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 126 /* QualifiedName */) { - while (root.parent && root.parent.kind === 126 /* QualifiedName */) { + if (root.parent.kind === 127 /* QualifiedName */) { + while (root.parent && root.parent.kind === 127 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 141 /* TypeReference */ && !isLastClause; + return root.parent.kind === 142 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 126 /* QualifiedName */) { + while (node.parent.kind === 127 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -39100,15 +40046,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 126 /* QualifiedName */ && + if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 208 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 209 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 214 /* ExportAssignment */) { + if (node.parent.kind === 215 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -39148,8 +40094,8 @@ var ts; return; } switch (node.kind) { - case 155 /* PropertyAccessExpression */: - case 126 /* QualifiedName */: + case 156 /* PropertyAccessExpression */: + case 127 /* QualifiedName */: case 8 /* StringLiteral */: case 80 /* FalseKeyword */: case 95 /* TrueKeyword */: @@ -39172,7 +40118,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 === 205 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 206 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -39199,29 +40145,37 @@ var ts; return ts.NavigationBar.getNavigationBarItems(sourceFile); } function getSemanticClassifications(fileName, span) { + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + function getEncodedSemanticClassifications(fileName, span) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; processNode(sourceFile); - return result; + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) { - return ClassificationTypeNames.className; + return 11 /* className */; } else if (flags & 384 /* Enum */) { - return ClassificationTypeNames.enumName; + return 12 /* enumName */; } else if (flags & 524288 /* TypeAlias */) { - return ClassificationTypeNames.typeAlias; + return 16 /* typeAliasName */; } else if (meaningAtPosition & 2 /* Type */) { if (flags & 64 /* Interface */) { - return ClassificationTypeNames.interfaceName; + return 13 /* interfaceName */; } else if (flags & 262144 /* TypeParameter */) { - return ClassificationTypeNames.typeParameterName; + return 15 /* typeParameterName */; } } else if (flags & 1536 /* Module */) { @@ -39230,7 +40184,7 @@ var ts; // - There exists a module declaration which actually impacts the value side. if (meaningAtPosition & 4 /* Namespace */ || (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { - return ClassificationTypeNames.moduleName; + return 14 /* moduleName */; } } return undefined; @@ -39239,7 +40193,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 205 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; }); } } @@ -39251,10 +40205,7 @@ var ts; if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { - result.push({ - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - classificationType: type - }); + pushClassification(node.getStart(), node.getWidth(), type); } } } @@ -39262,7 +40213,42 @@ var ts; } } } + function getClassificationTypeName(type) { + switch (type) { + case 1 /* comment */: return ClassificationTypeNames.comment; + case 2 /* identifier */: return ClassificationTypeNames.identifier; + case 3 /* keyword */: return ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ClassificationTypeNames.text; + case 10 /* punctuation */: return ClassificationTypeNames.punctuation; + case 11 /* className */: return ClassificationTypeNames.className; + case 12 /* enumName */: return ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ClassificationTypeNames.parameterName; + } + } + function convertClassifications(classifications) { + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } function getSyntacticClassifications(fileName, span) { + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + function getEncodedSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Make a scanner we can get trivia from. @@ -39270,7 +40256,12 @@ var ts; var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); var result = []; processElement(sourceFile); - return result; + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } function classifyLeadingTrivia(token) { var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); if (tokenStart === token.pos) { @@ -39289,10 +40280,7 @@ var ts; } if (ts.isComment(kind)) { // Simple comment. Just add as is. - result.push({ - textSpan: ts.createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, 1 /* comment */); continue; } if (kind === 6 /* ConflictMarkerTrivia */) { @@ -39301,10 +40289,7 @@ var ts; // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - result.push({ - textSpan: ts.createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, 1 /* comment */); continue; } // for the ======== add a comment for the first line, and then lex all @@ -39323,10 +40308,7 @@ var ts; break; } } - result.push({ - textSpan: ts.createTextSpanFromBounds(start, i), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, i - start, 1 /* comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -39338,10 +40320,7 @@ var ts; var end = mergeConflictScanner.getTextPos(); var type = classifyTokenType(tokenKind); if (type) { - result.push({ - textSpan: ts.createTextSpanFromBounds(start, end), - classificationType: type - }); + pushClassification(start, end - start, type); } } function classifyToken(token) { @@ -39349,10 +40328,7 @@ var ts; if (token.getWidth() > 0) { var type = classifyTokenType(token.kind, token); if (type) { - result.push({ - textSpan: ts.createTextSpan(token.getStart(), token.getWidth()), - classificationType: type - }); + pushClassification(token.getStart(), token.getWidth(), type); } } } @@ -39361,7 +40337,7 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return ClassificationTypeNames.keyword; + return 3 /* keyword */; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. @@ -39369,73 +40345,78 @@ var ts; // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return ClassificationTypeNames.punctuation; + return 10 /* punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 53 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 198 /* VariableDeclaration */ || - token.parent.kind === 132 /* PropertyDeclaration */ || - token.parent.kind === 129 /* Parameter */) { - return ClassificationTypeNames.operator; + if (token.parent.kind === 199 /* VariableDeclaration */ || + token.parent.kind === 133 /* PropertyDeclaration */ || + token.parent.kind === 130 /* Parameter */) { + return 5 /* operator */; } } - if (token.parent.kind === 169 /* BinaryExpression */ || - token.parent.kind === 167 /* PrefixUnaryExpression */ || - token.parent.kind === 168 /* PostfixUnaryExpression */ || - token.parent.kind === 170 /* ConditionalExpression */) { - return ClassificationTypeNames.operator; + if (token.parent.kind === 170 /* BinaryExpression */ || + token.parent.kind === 168 /* PrefixUnaryExpression */ || + token.parent.kind === 169 /* PostfixUnaryExpression */ || + token.parent.kind === 171 /* ConditionalExpression */) { + return 5 /* operator */; } } - return ClassificationTypeNames.punctuation; + return 10 /* punctuation */; } else if (tokenKind === 7 /* NumericLiteral */) { - return ClassificationTypeNames.numericLiteral; + return 4 /* numericLiteral */; } else if (tokenKind === 8 /* StringLiteral */) { - return ClassificationTypeNames.stringLiteral; + return 6 /* stringLiteral */; } else if (tokenKind === 9 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return ClassificationTypeNames.stringLiteral; + return 6 /* stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return ClassificationTypeNames.stringLiteral; + return 6 /* stringLiteral */; } else if (tokenKind === 65 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.className; + return 11 /* className */; } return; - case 128 /* TypeParameter */: + case 129 /* TypeParameter */: if (token.parent.name === token) { - return ClassificationTypeNames.typeParameterName; + return 15 /* typeParameterName */; } return; - case 202 /* InterfaceDeclaration */: + case 203 /* InterfaceDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.interfaceName; + return 13 /* interfaceName */; } return; - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.enumName; + return 12 /* enumName */; } return; - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (token.parent.name === token) { - return ClassificationTypeNames.moduleName; + return 14 /* moduleName */; + } + return; + case 130 /* Parameter */: + if (token.parent.name === token) { + return 17 /* parameterName */; } return; } } - return ClassificationTypeNames.text; + return 9 /* text */; } } function processElement(element) { @@ -39715,11 +40696,14 @@ var ts; getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getSyntacticClassifications: getSyntacticClassifications, getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, getCompletionsAtPosition: getCompletionsAtPosition, getCompletionEntryDetails: getCompletionEntryDetails, getSignatureHelpItems: getSignatureHelpItems, getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, findReferences: findReferences, getOccurrencesAtPosition: getOccurrencesAtPosition, @@ -39767,7 +40751,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 === 219 /* ExternalModuleReference */ || + node.parent.kind === 220 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -39780,7 +40764,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 156 /* ElementAccessExpression */ && + node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -39828,7 +40812,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 120 /* SetKeyword */ || + keyword2 === 121 /* SetKeyword */ || keyword2 === 114 /* ConstructorKeyword */ || keyword2 === 109 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -39843,9 +40827,58 @@ var ts; // if there are more cases we want the classifier to be better at. return true; } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_1 = dense[i + 1]; + var type = dense[i + 2]; + // Make a whitespace entry between the last item and this one. + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + } + } + entries.push({ length: length_1, classification: convertClassification(type) }); + lastEnd = start + length_1; + } + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + return { entries: entries, finalLexState: classifications.endOfLineState }; + } + function convertClassification(type) { + switch (type) { + case 1 /* comment */: return TokenClass.Comment; + case 3 /* keyword */: return TokenClass.Keyword; + case 4 /* numericLiteral */: return TokenClass.NumberLiteral; + case 5 /* operator */: return TokenClass.Operator; + case 6 /* stringLiteral */: return TokenClass.StringLiteral; + case 8 /* whiteSpace */: return TokenClass.Whitespace; + case 10 /* punctuation */: return TokenClass.Punctuation; + case 2 /* identifier */: + case 11 /* className */: + case 12 /* enumName */: + case 13 /* interfaceName */: + case 14 /* moduleName */: + case 15 /* typeParameterName */: + case 16 /* typeAliasName */: + case 9 /* text */: + case 17 /* parameterName */: + default: + return TokenClass.Identifier; + } + } + function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. - function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { var offset = 0; var token = 0 /* Unknown */; var lastNonTriviaToken = 0 /* Unknown */; @@ -39885,8 +40918,8 @@ var ts; } scanner.setText(text); var result = { - finalLexState: 0 /* Start */, - entries: [] + endOfLineState: 0 /* None */, + spans: [] }; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -39938,10 +40971,10 @@ var ts; angleBracketStack--; } else if (token === 112 /* AnyKeyword */ || - token === 121 /* StringKeyword */ || - token === 119 /* NumberKeyword */ || + token === 122 /* StringKeyword */ || + token === 120 /* NumberKeyword */ || token === 113 /* BooleanKeyword */ || - token === 122 /* SymbolKeyword */) { + token === 123 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -39988,7 +41021,7 @@ var ts; function processToken() { var start = scanner.getTokenPos(); var end = scanner.getTextPos(); - addResult(end - start, classFromKind(token)); + addResult(start, end, classFromKind(token)); if (end >= text.length) { if (token === 8 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. @@ -40002,7 +41035,7 @@ var ts; // If we have an odd number of backslashes, then the multiline string is unclosed if (numBackslashes & 1) { var quoteChar = tokenText.charCodeAt(0); - result.finalLexState = quoteChar === 34 /* doubleQuote */ + result.endOfLineState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; } @@ -40011,16 +41044,16 @@ var ts; else if (token === 3 /* MultiLineCommentTrivia */) { // Check to see if the multiline comment was unclosed. if (scanner.isUnterminated()) { - result.finalLexState = 1 /* InMultiLineCommentTrivia */; + result.endOfLineState = 1 /* InMultiLineCommentTrivia */; } } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { if (token === 13 /* TemplateTail */) { - result.finalLexState = 5 /* InTemplateMiddleOrTail */; + result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } else if (token === 10 /* NoSubstitutionTemplateLiteral */) { - result.finalLexState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); @@ -40028,18 +41061,30 @@ var ts; } } else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { - result.finalLexState = 6 /* InTemplateSubstitutionPosition */; + result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } } - function addResult(length, classification) { + function addResult(start, end, classification) { + if (classification === 8 /* whiteSpace */) { + // Don't bother with whitespace classifications. They're not needed. + return; + } + if (start === 0 && offset > 0) { + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of + // the original text. + start += offset; + } + // All our tokens are in relation to the augmented text. Move them back to be + // relative to the original text. + start -= offset; + end -= offset; + var length = end - start; if (length > 0) { - // If this is the first classification we're adding to the list, then remove any - // offset we have if we were continuing a construct from the previous line. - if (result.entries.length === 0) { - length -= offset; - } - result.entries.push({ length: length, classification: classification }); + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); } } } @@ -40100,41 +41145,44 @@ var ts; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 125 /* LastKeyword */; + return token >= 66 /* FirstKeyword */ && token <= 126 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { - return TokenClass.Keyword; + return 3 /* keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return TokenClass.Operator; + return 5 /* operator */; } else if (token >= 14 /* FirstPunctuation */ && token <= 64 /* LastPunctuation */) { - return TokenClass.Punctuation; + return 10 /* punctuation */; } switch (token) { case 7 /* NumericLiteral */: - return TokenClass.NumberLiteral; + return 4 /* numericLiteral */; case 8 /* StringLiteral */: - return TokenClass.StringLiteral; + return 6 /* stringLiteral */; case 9 /* RegularExpressionLiteral */: - return TokenClass.RegExpLiteral; + return 7 /* regularExpressionLiteral */; case 6 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: - return TokenClass.Comment; + return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: - return TokenClass.Whitespace; + return 8 /* whiteSpace */; case 65 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return TokenClass.StringLiteral; + return 6 /* stringLiteral */; } - return TokenClass.Identifier; + return 2 /* identifier */; } } - return { getClassificationsForLine: getClassificationsForLine }; + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; } ts.createClassifier = createClassifier; /** @@ -40155,7 +41203,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 227 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 228 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -40225,125 +41273,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 184 /* DoStatement */) { + if (node.parent.kind === 185 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 186 /* ForStatement */) { + if (node.parent.kind === 187 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 169 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 170 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind == 163 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind == 164 /* 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 180 /* VariableStatement */: + case 181 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 198 /* VariableDeclaration */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: + case 199 /* VariableDeclaration */: + case 133 /* PropertyDeclaration */: + case 132 /* PropertySignature */: return spanInVariableDeclaration(node); - case 129 /* Parameter */: + case 130 /* Parameter */: return spanInParameterDeclaration(node); - case 200 /* FunctionDeclaration */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: + case 201 /* FunctionDeclaration */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: + case 163 /* FunctionExpression */: + case 164 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 179 /* Block */: + case 180 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 206 /* ModuleBlock */: + case 207 /* ModuleBlock */: return spanInBlock(node); - case 223 /* CatchClause */: + case 224 /* CatchClause */: return spanInBlock(node.block); - case 182 /* ExpressionStatement */: + case 183 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 191 /* ReturnStatement */: + case 192 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 185 /* WhileStatement */: + case 186 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 184 /* DoStatement */: + case 185 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 197 /* DebuggerStatement */: + case 198 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 183 /* IfStatement */: + case 184 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* LabeledStatement */: + case 195 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: + case 191 /* BreakStatement */: + case 190 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 186 /* ForStatement */: + case 187 /* ForStatement */: return spanInForStatement(node); - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 193 /* SwitchStatement */: + case 194 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: + case 221 /* CaseClause */: + case 222 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 196 /* TryStatement */: + case 197 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 195 /* ThrowStatement */: + case 196 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 214 /* ExportAssignment */: + case 215 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 208 /* ImportEqualsDeclaration */: + case 209 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 209 /* ImportDeclaration */: + case 210 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ExportDeclaration */: + case 216 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 201 /* ClassDeclaration */: - case 204 /* EnumDeclaration */: - case 226 /* EnumMember */: - case 157 /* CallExpression */: - case 158 /* NewExpression */: + case 202 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 227 /* EnumMember */: + case 158 /* CallExpression */: + case 159 /* NewExpression */: // span on complete node return textSpan(node); - case 192 /* WithStatement */: + case 193 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 202 /* InterfaceDeclaration */: - case 203 /* TypeAliasDeclaration */: + case 203 /* InterfaceDeclaration */: + case 204 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -40373,11 +41421,11 @@ var ts; return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 224 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 225 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 160 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 161 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -40390,12 +41438,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 187 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 188 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 188 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 180 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 186 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -40449,7 +41497,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 201 /* ClassDeclaration */ && functionDeclaration.kind !== 135 /* Constructor */); + (functionDeclaration.parent.kind === 202 /* ClassDeclaration */ && functionDeclaration.kind !== 136 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -40472,18 +41520,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 205 /* ModuleDeclaration */: + case 206 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 185 /* WhileStatement */: - case 183 /* IfStatement */: - case 187 /* ForInStatement */: - case 188 /* ForOfStatement */: + case 186 /* WhileStatement */: + case 184 /* IfStatement */: + case 188 /* ForInStatement */: + case 189 /* ForOfStatement */: 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 186 /* ForStatement */: + case 187 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -40491,7 +41539,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 199 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 200 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -40511,13 +41559,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 204 /* EnumDeclaration */: + case 205 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 201 /* ClassDeclaration */: + case 202 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 207 /* CaseBlock */: + case 208 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -40525,30 +41573,30 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 206 /* ModuleBlock */: + case 207 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 204 /* EnumDeclaration */: - case 201 /* ClassDeclaration */: + case 205 /* EnumDeclaration */: + case 202 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 179 /* Block */: + case 180 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 223 /* CatchClause */: - return spanInNode(node.parent.statements[node.parent.statements.length - 1]); + case 224 /* CatchClause */: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 207 /* CaseBlock */: + case 208 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; - var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { - return spanInNode(lastClause.statements[lastClause.statements.length - 1]); + return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; // Default to parent node @@ -40557,7 +41605,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 184 /* DoStatement */) { + if (node.parent.kind === 185 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -40567,17 +41615,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 162 /* FunctionExpression */: - case 200 /* FunctionDeclaration */: - case 163 /* ArrowFunction */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 135 /* Constructor */: - case 185 /* WhileStatement */: - case 184 /* DoStatement */: - case 186 /* ForStatement */: + case 163 /* FunctionExpression */: + case 201 /* FunctionDeclaration */: + case 164 /* ArrowFunction */: + case 135 /* MethodDeclaration */: + case 134 /* MethodSignature */: + case 137 /* GetAccessor */: + case 138 /* SetAccessor */: + case 136 /* Constructor */: + case 186 /* WhileStatement */: + case 185 /* DoStatement */: + case 187 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -40588,19 +41636,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 224 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 225 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 160 /* TypeAssertionExpression */) { + if (node.parent.kind === 161 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 184 /* DoStatement */) { + if (node.parent.kind === 185 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -40614,7 +41662,7 @@ var ts; })(ts || (ts = {})); // // Copyright (c) Microsoft Corporation. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -40633,7 +41681,9 @@ var debugObjectHost = this; var ts; (function (ts) { function logInternalError(logger, err) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } } var ScriptSnapshotShimAdapter = (function () { function ScriptSnapshotShimAdapter(scriptSnapshotShim) { @@ -40726,24 +41776,39 @@ var ts; return LanguageServiceShimHostAdapter; })(); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action) { - logger.log(actionDescription); - var start = Date.now(); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + this.shimHost = shimHost; + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { + var encoded = this.shimHost.readDirectory(rootDir, extension); + return JSON.parse(encoded); + }; + return CoreServicesShimHostAdapter; + })(); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, noPerfLogging) { + if (!noPerfLogging) { + logger.log(actionDescription); + var start = Date.now(); + } var result = action(); - var end = Date.now(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof (result) === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; + if (!noPerfLogging) { + var end = Date.now(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof (result) === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); } return result; } - function forwardJSONCall(logger, actionDescription, action) { + function forwardJSONCall(logger, actionDescription, action, noPerfLogging) { try { - var result = simpleForwardCall(logger, actionDescription, action); + var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); return JSON.stringify({ result: result }); } catch (err) { @@ -40788,7 +41853,7 @@ var ts; this.logger = this.host; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action); + return forwardJSONCall(this.logger, actionDescription, action, false); }; /// DISPOSE /** @@ -40841,6 +41906,22 @@ var ts; return classifications; }); }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); + }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); + }); + }; LanguageServiceShimObject.prototype.getNewLine = function () { return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; }; @@ -40919,6 +42000,17 @@ var ts; return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; + /// GOTO Type + /** + * Computes the definition location of the type of the symbol + * at the requested position. + */ + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getTypeDefinitionAtPosition(fileName, position); + }); + }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { var _this = this; return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { @@ -41060,12 +42152,21 @@ var ts; }; return LanguageServiceShimObject; })(ShimBase); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } var ClassifierShimObject = (function (_super) { __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory) { + function ClassifierShimObject(factory, logger) { _super.call(this, factory); + this.logger = logger; this.classifier = ts.createClassifier(); } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, + /*noPerfLogging:*/ true); + }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); @@ -41082,12 +42183,13 @@ var ts; })(ShimBase); var CoreServicesShimObject = (function (_super) { __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger) { + function CoreServicesShimObject(factory, logger, host) { _super.call(this, factory); this.logger = logger; + this.host = host; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action); + return forwardJSONCall(this.logger, actionDescription, action, false); }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { @@ -41114,6 +42216,26 @@ var ts; return convertResult; }); }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileText(fileName, text); + if (result.error) { + return { + options: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + var configFile = ts.parseConfigFile(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + return { + options: configFile.options, + files: configFile.fileNames, + errors: [realizeDiagnostics(configFile.errors, '\r\n')] + }; + }); + }; CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); @@ -41145,19 +42267,20 @@ var ts; }; TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { try { - return new ClassifierShimObject(this); + return new ClassifierShimObject(this, logger); } catch (err) { logInternalError(logger, err); throw err; } }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (logger) { + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { try { - return new CoreServicesShimObject(this, logger); + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); } catch (err) { - logInternalError(logger, err); + logInternalError(host, err); throw err; } }; diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 170f3d3c830..b66497fc40d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -440,6 +440,18 @@ module ts { else if (isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); } + else if (isParameterDeclaration(node)) { + // It is safe to walk up parent chain to find whether the node is a destructing parameter declaration + // because its parent chain has already been set up, since parents are set before descending into children. + // + // If node is a binding element in parameter declaration, we need to use ParameterExcludes. + // Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration + // For example: + // function foo([a,a]) {} // Duplicate Identifier error + // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter + // // which correctly set excluded symbols + bindDeclaration(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false); + } else { bindDeclaration(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes, /*isBlockScopeContainer*/ false); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 469ecf80c84..8536f24a7e2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -88,12 +88,11 @@ module ts { let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined"); let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null"); let unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); - let resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__"); let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - + let anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); @@ -118,7 +117,7 @@ module ts { let getGlobalParameterDecoratorType: () => ObjectType; let getGlobalPropertyDecoratorType: () => ObjectType; let getGlobalMethodDecoratorType: () => ObjectType; - + let tupleTypes: Map = {}; let unionTypes: Map = {}; let stringLiteralTypes: Map = {}; @@ -126,6 +125,9 @@ module ts { let emitDecorate = false; let emitParam = false; + let resolutionTargets: Object[] = []; + let resolutionResults: boolean[] = []; + let mergedSymbols: Symbol[] = []; let symbolLinks: SymbolLinks[] = []; let nodeLinks: NodeLinks[] = []; @@ -350,9 +352,9 @@ module ts { } else if (location.kind === SyntaxKind.SourceFile || (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { - result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & SymbolFlags.ModuleMember); + result = getSymbolOfNode(location).exports["default"]; let localSymbol = getLocalSymbolForExportDefault(result); - if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) { + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; @@ -801,7 +803,9 @@ module ts { let symbol: Symbol; if (name.kind === SyntaxKind.Identifier) { - symbol = resolveName(name, (name).text, meaning, Diagnostics.Cannot_find_name_0, name); + let message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; + + symbol = resolveName(name, (name).text, meaning, message, name); if (!symbol) { return undefined; } @@ -853,10 +857,11 @@ module ts { return symbol; } } + let fileName: string; let sourceFile: SourceFile; while (true) { - let fileName = normalizePath(combinePaths(searchPath, moduleName)); - sourceFile = host.getSourceFile(fileName + ".ts") || host.getSourceFile(fileName + ".d.ts"); + fileName = normalizePath(combinePaths(searchPath, moduleName)); + sourceFile = forEach(supportedExtensions, extension => host.getSourceFile(fileName + extension)); if (sourceFile || isRelative) { break; } @@ -1980,7 +1985,7 @@ module ts { } } - function collectLinkedAliases(node: Identifier): Node[]{ + function collectLinkedAliases(node: Identifier): Node[] { var exportSymbol: Symbol; if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node); @@ -2014,11 +2019,36 @@ module ts { } } - function getRootDeclaration(node: Node): Node { - while (node.kind === SyntaxKind.BindingElement) { - node = node.parent.parent; + // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, + // a new entry with that target and an associated result value of true is pushed on the stack, and the value + // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and + // all entries pushed after it are changed to false, and the value false is returned. The target object provides + // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of + // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and + // Signature instances are used to track resolution of Signature.resolvedReturnType. + function pushTypeResolution(target: Object): boolean { + let i = 0; + let count = resolutionTargets.length; + while (i < count && resolutionTargets[i] !== target) { + i++; } - return node; + if (i < count) { + do { + resolutionResults[i++] = false; + } + while (i < count); + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + return true; + } + + // Pop an entry from the type resolution stack and return its associated result value. The result value will + // be true if no circularities were detected, or false if a circularity was found. + function popTypeResolution(): boolean { + resolutionTargets.pop(); + return resolutionResults.pop(); } function getDeclarationContainer(node: Node): Node { @@ -2271,20 +2301,27 @@ module ts { return links.type = checkExpression((declaration).expression); } // Handle variable, parameter or property - links.type = resolvingType; + if (!pushTypeResolution(symbol)) { + return unknownType; + } let type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - let diagnostic = (symbol.valueDeclaration).type ? - Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation : - Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer; - error(symbol.valueDeclaration, diagnostic, symbolToString(symbol)); + if (!popTypeResolution()) { + if ((symbol.valueDeclaration).type) { + // Variable has type annotation that circularly references the variable itself + type = unknownType; + error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, + symbolToString(symbol)); + } + else { + // Variable has initializer that circularly references the variable itself + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, + symbolToString(symbol)); + } + } } + links.type = type; } return links.type; } @@ -2308,19 +2345,13 @@ module ts { function getTypeOfAccessors(symbol: Symbol): Type { let links = getSymbolLinks(symbol); - checkAndStoreTypeOfAccessors(symbol, links); - return links.type; - } - - function checkAndStoreTypeOfAccessors(symbol: Symbol, links?: SymbolLinks) { - links = links || getSymbolLinks(symbol); if (!links.type) { - links.type = resolvingType; + if (!pushTypeResolution(symbol)) { + return unknownType; + } let getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); let setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); - let type: Type; - // First try to see if the user specified a return type on the get-accessor. let getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -2342,23 +2373,20 @@ module ts { if (compilerOptions.noImplicitAny) { error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); } - type = anyType; } } } - - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - let getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); - error(getter, 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)); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + let getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); + error(getter, 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)); + } } + links.type = type; } + return links.type; } function getTypeOfFuncClassEnumModule(symbol: Symbol): Type { @@ -2451,7 +2479,7 @@ module ts { return result; } - function getBaseTypes(type: InterfaceType): ObjectType[]{ + function getBaseTypes(type: InterfaceType): ObjectType[] { let typeWithBaseTypes = type; if (!typeWithBaseTypes.baseTypes) { if (type.symbol.flags & SymbolFlags.Class) { @@ -2536,17 +2564,18 @@ module ts { function getDeclaredTypeOfTypeAlias(symbol: Symbol): Type { let links = getSymbolLinks(symbol); if (!links.declaredType) { - links.declaredType = resolvingType; + // Note that we use the links object as the target here because the symbol object is used as the unique + // identity for resolution of the 'type' property in SymbolLinks. + if (!pushTypeResolution(links)) { + return unknownType; + } let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); let type = getTypeFromTypeNode(declaration.type); - if (links.declaredType === resolvingType) { - links.declaredType = type; + if (!popTypeResolution()) { + type = unknownType; + error(declaration.name, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } - } - else if (links.declaredType === resolvingType) { - links.declaredType = unknownType; - let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); - error(declaration.name, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + links.declaredType = type; } return links.declaredType; } @@ -3150,7 +3179,9 @@ module ts { function getReturnTypeOfSignature(signature: Signature): Type { if (!signature.resolvedReturnType) { - signature.resolvedReturnType = resolvingType; + if (!pushTypeResolution(signature)) { + return unknownType; + } let type: Type; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); @@ -3161,28 +3192,26 @@ module ts { else { type = getReturnTypeFromBody(signature.declaration); } - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = type; - } - } - else if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = anyType; - if (compilerOptions.noImplicitAny) { - let declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, declarationNameToString(declaration.name)); - } - else { - error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + let declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, declarationNameToString(declaration.name)); + } + else { + error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); + } } } + signature.resolvedReturnType = type; } return signature.resolvedReturnType; } function getRestTypeOfSignature(signature: Signature): Type { if (signature.hasRestParameter) { - let type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + let type = getTypeOfSymbol(lastOrUndefined(signature.parameters)); if (type.flags & TypeFlags.Reference && (type).target === globalArrayType) { return (type).typeArguments[0]; } @@ -5349,20 +5378,43 @@ module ts { if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } - // Target type is type of prototype property + + let targetType: Type; let prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (!prototypeProperty) { - return type; + if (prototypeProperty) { + // Target type is type of the protoype property + let prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (prototypePropertyType !== anyType) { + targetType = prototypePropertyType; + } } - let targetType = getTypeOfSymbol(prototypeProperty); - // Narrow to target type if it is a subtype of current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; + + if (!targetType) { + // Target type is type of construct signature + let constructSignatures: Signature[]; + if (rightType.flags & TypeFlags.Interface) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & TypeFlags.Anonymous) { + constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct); + } + + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(map(constructSignatures, signature => getReturnTypeOfSignature(getErasedSignature(signature)))); + } } - // If current type is a union type, remove all constituents that aren't subtypes of target type - if (type.flags & TypeFlags.Union) { - return getUnionType(filter((type).types, t => isTypeSubtypeOf(t, targetType))); + + if (targetType) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (type.flags & TypeFlags.Union) { + return getUnionType(filter((type).types, t => isTypeSubtypeOf(t, targetType))); + } } + return type; } @@ -5666,7 +5718,7 @@ module ts { // If last parameter is contextually rest parameter get its type if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + return getTypeOfSymbol(lastOrUndefined(contextualSignature.parameters)); } } } @@ -7215,9 +7267,9 @@ module ts { links.type = instantiateType(getTypeAtPosition(context, i), mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - let parameter = signature.parameters[signature.parameters.length - 1]; + let parameter = lastOrUndefined(signature.parameters); let links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); + links.type = instantiateType(getTypeOfSymbol(lastOrUndefined(context.parameters)), mapper); } } @@ -7342,10 +7394,9 @@ module ts { if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type) { - signature.resolvedReturnType = resolvingType; + if (!node.type && !signature.resolvedReturnType) { let returnType = getReturnTypeFromBody(node, contextualMapper); - if (signature.resolvedReturnType === resolvingType) { + if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } @@ -8359,8 +8410,7 @@ module ts { } } } - - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + getTypeOfAccessors(getSymbolOfNode(node)); } checkFunctionLikeDeclaration(node); @@ -9149,13 +9199,6 @@ module ts { } } - function isParameterDeclaration(node: VariableLikeDeclaration) { - while (node.kind === SyntaxKind.BindingElement) { - node = node.parent.parent; - } - return node.kind === SyntaxKind.Parameter; - } - // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node: VariableLikeDeclaration): void { if (getRootDeclaration(node).kind !== SyntaxKind.Parameter) { @@ -12829,7 +12872,7 @@ module ts { function checkGrammarBindingElement(node: BindingElement) { if (node.dotDotDotToken) { let elements = (node.parent).elements; - if (node !== elements[elements.length - 1]) { + if (node !== lastOrUndefined(elements)) { return grammarErrorOnNode(node, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 15a67db77e0..7a589fe61cb 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -66,15 +66,29 @@ module ts { paramType: Diagnostics.KIND, error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd }, + { + name: "newLine", + type: { + "crlf": NewLineKind.CarriageReturnLineFeed, + "lf": NewLineKind.LineFeed + }, + description: Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: Diagnostics.NEWLINE, + error: Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF + }, { name: "noEmit", type: "boolean", description: Diagnostics.Do_not_emit_outputs, }, + { + name: "noEmitHelpers", + type: "boolean" + }, { name: "noEmitOnError", type: "boolean", - description: Diagnostics.Do_not_emit_outputs_if_any_type_checking_errors_were_reported, + description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noImplicitAny", diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6383108b0d6..9fe9747fb57 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -470,7 +470,7 @@ module ts { let normalized: string[] = []; for (let part of parts) { if (part !== ".") { - if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); } else { @@ -586,7 +586,7 @@ module ts { export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) { let pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); let directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name // that is ["test", "cases", ""] needs to be actually ["test", "cases"] directoryComponents.length--; @@ -640,16 +640,18 @@ module ts { return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } - let supportedExtensions = [".d.ts", ".ts", ".js"]; + /** + * List of supported extensions in order of file resolution precedence. + */ + export const supportedExtensions = [".ts", ".d.ts"]; + const extensionsToRemove = [".d.ts", ".ts", ".js"]; export function removeFileExtension(path: string): string { - for (let ext of supportedExtensions) { - + for (let ext of extensionsToRemove) { if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } } - return path; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 98b5a170ae6..32dc590eeec 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -363,6 +363,8 @@ module ts { An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "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: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -442,8 +444,8 @@ module ts { Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, + Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, @@ -463,7 +465,7 @@ module ts { Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: DiagnosticCategory.Message, key: "Do not emit outputs if any type checking errors were reported." }, + Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." }, Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, @@ -496,12 +498,15 @@ module ts { Corrupted_locale_file_0: { code: 6051, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, - File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -514,7 +519,6 @@ module ts { Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{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." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 60d8e8e6515..a3dfd62d34e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1440,6 +1440,14 @@ "category": "Error", "code": 2501 }, + "'{0}' is referenced directly or indirectly in its own type annotation.": { + "category": "Error", + "code": 2502 + }, + "Cannot find namespace '{0}'.": { + "category": "Error", + "code": 2503 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -1757,11 +1765,11 @@ "category": "Error", "code": 5033 }, - "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option.": { + "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option.": { "category": "Error", "code": 5038 }, - "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option.": { + "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option.": { "category": "Error", "code": 5039 }, @@ -1842,7 +1850,7 @@ "category": "Message", "code": 6007 }, - "Do not emit outputs if any type checking errors were reported.": { + "Do not emit outputs if any errors were reported.": { "category": "Message", "code": 6008 }, @@ -1974,7 +1982,7 @@ "category": "Error", "code": 6053 }, - "File '{0}' must have extension '.ts' or '.d.ts'.": { + "File '{0}' has unsupported extension. The only supported extensions are {1}.": { "category": "Error", "code": 6054 }, @@ -1998,6 +2006,18 @@ "category": "Error", "code": 6059 }, + "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix).": { + "category": "Message", + "code": 6060 + }, + "NEWLINE": { + "category": "Message", + "code": 6061 + }, + "Argument for '--newLine' option must be 'CRLF' or 'LF'.": { + "category": "Error", + "code": 6062 + }, "Variable '{0}' implicitly has an '{1}' type.": { @@ -2048,10 +2068,6 @@ "category": "Error", "code": 7020 }, - "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.": { - "category": "Error", - "code": 7021 - }, "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.": { "category": "Error", "code": 7022 diff --git a/src/compiler/emitter.js b/src/compiler/emitter.js deleted file mode 100644 index 9a6b96640c9..00000000000 --- a/src/compiler/emitter.js +++ /dev/null @@ -1,5229 +0,0 @@ -/// -/// -/* @internal */ -var ts; -(function (ts) { - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile) { - // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; - // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = this.__decorate || (typeof Reflect === \"object\" && Reflect.decorate) || function (decorators, target, key, desc) {\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = this.__metadata || (typeof Reflect === \"object\" && Reflect.metadata) || function () { };"; - // emit output for the __param helper function - var paramHelper = "\nvar __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); - } - } - else { - // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); - } - } - // Sort and make the unique list of diagnostics - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - // name of an exporter function if file is a System external module - // System.register([...], function () {...}) - // exporting in System modules looks like: - // export var x; ... x = 1 - // => - // var x;... exporter("x", x = 1) - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - /** write emitted output to disk*/ - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - /** Emit a node */ - var emit = emitNodeWithoutSourceMap; - /** Called just before starting emit of a node */ - var emitStart = function (node) { }; - /** Called once the emit of the node is done */ - var emitEnd = function (node) { }; - /** Emit the text for the given token that comes after startPos - * This by default writes the text provided with the given tokenKind - * but if optional emitFn callback is provided the text is emitted using the callback instead of default text - * @param tokenKind the kind of the token to search and emit - * @param startPos the position in the source to start searching for the token - * @param emitFn if given will be invoked to emit the text instead of actual token emit */ - var emitToken = emitTokenText; - /** Called to before starting the lexical scopes as in function/class in the emitted code because of node - * @param scopeDeclaration node that starts the lexical scope - * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - /** Called after coming out of the scope */ - var scopeEmitEnd = function () { }; - /** Sourcemap data that will get encoded */ - var sourceMapData; - if (compilerOptions.sourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - // Do not call emit directly. It does not set the currentSourceFile. - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - // Return the next available name in the pattern _a ... _z, _0, _1, ... - // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name)) { - tempFlags |= flags; - return name; - } - } - while (true) { - var count = tempFlags & 268435455 /* CountMask */; - tempFlags++; - // Skip over 'i' and 'n' - if (count !== 8 && count !== 13) { - var name_1 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_1)) { - return name_1; - } - } - } - } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. - function makeUniqueName(baseName) { - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65 /* Identifier */) { - var name_2 = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_2, node) ? name_2 : makeUniqueName(name_2)); - } - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); - } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65 /* Identifier */) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - function generateNameForNode(node) { - switch (node.kind) { - case 200 /* FunctionDeclaration */: - case 201 /* ClassDeclaration */: - case 174 /* ClassExpression */: - generateNameForFunctionOrClassDeclaration(node); - break; - case 205 /* ModuleDeclaration */: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 204 /* EnumDeclaration */: - generateNameForModuleOrEnum(node); - break; - case 209 /* ImportDeclaration */: - generateNameForImportDeclaration(node); - break; - case 215 /* ExportDeclaration */: - generateNameForExportDeclaration(node); - break; - case 214 /* ExportAssignment */: - generateNameForExportAssignment(node); - break; - } - } - function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex = -1; - // Names and its index map - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; - } - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - // Convert the location to be one-based. - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - // 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; - } - } - function recordEmitNodeStartSpan(node) { - // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(node.fileName); - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - // Child scopes are always shown with a dot (even if they have no name), - // unless it is a computed property. Then it is shown with brackets, - // but the brackets are included in the name. - var name_3 = node.name; - if (!name_3 || name_3.kind !== 127 /* ComputedPropertyName */) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - // The scope was already given a name use it - recordScopeNameStart(scopeName); - } - else if (node.kind === 200 /* FunctionDeclaration */ || - node.kind === 162 /* FunctionExpression */ || - node.kind === 134 /* MethodDeclaration */ || - node.kind === 133 /* MethodSignature */ || - node.kind === 136 /* GetAccessor */ || - node.kind === 137 /* SetAccessor */ || - node.kind === 205 /* ModuleDeclaration */ || - node.kind === 201 /* ClassDeclaration */ || - node.kind === 204 /* EnumDeclaration */) { - // Declaration and has associated name use it - if (node.name) { - var name_4 = node.name; - // For computed property names, the text will include the brackets - scopeName = name_4.kind === 127 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_4) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - // Block just use the name from upper level scope - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { - if (typeof JSON !== "undefined") { - return JSON.stringify({ - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - // Write source map file - encodeLastRecordedSourceMapSpan(); - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); - sourceMapDataList.push(sourceMapData); - // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); - } - // Initialize source map data - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapDecodedMappings: [] - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); - } - if (node.kind != 227 /* SourceFile */) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); - } - } - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - // Create a temporary variable with a unique unused name. - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(65 /* Identifier */); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - emitNode(nodes[start + i]); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - case 111 /* o */: - case 79 /* O */: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if (compilerOptions.sourceMap && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - // Any template literal or string literal with an extended escape - // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES6 */ && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - // If we don't need to downlevel and we can reach the original source text using - // the node's parent reference, then simply get the text as it was originally written. - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - // If we can't reach the original source text, use the canonical form if it's a number, - // or an escaped quoted form of the original text if it's string-like. - switch (node.kind) { - case 8 /* StringLiteral */: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText('`', node.text, '`'); - case 11 /* TemplateHead */: - return getQuotedEscapedLiteralText('`', node.text, '${'); - case 12 /* TemplateMiddle */: - return getQuotedEscapedLiteralText('}', node.text, '${'); - case 13 /* TemplateTail */: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7 /* NumericLiteral */: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - // Find original source text, since we need to emit the raw strings of the tagged template. - // The raw strings contain the (escaped) strings of what the user wrote. - // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 10 /* NoSubstitutionTemplateLiteral */ || node.kind === 13 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - // Newline normalization: - // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's - // and LineTerminatorSequences are normalized to for both TV and TRV. - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write('"' + text + '"'); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - // Now we emit the expressions - if (node.template.kind === 171 /* TemplateExpression */) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 169 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - // In ES6 mode and above, we can simply emit each portion of a template in order, but in - // ES3 & ES5 we must convert the template expression into a series of string concatenations. - if (languageVersion >= 2 /* ES6 */) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - // Check if the expression has operands and binds its operands less closely than binary '+'. - // If it does, we need to wrap the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 161 /* 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 - // expression will be the first to be emitted. Don't emit the preceding ' + ' in that - // case. - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 157 /* CallExpression */: - case 158 /* NewExpression */: - return parent.expression === template; - case 159 /* TaggedTemplateExpression */: - case 161 /* ParenthesizedExpression */: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; - } - } - /** - * Returns whether the expression has lesser, greater, - * or equal precedence to the binary '+' operator - */ - function comparePrecedenceToBinaryPlus(expression) { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' - // which have greater precedence and '-' which has equal precedence. - // All unary operators have a higher precedence apart from yield. - // Arrow functions and conditionals have a lower precedence, - // although we convert the former into regular function expressions in ES5 mode, - // and in ES6 mode this function won't get called anyway. - // - // 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 169 /* BinaryExpression */: - switch (expression.operatorToken.kind) { - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: - return 1 /* GreaterThan */; - case 33 /* PlusToken */: - case 34 /* MinusToken */: - return 0 /* EqualTo */; - default: - return -1 /* LessThan */; - } - case 172 /* YieldExpression */: - case 170 /* ConditionalExpression */: - return -1 /* LessThan */; - default: - return 1 /* GreaterThan */; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. - // 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 !== 152 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { - emitLiteral(node); - } - else if (node.kind === 127 /* 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: - // - // class C { - // [_a = x]() { } - // } - // - // The emit for the decorated computed property decorator is: - // - // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); - // - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - // we have already generated a variable for this node, write that value instead. - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0 /* Auto */).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 7 /* NumericLiteral */) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isNotExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 129 /* Parameter */: - case 198 /* VariableDeclaration */: - case 152 /* BindingElement */: - case 132 /* PropertyDeclaration */: - case 131 /* PropertySignature */: - case 224 /* PropertyAssignment */: - case 225 /* ShorthandPropertyAssignment */: - case 226 /* EnumMember */: - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - case 200 /* FunctionDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 162 /* FunctionExpression */: - case 201 /* ClassDeclaration */: - case 202 /* InterfaceDeclaration */: - case 204 /* EnumDeclaration */: - case 205 /* ModuleDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 210 /* ImportClause */: - case 211 /* NamespaceImport */: - return parent.name === node; - case 213 /* ImportSpecifier */: - case 217 /* ExportSpecifier */: - return parent.name === node || parent.propertyName === node; - case 190 /* BreakStatement */: - case 189 /* ContinueStatement */: - case 214 /* ExportAssignment */: - return false; - case 194 /* LabeledStatement */: - return node.parent.label === node; - } - } - function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); - return; - } - } - if (!node.parent) { - write(node.text); - } - else if (!isNotExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2 /* ES6 */) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 16 /* SuperInstance */) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName, false); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(110 /* YieldKeyword */)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 65 /* Identifier */: - case 153 /* ArrayLiteralExpression */: - case 155 /* PropertyAccessExpression */: - case 156 /* ElementAccessExpression */: - case 157 /* CallExpression */: - case 161 /* 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; - } - return true; - } - function emitListWithSpread(elements, multiLine, trailingComma) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - // Emit using the pattern .concat(, , ...) - if (group === 1) { - write(".concat("); - } - else if (group > 1) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 173 /* SpreadElementExpression */) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - } - else { - var i = pos; - while (i < length && elements[i].kind !== 173 /* SpreadElementExpression */) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - write(")"); - } - } - function isSpreadElementExpression(node) { - return node.kind === 173 /* SpreadElementExpression */; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, (node.flags & 512 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - // If we are not doing a downlevel transformation for object literals, - // then try to preserve the original shape of the object literal. - // Otherwise just try to preserve the formatting. - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); - } - else { - var multiLine = (node.flags & 512 /* MultiLine */) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 512 /* MultiLine */) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var tempVar = createAndRecordTempVariable(0 /* Auto */); - // Write out the first non-computed properties - // (or all properties if none of them are computed), - // then emit the rest through indexing on the temp variable. - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 136 /* GetAccessor */ || property.kind === 137 /* SetAccessor */) { - // TODO (drosen): Reconcile with 'emitMemberFunctions'. - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 224 /* PropertyAssignment */) { - emit(property.initializer); - } - else if (property.kind === 225 /* ShorthandPropertyAssignment */) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 134 /* MethodDeclaration */) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2 /* ES6 */) { - var numProperties = properties.length; - // Find the first computed property. - // 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 === 127 /* ComputedPropertyName */) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - // Ordinary case: either the object has no computed properties - // or we're compiling with an ES6+ target. - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(169 /* BinaryExpression */, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(155 /* PropertyAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(156 /* ElementAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: - // - // NewExpression: - // new C.x -> not the same as (new C).x - // NumberLiteral - // 1.x -> not the same as (1).x - // - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 158 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { - return expr; - } - var node = ts.createSynthesizedNode(161 /* ParenthesizedExpression */); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - emit(node.name, false); - if (languageVersion < 2 /* ES6 */) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name, false); - write(": "); - emit(node.initializer); - } - function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // export let obj = { y }; - // } - // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (languageVersion < 2 /* ES6 */) { - // Emit identifier as an identifier - write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - // Emit identifier as an identifier - write(": "); - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); - } - } - function tryEmitConstantValue(node) { - if (compilerOptions.separateCompilation) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 155 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be - // emitted instead. - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - // Always use a newline for synthesized code if the synthesizer desires it. - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - write("."); - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 173 /* SpreadElementExpression */; }); - } - function skipParentheses(node) { - while (node.kind === 161 /* ParenthesizedExpression */ || node.kind === 160 /* TypeAssertionExpression */) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 65 /* Identifier */ || node.kind === 93 /* ThisKeyword */ || node.kind === 91 /* SuperKeyword */) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 155 /* PropertyAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 156 /* ElementAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 91 /* SuperKeyword */) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 91 /* SuperKeyword */) { - // Calls of form super(...) and super.foo(...) - emitThis(target); - } - else { - // Calls of form obj.foo(...) - emit(target); - } - } - else { - // Calls of form foo(...) - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 91 /* SuperKeyword */) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 155 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; - } - if (superCall && languageVersion < 2 /* ES6 */) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2 /* ES6 */) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 163 /* ArrowFunction */) { - if (node.expression.kind === 160 /* TypeAssertionExpression */) { - var operand = node.expression.expression; - // Make sure we consider all nested cast expressions, e.g.: - // (-A).x; - while (operand.kind == 160 /* TypeAssertionExpression */) { - operand = operand.expression; - } - // We have an expression of the form: (SubExpr) - // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. - // Omitting the parentheses, however, could cause change in the semantics of the generated - // code if the casted expression has a lower precedence than the rest of the expression, e.g.: - // (new A).foo should be emitted as (new A).foo and not new A.foo - // (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 !== 167 /* PrefixUnaryExpression */ && - operand.kind !== 166 /* VoidExpression */ && - operand.kind !== 165 /* TypeOfExpression */ && - operand.kind !== 164 /* DeleteExpression */ && - operand.kind !== 168 /* PostfixUnaryExpression */ && - operand.kind !== 158 /* NewExpression */ && - !(operand.kind === 157 /* CallExpression */ && node.parent.kind === 158 /* NewExpression */) && - !(operand.kind === 162 /* FunctionExpression */ && node.parent.kind === 157 /* CallExpression */)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(74 /* DeleteKeyword */)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(99 /* VoidKeyword */)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(97 /* TypeOfKeyword */)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 198 /* VariableDeclaration */ || node.parent.kind === 152 /* BindingElement */); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemExternalModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // emit - // ++x - // as - // exports('x', ++x) - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - // In some cases, we need to emit a space between the operator and the operand. One obvious case - // is when the operator is an identifier, like delete or typeof. We also need to do this for plus - // and minus expressions in certain cases. Specifically, consider the following two cases (parens - // are just for clarity of exposition, and not part of the source code): - // - // (+(+1)) - // (+(++1)) - // - // We need to emit a space in both cases. In the first case, the absence of a space will make - // 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 === 167 /* PrefixUnaryExpression */) { - var operand = node.operand; - if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { - write(" "); - } - else if (node.operator === 34 /* MinusToken */ && (operand.operator === 34 /* MinusToken */ || operand.operator === 39 /* MinusMinusToken */)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 38 /* PlusPlusToken */) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - /* - * Checks if given node is a source file level declaration (not nested in module/function). - * If 'isExported' is true - then declaration must also be exported. - * This function is used in two cases: - * - check if node is a exported source file level value to determine - * if we should also export the value after its it changed - * - check if node is a source level declaration to emit it differently, - * i.e non-exported variable statement 'var x = 1' is hoisted so - * we we emit variable statement 'var' should be dropped. - */ - function isSourceFileLevelDeclarationInSystemExternalModule(node, isExported) { - if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 227 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 206 /* ModuleBlock */) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 154 /* ObjectLiteralExpression */ || node.left.kind === 153 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 182 /* ExpressionStatement */); - } - else { - var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && - node.operatorToken.kind <= 64 /* LastAssignment */ && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - // emit assignment 'x y' as 'exports("x", x y)' - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - // Helper function to decrease the indent if we previously indented. Allows multiple - // previous indent values to be considered at a time. This also allows caller to just - // call this once, passing in all their appropriate indent values, instead of needing - // to call this helper function multiple times. - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 179 /* Block */) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); - write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); - return; - } - emitToken(14 /* OpenBraceToken */, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 206 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 205 /* ModuleDeclaration */); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 206 /* ModuleBlock */) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 179 /* Block */) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 163 /* ArrowFunction */); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(84 /* IfKeyword */, node.pos); - write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 183 /* IfStatement */) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 179 /* Block */) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - /* Returns true if start of variable declaration list was emitted. - * Return false if nothing was written - this can happen for source file level variable declarations - * in system modules - such variable declarations are hoisted. - */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - // variables in variable declaration list were already hoisted - return false; - } - var tokenKind = 98 /* VarKeyword */; - if (decl && languageVersion >= 2 /* ES6 */) { - if (ts.isLet(decl)) { - tokenKind = 104 /* LetKeyword */; - } - else if (ts.isConst(decl)) { - tokenKind = 70 /* ConstKeyword */; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 98 /* VarKeyword */: - write("var "); - break; - case 104 /* LetKeyword */: - write("let "); - break; - case 70 /* ConstKeyword */: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _i = 0, _a = list.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(82 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 199 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.iterator); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 188 /* ForOfStatement */) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(82 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 199 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 187 /* ForInStatement */) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(82 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - // Do not emit the LHS let declaration yet, because it might contain destructuring. - // Do not call recordTempDeclaration because we are declaring the temps - // right here. Recording means they will be declared later. - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 65 /* Identifier */; - var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); - // This is the let keyword for the counter and rhsReference. The let keyword for - // the LHS will be emitted inside the body. - emitStart(node.expression); - write("var "); - // _i = 0 - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - // _i < _a.length; - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithoutSourceMap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - // _i++) - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); - // Body - write(" {"); - writeLine(); - increaseIndent(); - // Initialize LHS - // let v = _a[_i]; - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 199 /* VariableDeclarationList */) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - emitNodeWithoutSourceMap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // It's an empty declaration list. This can only happen in an error case, if the user wrote - // for (let of []) {} - emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 153 /* ArrayLiteralExpression */ || node.initializer.kind === 154 /* 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, true, undefined); - } - else { - emitNodeWithoutSourceMap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 179 /* Block */) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 190 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(90 /* ReturnKeyword */, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(92 /* SwitchKeyword */, node.pos); - write(" "); - emitToken(16 /* OpenParenToken */, endPos); - emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 220 /* CaseClause */) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(68 /* CatchKeyword */, node.pos); - write(" "); - emitToken(16 /* OpenParenToken */, endPos); - emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(72 /* DebuggerKeyword */, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 205 /* ModuleDeclaration */); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 3 /* System */) { - write("exports."); - } - } - emitNodeWithoutSourceMap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); - zero.text = "0"; - var result = ts.createSynthesizedNode(166 /* VoidExpression */); - result.expression = zero; - return result; - } - function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - if (compilerOptions.module === 3 /* System */) { - // emit export default as - // export("default", ) - write(exportFunctionForFile + "(\""); - if (node.flags & 256 /* Default */) { - write("default"); - } - else { - emitNodeWithoutSourceMap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 256 /* Default */) { - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - writeLine(); - emitStart(specifier.name); - if (compilerOptions.module === 3 /* System */) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - } - else { - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } - write(";"); - } - } - } - 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 - // temporary variables in an exported declaration need to have real declarations elsewhere - // 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 === 198 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; - var isSourceLevelForSystemModuleKind = isSourceFileLevelDeclarationInSystemExternalModule(root, false); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 129 /* Parameter */) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 169 /* BinaryExpression */) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 198 /* VariableDeclaration */ || name.parent.kind === 152 /* BindingElement */); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function ensureIdentifier(expr) { - if (expr.kind !== 65 /* Identifier */) { - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - expr = identifier; - } - return expr; - } - function createDefaultValueCheck(value, defaultValue) { - // The value expression will be evaluated twice, so for anything but a simple identifier - // we need to generate a temporary variable - value = ensureIdentifier(value); - // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(169 /* BinaryExpression */); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(170 /* ConditionalExpression */); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(51 /* ColonToken */); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65 /* Identifier */) { - return createElementAccessExpression(object, propName); - } - return createPropertyAccessExpression(object, propName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(157 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - 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); - } - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; - if (p.kind === 224 /* PropertyAssignment */ || p.kind === 225 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var propName = (p.name); - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - 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); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 175 /* OmittedExpression */) { - if (e.kind !== 173 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 169 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 154 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 153 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 161 /* ParenthesizedExpression */) { - write("("); - } - value = ensureIdentifier(value); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 161 /* ParenthesizedExpression */) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - // Use 'void 0' in absence of value and initializer - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.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); - } - for (var i = 0; i < elements.length; i++) { - var element = elements[i]; - if (pattern.kind === 150 /* 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 !== 175 /* OmittedExpression */) { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - renameNonTopLevelLetAndConst(node.name); - var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isUninitializedLet && - node.parent.parent.kind !== 187 /* ForInStatement */ && - node.parent.parent.kind !== 188 /* ForOfStatement */) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 175 /* OmittedExpression */) { - return; - } - var name = node.name; - if (name.kind === 65 /* Identifier */) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function renameNonTopLevelLetAndConst(node) { - // do not rename if - // - language version is ES6+ - // - node is synthesized - // - node is not identifier (can happen when tree is malformed) - // - node is definitely not name of variable declaration. - // it still can be part of parameter declaration, this check will be done next - if (languageVersion >= 2 /* ES6 */ || - ts.nodeIsSynthesized(node) || - node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288 /* BlockScoped */) === 0) || combinedFlags & 1 /* Export */) { - // do not rename exported or non-block scoped variables - return; - } - // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 199 /* VariableDeclarationList */); - if (list.parent.kind === 180 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 227 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 206 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 179 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 227 /* SourceFile */ - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && - languageVersion >= 2 /* ES6 */ && - node.parent.kind === 227 /* SourceFile */; - } - function emitVariableStatement(node) { - var startIsEmitted = true; - if (!(node.flags & 1 /* Export */)) { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - else if (isES6ExportedDeclaration(node)) { - // Exported ES6 module member - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function emitParameter(node) { - if (languageVersion < 2 /* ES6 */) { - if (ts.isBindingPattern(node.name)) { - var name_5 = createTempVariable(0 /* Auto */); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_5); - emit(name_5); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; - ts.forEach(node.parameters, function (p) { - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (p.dotDotDotToken) { - return; - } - if (ts.isBindingPattern(p.name)) { - writeLine(); - write("var "); - emitDestructuring(p, false, tempParameters[tempIndex]); - write(";"); - tempIndex++; - } - else if (p.initializer) { - writeLine(); - emitStart(p); - write("if ("); - emitNodeWithoutSourceMap(p.name); - write(" === void 0)"); - emitEnd(p); - write(" { "); - emitStart(p); - emitNodeWithoutSourceMap(p.name); - write(" = "); - emitNodeWithoutSourceMap(p.initializer); - emitEnd(p); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 /* ES6 */ && ts.hasRestParameters(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456 /* _i */).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithoutSourceMap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 136 /* GetAccessor */ ? "get " : "set "); - emit(node.name, false); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 163 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithoutSourceMap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 162 /* FunctionExpression */) { - // Emit name if one is present - return !!node.name; - } - if (node.kind === 200 /* FunctionDeclaration */) { - // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || languageVersion < 2 /* ES6 */; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration - emitLeadingComments(node); - } - // For targeting below es6, emit functions-like declaration including arrow function using function keyword. - // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 256 /* Default */) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 200 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameters(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - // Check whether the parameter list needs parentheses and preserve no-parenthesis - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else if (node.body.kind === 179 /* Block */) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - // Returns true if any preamble code was emitted. - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - // For es6 and higher we can emit the expression as is. However, in the case - // where the expression might end up looking like a block when emitted, we'll - // also wrap it in parentheses first. For example if you have: a => {} - // then we need to generate: a => ({}) - write(" "); - // Unwrap all type assertions. - var current = body; - while (current.kind === 160 /* TypeAssertionExpression */) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 154 /* ObjectLiteralExpression */); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - // If we didn't have to emit any preamble code, then attempt to keep the arrow - // function on one line. - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(15 /* CloseBraceToken */, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 182 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 157 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 91 /* SuperKeyword */) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. - if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { - write("["); - emitNodeWithoutSourceMap(memberName); - write("]"); - } - else if (memberName.kind === 127 /* ComputedPropertyName */) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithoutSourceMap(memberName); - } - } - function getInitializedProperties(node, static) { - var properties = []; - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.kind === 132 /* PropertyDeclaration */ && static === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _i = 0; _i < properties.length; _i++) { - var property = properties[_i]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128 /* Static */) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 178 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - else if (member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) { - if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitStart(member); - emitFunctionDeclaration(member); - emitEnd(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 136 /* GetAccessor */ || member.kind === 137 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - if ((member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); - } - else if (member.kind === 134 /* MethodDeclaration */ || - member.kind === 136 /* GetAccessor */ || - member.kind === 137 /* SetAccessor */) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128 /* Static */) { - write("static "); - } - if (member.kind === 136 /* GetAccessor */) { - write("get "); - } - else if (member.kind === 137 /* SetAccessor */) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 178 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - // Check if we have property assignment inside class declaration. - // If there is property assignment, we need to emit constructor whether users define it or not - // If there is no property assignment, we can omit constructor if users do not define it - var hasInstancePropertyWithInitializer = false; - // Emit the constructor overload pinned comments - ts.forEach(node.members, function (member) { - if (member.kind === 135 /* Constructor */ && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); - } - // Check if there is any non-static property assignment - if (member.kind === 132 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - // For target ES6 and above, if there is no user-defined constructor and there is no property assignment - // do not emit constructor in class declaration. - if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2 /* ES6 */) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. - // If constructor is empty, then, - // If ClassHeritageopt is present, then - // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. - // Else, - // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2 /* ES6 */) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLines(statements); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 201 /* 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: - // - // * For a local class declaration: - // - // @dec class C { - // } - // - // The emit should be: - // - // let C = class { - // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // - // * For an exported class declaration: - // - // @dec export class C { - // } - // - // The emit should be: - // - // export let C = class { - // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; - // - if (isES6ExportedDeclaration(node) && !(node.flags & 256 /* Default */)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 256 /* Default */) { - write("default "); - } - } - } - // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: - // - // class C { static a = 1; static b = 2; ... } - // - // We'll emit: - // - // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) - // - // 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, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 174 /* ClassExpression */; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 256 /* Default */)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // - if (thisNodeIsDecorated) { - write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } - } - // Emit static property assignment. Because classDeclaration is lexically evaluated, - // it is safe to emit static property assignment after classDeclaration - // From ES6 specification: - // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using - // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - if (isClassExpressionWithStaticProperties) { - for (var _i = 0; _i < staticProperties.length; _i++) { - var property = staticProperties[_i]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 256 /* Default */) && thisNodeIsDecorated) { - // if this is a top level default export of decorated class, write the export after the declaration. - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 201 /* ClassDeclaration */) { - // source file level classes in system modules are hoisted so 'var's for them are already defined - if (!isSourceFileLevelDeclarationInSystemExternalModule(node, false)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 201 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - if (node.kind === 201 /* ClassDeclaration */) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128 /* Static */); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { - return; - } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = __decorate([dec], C); - // - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { - continue; - } - // skip members that cannot be decorated (such as the constructor) - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - // skip a member if it or any of its parameters are not decorated - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - // get the decorators from the first accessor with decorators - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - // we only decorate parameters of the set accessor - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - // we only decorate the parameters here if this is a method - if (member.kind === 134 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - // Emit the call to __decorate. Given the following: - // - // class C { - // @dec method(@dec2 x) {} - // @dec get accessor() {} - // @dec prop; - // } - // - // The emit for a method is: - // - // Object.defineProperty(C.prototype, "method", - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); - // - // The emit for an accessor is: - // - // Object.defineProperty(C.prototype, "accessor", - // __decorate([ - // dec - // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); - // - // The emit for a property is: - // - // __decorate([ - // dec - // ], C.prototype, "prop"); - // - writeLine(); - emitStart(member); - if (member.kind !== 132 /* PropertyDeclaration */) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 132 /* PropertyDeclaration */) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 134 /* MethodDeclaration */: - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - case 132 /* PropertyDeclaration */: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 134 /* MethodDeclaration */: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 201 /* ClassDeclaration */: - case 134 /* MethodDeclaration */: - case 137 /* SetAccessor */: - return true; - } - return false; - } - function emitSerializedTypeMetadata(node, writeComma) { - // This method emits the serialized type metadata for a decorator target. - // The caller should have already tested whether the node has decorators. - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); - if (serializedType) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; - } - } - if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); - if (serializedTypes) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - for (var i = 0; i < serializedTypes.length; ++i) { - if (i > 0) { - write(", "); - } - emitSerializedType(node, serializedTypes[i]); - } - write("])"); - argumentsWritten++; - } - } - if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); - if (serializedType) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; - } - } - } - return argumentsWritten; - } - function serializeTypeNameSegment(location, path, index) { - switch (index) { - case 0: - return "typeof " + path[index] + " !== 'undefined' && " + path[index]; - case 1: - return serializeTypeNameSegment(location, path, index - 1) + "." + path[index]; - default: - var temp = createAndRecordTempVariable(0 /* Auto */).text; - return "(" + temp + " = " + serializeTypeNameSegment(location, path, index - 1) + ") && " + temp + "." + path[index]; - } - } - function emitSerializedType(location, name) { - if (typeof name === "string") { - write(name); - return; - } - else { - ts.Debug.assert(name.length > 0, "Invalid serialized type name"); - write("(" + serializeTypeNameSegment(location, name, name.length - 1) + ") || Object"); - } - } - function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; - } - function emitEnumDeclaration(node) { - // const enums are completely erased during compilation. - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 205 /* ModuleDeclaration */) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 2048 /* LexicalModuleMergesWithClass */); - } - function emitModuleDeclaration(node) { - // Emit only if this module is non-ambient. - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var hoistedInDeclarationScope = isSourceFileLevelDeclarationInSystemExternalModule(node, false); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 206 /* ModuleBlock */) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 65 /* Identifier */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 3 /* System */ && (node.flags & 1 /* Export */)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(")"); - } - emitExportMemberAssignments(node.name); - } - } - function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { - write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 208 /* ImportEqualsDeclaration */) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 211 /* NamespaceImport */) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 209 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - return emitExternalImportDeclaration(node); - } - // ES6 import - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 211 /* NamespaceImport */) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 208 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2 /* AMD */) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - // import x = require("foo") - // import * as x from "foo" - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - // import "foo" - // import x from "foo" - // import { x, y } from "foo" - // import d, * as x from "foo" - // import d, { x, y } from "foo" - var isNakedImport = 209 /* ImportDeclaration */ && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when - // - current file is not external module - // - import declaration is top level and target is value imported by entity name - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1 /* Export */)) { - write("var "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 3 /* System */); - if (languageVersion < 2 /* ES6 */) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - // export { x, y, ... } from "foo" - if (compilerOptions.module !== 2 /* AMD */) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - // export * from "foo" - writeLine(); - write("__export("); - if (compilerOptions.module !== 2 /* AMD */) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); - write("export "); - if (node.exportClause) { - // export { x, y, ... } - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); - } - write(";"); - emitEnd(node); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2 /* ES6 */); - var needsComma = false; - for (var _i = 0; _i < specifiers.length; _i++) { - var specifier = specifiers[_i]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - emitStart(specifier); - if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); - write(" as "); - } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2 /* ES6 */) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 200 /* FunctionDeclaration */ && - expression.kind !== 201 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 3 /* System */) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var node = _a[_i]; - switch (node.kind) { - case 209 /* ImportDeclaration */: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced - externalImports.push(node); - } - break; - case 208 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 219 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 215 /* ExportDeclaration */: - if (node.moduleSpecifier) { - if (!node.exportClause) { - // export * from "mod" - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol - externalImports.push(node); - } - } - else { - // export { x, y } - for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { - var specifier = _c[_b]; - var name_6 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_6] || (exportSpecifiers[name_6] = [])).push(specifier); - } - } - break; - case 214 /* ExportAssignment */: - if (node.isExportEquals && !exportEquals) { - // export = x - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - else { - return getGeneratedNameForNode(importNode); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _i = 0; _i < externalImports.length; _i++) { - var importNode = externalImports[_i]; - // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 215 /* ExportDeclaration */ || - (importNode.kind === 209 /* ImportDeclaration */ && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function hoistTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: - // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method - // - var declarations are initialized to undefined - 14.a.ii - // - function/generator declarations are instantiated - 16.a.iv - // this means that after module is instantiated but before its evaluation - // exported functions are already accessible at import sites - // in theory we should hoist only exported functions and its dependencies - // in practice to simplify things we'll hoist all source level functions and variable declaration - // including variables declarations for module and class declarations - var hoistedVars; - var hoistedFunctionDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - if (i !== 0) { - write(", "); - } - if (local.kind === 201 /* ClassDeclaration */ || local.kind === 205 /* ModuleDeclaration */) { - emitDeclarationName(local); - } - else { - emit(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _i = 0; _i < hoistedFunctionDeclarations.length; _i++) { - var f = hoistedFunctionDeclarations[_i]; - writeLine(); - emit(f); - } - } - function visit(node) { - if (node.kind === 200 /* FunctionDeclaration */) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 201 /* ClassDeclaration */) { - // TODO: rename block scoped classes - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 205 /* ModuleDeclaration */ && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 198 /* VariableDeclaration */ || node.kind === 152 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { - var name_7 = node.name; - if (name_7.kind === 65 /* Identifier */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_7); - } - else { - ts.forEachChild(name_7, visit); - } - } - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !isSourceFileLevelDeclarationInSystemExternalModule(node, false)) { - return false; - } - // hoist variable if - // - it is not block scoped - // - it is top level block scoped - // 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) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 227 /* SourceFile */; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 3 /* System */ && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, startIndex) { - // shape of the body in system modules: - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // I.e: - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // will be transformed to - // function(exports) { - // var file1; // local alias - // var y; - // function foo() { return y + file1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - emitVariableDeclarationsForImports(); - writeLine(); - hoistTopLevelVariableAndFunctionDeclarations(node); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(); - writeLine(); - emitExecute(node, startIndex); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - write("}"); // return - } - function emitSetters() { - write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; - write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 209 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 208 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName); - writeLine(); - var defaultName = importNode.kind === 209 /* ImportDeclaration */ - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - // emit re-export for imported default name - // import n1 from 'foo1' - // import n2 = require('foo2') - // export {n1} - // export {n2} - emitExportMemberAssignments(defaultName); - writeLine(); - } - if (importNode.kind === 209 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 211 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); - writeLine(); - } - else { - // emit re-exports for named imports - // import {a, b} from 'foo' - // export {a, b as c} - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 215 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports('a', _foo["a"]) - // exports('c', _foo["b"]) - for (var _b = 0, _c = importNode.exportClause.elements; _b < _c.length; _b++) { - var e = _c[_b]; - writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); - } - } - else { - writeLine(); - // export * from 'foo' - // emit as: - // for (var n in _foo) exports(n, _foo[n]); - // NOTE: it is safe to use name 'n' since parameter name always starts with '_' - write("for (var n in " + parameterName + ") " + exportFunctionForFile + "(n, " + parameterName + "[n]);"); - } - writeLine(); - decreaseIndent(); - break; - } - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - // - imports/exports are not emitted for system modules - // - function declarations are not emitted because they were already hoisted - switch (statement.kind) { - case 215 /* ExportDeclaration */: - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 200 /* FunctionDeclaration */: - continue; - } - writeLine(); - emit(statement); - } - decreaseIndent(); - writeLine(); - write("}"); // execute - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - // System modules has the following shape - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. - // 'exports' returns its 'value' argument so in most cases expressions - // that mutate exported values can be rewritten as: - // expr -> exports('name', expr). - // The only exception in this rule is postfix unary operators, - // see comment to 'emitPostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // make sure that name of 'exports' function does not conflict with existing identifiers - exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDModule(node, startIndex) { - collectExternalModuleInfo(node); - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list - var aliasedModuleNames = []; // names of modules with corresponding parameter in the - // factory function. - var unaliasedModuleNames = []; // names of modules with no corresponding parameters in - // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _b = 0; _b < externalImports.length; _b++) { - var importNode = externalImports[_b]; - // Find the name of the external module - var externalModuleName = getExternalModuleNameText(importNode); - // Find the name of the module alias, if there is one - var importAliasName = getLocalNameForExternalImport(importNode); - if (importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - // Emit exportDefault if it exists will happen as part - // or normal statement emit. - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - // return index of the first non prologue directive - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); - // 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 */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (ts.isExternalModule(node)) { - if (languageVersion >= 2 /* ES6 */) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2 /* AMD */) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 3 /* System */) { - emitSystemModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { - if (!node) { - return; - } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); - if (emitComments) { - emitTrailingComments(node); - } - } - function shouldEmitLeadingAndTrailingComments(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 202 /* InterfaceDeclaration */: - case 200 /* FunctionDeclaration */: - case 209 /* ImportDeclaration */: - case 208 /* ImportEqualsDeclaration */: - case 203 /* TypeAliasDeclaration */: - case 214 /* ExportAssignment */: - return false; - case 205 /* ModuleDeclaration */: - // Only emit the leading/trailing comments for a module if we're actually - // emitting the module as well. - return shouldEmitModuleDeclaration(node); - case 204 /* EnumDeclaration */: - // Only emit the leading/trailing comments for an enum if we're actually - // emitting the module as well. - return shouldEmitEnumDeclaration(node); - } - // If this is the expression body of an arrow function that we're down-leveling, - // 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 !== 179 /* Block */ && - node.parent && - node.parent.kind === 163 /* ArrowFunction */ && - node.parent.body === node && - compilerOptions.target <= 1 /* ES5 */) { - return false; - } - // Emit comments for everything else. - return true; - } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } - // Check if the node can be emitted regardless of the ScriptTarget - switch (node.kind) { - case 65 /* Identifier */: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 129 /* Parameter */: - return emitParameter(node); - case 134 /* MethodDeclaration */: - case 133 /* MethodSignature */: - return emitMethod(node); - case 136 /* GetAccessor */: - case 137 /* SetAccessor */: - return emitAccessor(node); - case 93 /* ThisKeyword */: - return emitThis(node); - case 91 /* SuperKeyword */: - return emitSuper(node); - case 89 /* NullKeyword */: - return write("null"); - case 95 /* TrueKeyword */: - return write("true"); - case 80 /* FalseKeyword */: - return write("false"); - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 9 /* RegularExpressionLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 12 /* TemplateMiddle */: - case 13 /* TemplateTail */: - return emitLiteral(node); - case 171 /* TemplateExpression */: - return emitTemplateExpression(node); - case 176 /* TemplateSpan */: - return emitTemplateSpan(node); - case 126 /* QualifiedName */: - return emitQualifiedName(node); - case 150 /* ObjectBindingPattern */: - return emitObjectBindingPattern(node); - case 151 /* ArrayBindingPattern */: - return emitArrayBindingPattern(node); - case 152 /* BindingElement */: - return emitBindingElement(node); - case 153 /* ArrayLiteralExpression */: - return emitArrayLiteral(node); - case 154 /* ObjectLiteralExpression */: - return emitObjectLiteral(node); - case 224 /* PropertyAssignment */: - return emitPropertyAssignment(node); - case 225 /* ShorthandPropertyAssignment */: - return emitShorthandPropertyAssignment(node); - case 127 /* ComputedPropertyName */: - return emitComputedPropertyName(node); - case 155 /* PropertyAccessExpression */: - return emitPropertyAccess(node); - case 156 /* ElementAccessExpression */: - return emitIndexedAccess(node); - case 157 /* CallExpression */: - return emitCallExpression(node); - case 158 /* NewExpression */: - return emitNewExpression(node); - case 159 /* TaggedTemplateExpression */: - return emitTaggedTemplateExpression(node); - case 160 /* TypeAssertionExpression */: - return emit(node.expression); - case 161 /* ParenthesizedExpression */: - return emitParenExpression(node); - case 200 /* FunctionDeclaration */: - case 162 /* FunctionExpression */: - case 163 /* ArrowFunction */: - return emitFunctionDeclaration(node); - case 164 /* DeleteExpression */: - return emitDeleteExpression(node); - case 165 /* TypeOfExpression */: - return emitTypeOfExpression(node); - case 166 /* VoidExpression */: - return emitVoidExpression(node); - case 167 /* PrefixUnaryExpression */: - return emitPrefixUnaryExpression(node); - case 168 /* PostfixUnaryExpression */: - return emitPostfixUnaryExpression(node); - case 169 /* BinaryExpression */: - return emitBinaryExpression(node); - case 170 /* ConditionalExpression */: - return emitConditionalExpression(node); - case 173 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 172 /* YieldExpression */: - return emitYieldExpression(node); - case 175 /* OmittedExpression */: - return; - case 179 /* Block */: - case 206 /* ModuleBlock */: - return emitBlock(node); - case 180 /* VariableStatement */: - return emitVariableStatement(node); - case 181 /* EmptyStatement */: - return write(";"); - case 182 /* ExpressionStatement */: - return emitExpressionStatement(node); - case 183 /* IfStatement */: - return emitIfStatement(node); - case 184 /* DoStatement */: - return emitDoStatement(node); - case 185 /* WhileStatement */: - return emitWhileStatement(node); - case 186 /* ForStatement */: - return emitForStatement(node); - case 188 /* ForOfStatement */: - case 187 /* ForInStatement */: - return emitForInOrForOfStatement(node); - case 189 /* ContinueStatement */: - case 190 /* BreakStatement */: - return emitBreakOrContinueStatement(node); - case 191 /* ReturnStatement */: - return emitReturnStatement(node); - case 192 /* WithStatement */: - return emitWithStatement(node); - case 193 /* SwitchStatement */: - return emitSwitchStatement(node); - case 220 /* CaseClause */: - case 221 /* DefaultClause */: - return emitCaseOrDefaultClause(node); - case 194 /* LabeledStatement */: - return emitLabelledStatement(node); - case 195 /* ThrowStatement */: - return emitThrowStatement(node); - case 196 /* TryStatement */: - return emitTryStatement(node); - case 223 /* CatchClause */: - return emitCatchClause(node); - case 197 /* DebuggerStatement */: - return emitDebuggerStatement(node); - case 198 /* VariableDeclaration */: - return emitVariableDeclaration(node); - case 174 /* ClassExpression */: - return emitClassExpression(node); - case 201 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 202 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 204 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 226 /* EnumMember */: - return emitEnumMember(node); - case 205 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 209 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 208 /* ImportEqualsDeclaration */: - return emitImportEqualsDeclaration(node); - case 215 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 214 /* ExportAssignment */: - return emitExportAssignment(node); - case 227 /* SourceFile */: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - // If we're removing comments, then we want to strip out all but the pinned or - // triple slash comments. - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } - } - return ranges; - } - 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 === 227 /* SourceFile */ || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - // get comments without detached comments - return getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - 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 === 227 /* SourceFile */ || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); - } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - // If the caller only wants pinned or triple slash comments, then always filter - // down to that set. Otherwise, filter based on the current compiler options. - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitLeadingCommentsOfPosition(pos) { - var leadingComments; - if (hasDetachedComments(pos)) { - // get comments without detached comments - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7ebdb3026ce..59b6fcd7eb6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -18,7 +18,7 @@ module ts { export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { // emit output for the __extends helper function const extendsHelper = ` -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -27,7 +27,7 @@ var __extends = this.__extends || function (d, b) { // emit output for the __decorate helper function const decorateHelper = ` -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -38,13 +38,13 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target, // emit output for the __metadata helper function const metadataHelper = ` -if (typeof __metadata !== "function") __metadata = function (k, v) { +var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); };`; // emit output for the __param helper function const paramHelper = ` -if (typeof __param !== "function") __param = function (paramIndex, decorator) { +var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } };`; @@ -336,7 +336,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { let sourceMapNameIndexMap: Map = {}; let sourceMapNameIndices: number[] = []; function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; + return sourceMapNameIndices.length ? lastOrUndefined(sourceMapNameIndices) : -1; } // Last recorded and encoded spans @@ -1366,7 +1366,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { return true; } - function emitListWithSpread(elements: Expression[], multiLine: boolean, trailingComma: boolean) { + function emitListWithSpread(elements: Expression[], alwaysCopy: boolean, multiLine: boolean, trailingComma: boolean) { let pos = 0; let group = 0; let length = elements.length; @@ -1383,6 +1383,9 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { e = (e).expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; + if (pos === length && group === 0 && alwaysCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) { + write(".slice()"); + } } else { let i = pos; @@ -1422,7 +1425,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { write("]"); } else { - emitListWithSpread(elements, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, + emitListWithSpread(elements, /*alwaysCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, /*trailingComma*/ elements.hasTrailingComma); } } @@ -1847,7 +1850,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { write("void 0"); } write(", "); - emitListWithSpread(node.arguments, /*multiLine*/ false, /*trailingComma*/ false); + emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); write(")"); } @@ -2639,7 +2642,8 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { writeLine(); emitStart(node); - if (compilerOptions.module === ModuleKind.System) { + // emit call to exporter only for top level nodes + if (compilerOptions.module === ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(`${exportFunctionForFile}("`); @@ -3481,10 +3485,10 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { } } - function getInitializedProperties(node: ClassLikeDeclaration, static: boolean) { + function getInitializedProperties(node: ClassLikeDeclaration, isStatic: boolean) { let properties: PropertyDeclaration[] = []; for (let member of node.members) { - if (member.kind === SyntaxKind.PropertyDeclaration && static === ((member.flags & NodeFlags.Static) !== 0) && (member).initializer) { + if (member.kind === SyntaxKind.PropertyDeclaration && isStatic === ((member.flags & NodeFlags.Static) !== 0) && (member).initializer) { properties.push(member); } } @@ -3898,6 +3902,8 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { emitToken(SyntaxKind.CloseBraceToken, node.members.end); scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. + // For a decorated class, we need to assign its name (if it has one). This is because we emit // the class as a class expression to avoid the double-binding of the identifier: // @@ -3907,15 +3913,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { // if (thisNodeIsDecorated) { write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } } // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -4380,15 +4377,18 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { return; } - if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); } writeLine(); emitStart(node); @@ -4410,7 +4410,8 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & NodeFlags.Export) { + if (!isES6ExportedDeclaration(node) && node.flags & NodeFlags.Export && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted writeLine(); emitStart(node); write("var "); @@ -4421,6 +4422,15 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { write(";"); } if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { + if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + // write the call to exporter for enum + writeLine(); + write(`${exportFunctionForFile}("`); + emitDeclarationName(node); + write(`", `); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -5101,7 +5111,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { // in theory we should hoist only exported functions and its dependencies // in practice to simplify things we'll hoist all source level functions and variable declaration // including variables declarations for module and class declarations - let hoistedVars: (Identifier | ClassDeclaration | ModuleDeclaration)[]; + let hoistedVars: (Identifier | ClassDeclaration | ModuleDeclaration | EnumDeclaration)[]; let hoistedFunctionDeclarations: FunctionDeclaration[]; let exportedDeclarations: (Identifier | Declaration)[]; @@ -5110,13 +5120,30 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { if (hoistedVars) { writeLine(); write("var "); + let seen: Map = {}; for (let i = 0; i < hoistedVars.length; ++i) { let local = hoistedVars[i]; + let name = local.kind === SyntaxKind.Identifier + ? local + : (local).name; + + if (name) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + let text = unescapeIdentifier(name.text); + if (hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { write(", "); } - if (local.kind === SyntaxKind.ClassDeclaration || local.kind === SyntaxKind.ModuleDeclaration) { - emitDeclarationName(local); + + if (local.kind === SyntaxKind.ClassDeclaration || local.kind === SyntaxKind.ModuleDeclaration || local.kind === SyntaxKind.EnumDeclaration) { + emitDeclarationName(local); } else { emit(local); @@ -5150,6 +5177,10 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { return exportedDeclarations; function visit(node: Node): void { + if (node.flags & NodeFlags.Ambient) { + return; + } + if (node.kind === SyntaxKind.FunctionDeclaration) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; @@ -5160,7 +5191,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { } if (node.kind === SyntaxKind.ClassDeclaration) { - // TODO: rename block scoped classes if (!hoistedVars) { hoistedVars = []; } @@ -5169,12 +5199,26 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { return; } - if (node.kind === SyntaxKind.ModuleDeclaration && shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; + if (node.kind === SyntaxKind.EnumDeclaration) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node); } - hoistedVars.push(node); + return; + } + + if (node.kind === SyntaxKind.ModuleDeclaration) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node); + } return; } @@ -5614,24 +5658,28 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { // emit prologue directives prior to __extends var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - // 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)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); + // Only emit helpers if the user did not say otherwise. + 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)) { + writeLines(extendsHelper); + extendsEmitted = true; } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitParam) { - writeLines(paramHelper); - paramEmitted = true; + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + + if (!paramEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitParam) { + writeLines(paramHelper); + paramEmitted = true; + } } if (isExternalModule(node) || compilerOptions.separateCompilation) { @@ -5886,13 +5934,13 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { } function hasDetachedComments(pos: number) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + return detachedCommentsInfo !== undefined && lastOrUndefined(detachedCommentsInfo).nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { // get the leading comments from detachedPos let leadingComments = getLeadingCommentRanges(currentSourceFile.text, - detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -6013,13 +6061,13 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) { // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - let lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end); let nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - let currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; + let currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7d984a3dfa4..af9b486a1da 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -957,15 +957,6 @@ module ts { } function nextTokenCanFollowModifier() { - nextToken(); - return canFollowModifier(); - } - - function parseAnyContextualModifier(): boolean { - return isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); - } - - function nextTokenCanFollowContextualModifier() { if (token === SyntaxKind.ConstKeyword) { // 'const' is only a modifier if followed by 'enum'. return nextToken() === SyntaxKind.EnumKeyword; @@ -984,6 +975,10 @@ module ts { return canFollowModifier(); } + function parseAnyContextualModifier(): boolean { + return isModifier(token) && tryParse(nextTokenCanFollowModifier); + } + function canFollowModifier(): boolean { return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.OpenBraceToken @@ -1691,7 +1686,7 @@ module ts { do { templateSpans.push(parseTemplateSpan()); } - while (templateSpans[templateSpans.length - 1].literal.kind === SyntaxKind.TemplateMiddle) + while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle) templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cc2fe7ff190..f5bf44ec809 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -10,6 +10,9 @@ module ts { /** The version of the TypeScript compiler release */ export const version = "1.5.0"; + const carriageReturnLineFeed = "\r\n"; + const lineFeed = "\n"; + export function findConfigFile(searchPath: string): string { var fileName = "tsconfig.json"; while (true) { @@ -91,6 +94,11 @@ module ts { } } + let newLine = + options.newLine === NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed : + options.newLine === NewLineKind.LineFeed ? lineFeed : + sys.newLine; + return { getSourceFile, getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)), @@ -98,7 +106,7 @@ module ts { getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()), useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, getCanonicalFileName, - getNewLine: () => sys.newLine + getNewLine: () => newLine }; } @@ -211,7 +219,12 @@ module ts { // Create the emit resolver outside of the "emitTime" tracking code below. That way // any cost associated with it (like type checking) are appropriate associated with // the type-checking counter. - let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + // + // If the -out option is specified, we should not pass the source file to getEmitResolver. + // This is because in the -out scenario all files need to be emitted, and therefore all + // files need to be type checked. And the way to specify that all files need to be type + // checked is to not pass the file to getEmitResolver. + let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); let start = new Date().getTime(); @@ -225,7 +238,7 @@ module ts { } function getSourceFile(fileName: string) { - fileName = host.getCanonicalFileName(fileName); + fileName = host.getCanonicalFileName(normalizeSlashes(fileName)); return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; } @@ -299,45 +312,52 @@ module ts { function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) { let start: number; let length: number; + let extensions: string; + let diagnosticArgument: string[]; if (refEnd !== undefined && refPos !== undefined) { start = refPos; length = refEnd - refPos; } let diagnostic: DiagnosticMessage; if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !fileExtensionIs(host.getCanonicalFileName(fileName), ".ts")) { - diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts; + if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) { + diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; + diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { diagnostic = Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; } else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { diagnostic = Diagnostics.A_file_cannot_have_a_reference_to_itself; + diagnosticArgument = [fileName]; } } else { if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { diagnostic = Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; } - else if (!findSourceFile(fileName + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(fileName + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) { + else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd))) { diagnostic = Diagnostics.File_0_not_found; fileName += ".ts"; + diagnosticArgument = [fileName]; } } if (diagnostic) { if (refFile) { - diagnostics.add(createFileDiagnostic(refFile, start, length, diagnostic, fileName)); + diagnostics.add(createFileDiagnostic(refFile, start, length, diagnostic, ...diagnosticArgument)); } else { - diagnostics.add(createCompilerDiagnostic(diagnostic, fileName)); + diagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument)); } } } // Get source file from normalized fileName function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile { - let canonicalName = host.getCanonicalFileName(fileName); + let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName)); if (hasProperty(filesByName, canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); @@ -409,9 +429,10 @@ module ts { let moduleNameText = (moduleNameExpr).text; if (moduleNameText) { let searchPath = basePath; + let searchName: string; while (true) { - let searchName = normalizePath(combinePaths(searchPath, moduleNameText)); - if (findModuleSourceFile(searchName + ".ts", moduleNameExpr) || findModuleSourceFile(searchName + ".d.ts", moduleNameExpr)) { + searchName = normalizePath(combinePaths(searchPath, moduleNameText)); + if (forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, moduleNameExpr))) { break; } let parentPath = getDirectoryPath(searchPath); @@ -440,10 +461,7 @@ module ts { // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. let searchName = normalizePath(combinePaths(basePath, moduleName)); - let tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral); - if (!tsFile) { - findModuleSourceFile(searchName + ".d.ts", nameLiteral); - } + forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, nameLiteral)); } } }); @@ -556,10 +574,10 @@ module ts { if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); } return; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index f7224e619bb..1fc8bff92e6 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2,12 +2,10 @@ /// module ts { - /* @internal */ export interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } - /* @internal */ export interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -522,7 +520,7 @@ module ts { } collecting = true; if (result && result.length) { - result[result.length - 1].hasTrailingNewLine = true; + lastOrUndefined(result).hasTrailingNewLine = true; } continue; case CharacterCodes.tab: @@ -569,7 +567,7 @@ module ts { default: if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) { if (result && result.length && isLineBreak(ch)) { - result[result.length - 1].hasTrailingNewLine = true; + lastOrUndefined(result).hasTrailingNewLine = true; } pos++; continue; @@ -600,8 +598,7 @@ module ts { ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - // Creates a scanner over a (possibly unspecified) range of a piece of text. - /* @internal */ + /** Creates a scanner over a (possibly unspecified) range of a piece of text. */ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner { let pos: number; // Current position (end position of text of current token) let end: number; // end of text diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4799f314063..86e680ca8b0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1656,7 +1656,9 @@ module ts { locale?: string; mapRoot?: string; module?: ModuleKind; + newLine?: NewLineKind; noEmit?: boolean; + noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; noImplicitAny?: boolean; @@ -1688,6 +1690,11 @@ module ts { System = 4, } + export const enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, + } + export interface LineAndCharacter { line: number; /* diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5296f063a94..356337e1315 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -484,9 +484,6 @@ module ts { case SyntaxKind.IndexSignature: case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.FunctionDeclaration: return true; } } @@ -856,7 +853,7 @@ module ts { } export function hasRestParameters(s: SignatureDeclaration): boolean { - return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; + return s.parameters.length > 0 && lastOrUndefined(s.parameters).dotDotDotToken !== undefined; } export function isLiteralKind(kind: SyntaxKind): boolean { @@ -1149,6 +1146,18 @@ module ts { } return false; } + + export function isParameterDeclaration(node: VariableLikeDeclaration) { + let root = getRootDeclaration(node); + return root.kind === SyntaxKind.Parameter; + } + + export function getRootDeclaration(node: Node): Node { + while (node.kind === SyntaxKind.BindingElement) { + node = node.parent.parent; + } + return node; + } export function nodeStartsNewLexicalEnvironment(n: Node): boolean { return isFunctionLike(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile; @@ -1362,7 +1371,7 @@ module ts { let lineStartsOfS = computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + linePos = output.length - s.length + lastOrUndefined(lineStartsOfS); } } } @@ -1435,8 +1444,10 @@ module ts { export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.fileName, ".js")) { - return true; + if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + // 1. in-browser single file compilation scenario + // 2. non .js file + return compilerOptions.separateCompilation || !fileExtensionIs(sourceFile.fileName, ".js"); } return false; } @@ -1693,7 +1704,7 @@ module ts { } export function getLocalSymbolForExportDefault(symbol: Symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; } /** @@ -1727,8 +1738,8 @@ module ts { output.push(((charCode >> 6) & 0B00111111) | 0B10000000); output.push((charCode & 0B00111111) | 0B10000000); } - else { - Debug.assert(false, "Unexpected code point"); + else { + Debug.assert(false, "Unexpected code point"); } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c8f20746a07..ef4410b3e33 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -144,10 +144,10 @@ module FourSlash { if (globalOptions.hasOwnProperty(prop)) { switch (prop) { case metadataOptionNames.allowNonTsExtensions: - settings.allowNonTsExtensions = true; + settings.allowNonTsExtensions = globalOptions[prop] === "true"; break; case metadataOptionNames.declaration: - settings.declaration = true; + settings.declaration = globalOptions[prop] === "true"; break; case metadataOptionNames.mapRoot: settings.mapRoot = globalOptions[prop]; @@ -174,7 +174,7 @@ module FourSlash { settings.outDir = globalOptions[prop]; break; case metadataOptionNames.sourceMap: - settings.sourceMap = true; + settings.sourceMap = globalOptions[prop] === "true"; break; case metadataOptionNames.sourceRoot: settings.sourceRoot = globalOptions[prop]; @@ -308,7 +308,7 @@ module FourSlash { ts.forEach(testData.files, file => { // Create map between fileName and its content for easily looking up when resolveReference flag is specified this.inputFiles[file.fileName] = file.content; - if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference]) { + if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference] === "true") { startResolveFileRef = file; } else if (startResolveFileRef) { // If entry point for resolving file references is already specified, report duplication error @@ -1158,7 +1158,7 @@ module FourSlash { var allFourSlashFiles = this.testData.files; for (var idx = 0; idx < allFourSlashFiles.length; ++idx) { var file = allFourSlashFiles[idx]; - if (file.fileOptions[metadataOptionNames.emitThisFile]) { + if (file.fileOptions[metadataOptionNames.emitThisFile] === "true") { // Find a file with the flag emitThisFile turned on emitFiles.push(file); } @@ -1570,6 +1570,28 @@ module FourSlash { this.currentCaretPosition = definition.textSpan.start; } + public goToTypeDefinition(definitionIndex: number) { + if (definitionIndex === 0) { + this.scenarioActions.push(''); + } + else { + this.taoInvalidReason = 'GoToTypeDefinition not supported for non-zero definition indices'; + } + + var definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + if (!definitions || !definitions.length) { + this.raiseError('goToTypeDefinition failed - expected to at least one definition location but got 0'); + } + + if (definitionIndex >= definitions.length) { + this.raiseError('goToTypeDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')'); + } + + var definition = definitions[definitionIndex]; + this.openFile(definition.fileName); + this.currentCaretPosition = definition.textSpan.start; + } + public verifyDefinitionLocationExists(negative: boolean) { this.taoInvalidReason = 'verifyDefinitionLocationExists NYI'; @@ -1589,8 +1611,18 @@ module FourSlash { var assertFn = negative ? assert.notEqual : assert.equal; var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + var actualCount = definitions && definitions.length || 0; - assertFn(definitions.length, expectedCount, this.messageAtLastKnownMarker("Definitions Count")); + assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Definitions Count")); + } + + public verifyTypeDefinitionsCount(negative: boolean, expectedCount: number) { + var assertFn = negative ? assert.notEqual : assert.equal; + + var definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + var actualCount = definitions && definitions.length || 0; + + assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count")); } public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6af77e3d746..9ed515eb5b6 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -45,10 +45,10 @@ module Utils { export function getExecutionEnvironment() { if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return ExecutionEnvironment.CScript; - } else if (process && process.execPath && process.execPath.indexOf("node") !== -1) { - return ExecutionEnvironment.Node; - } else { + } else if (typeof window !== "undefined") { return ExecutionEnvironment.Browser; + } else { + return ExecutionEnvironment.Node; } } @@ -805,6 +805,9 @@ module Harness { return result; } + const carriageReturnLineFeed = "\r\n"; + const lineFeed = "\n"; + export var defaultLibFileName = 'lib.d.ts'; export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); @@ -822,7 +825,8 @@ module Harness { scriptTarget: ts.ScriptTarget, useCaseSensitiveFileNames: boolean, // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host - currentDirectory?: string): ts.CompilerHost { + currentDirectory?: string, + newLineKind?: ts.NewLineKind): ts.CompilerHost { // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames function getCanonicalFileName(fileName: string): string { @@ -841,6 +845,11 @@ module Harness { }; inputFiles.forEach(register); + let newLine = + newLineKind === ts.NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed : + newLineKind === ts.NewLineKind.LineFeed ? lineFeed : + ts.sys.newLine; + return { getCurrentDirectory, getSourceFile: (fn, languageVersion) => { @@ -869,7 +878,7 @@ module Harness { writeFile, getCanonicalFileName, useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, - getNewLine: () => ts.sys.newLine + getNewLine: () => newLine }; } @@ -990,20 +999,28 @@ module Harness { } break; + case 'emitdecoratormetadata': + options.emitDecoratorMetadata = setting.value === 'true'; + break; + + case 'noemithelpers': + options.noEmitHelpers = setting.value === 'true'; + break; + case 'noemitonerror': - options.noEmitOnError = !!setting.value; + options.noEmitOnError = setting.value === 'true'; break; case 'noresolve': - options.noResolve = !!setting.value; + options.noResolve = setting.value === 'true'; break; case 'noimplicitany': - options.noImplicitAny = !!setting.value; + options.noImplicitAny = setting.value === 'true'; break; case 'nolib': - options.noLib = !!setting.value; + options.noLib = setting.value === 'true'; break; case 'out': @@ -1025,15 +1042,26 @@ module Harness { break; case 'sourcemap': - options.sourceMap = !!setting.value; + options.sourceMap = setting.value === 'true'; break; case 'declaration': - options.declaration = !!setting.value; + options.declaration = setting.value === 'true'; break; case 'newline': - case 'newlines': + if (setting.value.toLowerCase() === 'crlf') { + options.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } + else if (setting.value.toLowerCase() === 'lf') { + options.newLine = ts.NewLineKind.LineFeed; + } + else { + throw new Error('Unknown option for newLine: ' + setting.value); + } + break; + + case 'normalizenewline': newLine = setting.value; break; @@ -1042,7 +1070,7 @@ module Harness { break; case 'stripinternal': - options.stripInternal = !!setting.value; + options.stripInternal = setting.value === 'true'; case 'usecasesensitivefilenames': useCaseSensitiveFileNames = setting.value === 'true'; @@ -1053,7 +1081,7 @@ module Harness { break; case 'emitbom': - options.emitBOM = !!setting.value; + options.emitBOM = setting.value === 'true'; break; case 'errortruncation': @@ -1095,7 +1123,7 @@ module Harness { var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles), (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), - options.target, useCaseSensitiveFileNames, currentDirectory)); + options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine)); var emitResult = program.emit(); @@ -1477,12 +1505,12 @@ module Harness { // List of allowed metadata names var fileMetadataNames = ["filename", "comments", "declaration", "module", - "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", - "noimplicitany", "noresolve", "newline", "newlines", "emitbom", + "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", + "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", "separatecompilation", "inlinesourcemap", "maproot", "sourceroot", - "inlinesources"]; + "inlinesources", "emitdecoratormetadata"]; function extractCompilerSettings(content: string): CompilerSetting[] { @@ -1582,7 +1610,6 @@ module Harness { export module Baseline { export interface BaselineOptions { - LineEndingSensitive?: boolean; Subfolder?: string; Baselinefolder?: string; } @@ -1674,13 +1701,6 @@ module Harness { expected = IO.readFile(refFileName); } - var lineEndingSensitive = opts && opts.LineEndingSensitive; - - if (!lineEndingSensitive) { - expected = expected.replace(/\r\n?/g, '\n'); - actual = actual.replace(/\r\n?/g, '\n'); - } - return { expected, actual }; } @@ -1736,4 +1756,4 @@ module Harness { } // TODO: not sure why Utils.evalFile isn't working with this, eventually will concat it like old compiler instead of eval -eval(Harness.tcServicesFile); \ No newline at end of file +eval(Harness.tcServicesFile); diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index e7c60e4d862..0e0b8d82918 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -241,6 +241,9 @@ module Harness.LanguageService { class ClassifierShimProxy implements ts.Classifier { constructor(private shim: ts.ClassifierShim) { } + getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications { + throw new Error("NYI"); + } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { var result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split('\n'); var entries: ts.ClassificationInfo[] = []; @@ -306,6 +309,12 @@ module Harness.LanguageService { getSemanticClassifications(fileName: string, span: ts.TextSpan): ts.ClassifiedSpan[] { return unwrapJSONCallResult(this.shim.getSemanticClassifications(fileName, span.start, span.length)); } + getEncodedSyntacticClassifications(fileName: string, span: ts.TextSpan): ts.Classifications { + return unwrapJSONCallResult(this.shim.getEncodedSyntacticClassifications(fileName, span.start, span.length)); + } + getEncodedSemanticClassifications(fileName: string, span: ts.TextSpan): ts.Classifications { + return unwrapJSONCallResult(this.shim.getEncodedSemanticClassifications(fileName, span.start, span.length)); + } getCompletionsAtPosition(fileName: string, position: number): ts.CompletionInfo { return unwrapJSONCallResult(this.shim.getCompletionsAtPosition(fileName, position)); } @@ -333,6 +342,9 @@ module Harness.LanguageService { getDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getDefinitionAtPosition(fileName, position)); } + getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[]{ + return unwrapJSONCallResult(this.shim.getTypeDefinitionAtPosition(fileName, position)); + } getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] { return unwrapJSONCallResult(this.shim.getReferencesAtPosition(fileName, position)); } diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 1958bf55439..5a4151c0c1c 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -3697,6 +3697,8 @@ interface HTMLCanvasElement extends HTMLElement { * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext; /** * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. @@ -12178,6 +12180,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { overrideMimeType(mime: string): void; send(data?: Document): void; send(data?: string): void; + send(data?: any): void; setRequestHeader(header: string, value: string): void; DONE: number; HEADERS_RECEIVED: number; @@ -12332,11 +12335,13 @@ interface DocumentEvent { createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface: "CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; createEvent(eventInterface:"ErrorEvent"): ErrorEvent; createEvent(eventInterface:"Event"): Event; + createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; @@ -12351,8 +12356,12 @@ interface DocumentEvent { createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; + createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; createEvent(eventInterface:"NavigationEvent"): NavigationEvent; createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; @@ -12363,6 +12372,7 @@ interface DocumentEvent { createEvent(eventInterface:"PopStateEvent"): PopStateEvent; createEvent(eventInterface:"ProgressEvent"): ProgressEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; @@ -12370,6 +12380,7 @@ interface DocumentEvent { createEvent(eventInterface:"TrackEvent"): TrackEvent; createEvent(eventInterface:"TransitionEvent"): TransitionEvent; createEvent(eventInterface:"UIEvent"): UIEvent; + createEvent(eventInterface:"UIEvents"): UIEvent; createEvent(eventInterface:"UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; createEvent(eventInterface:"WebGLContextEvent"): WebGLContextEvent; createEvent(eventInterface:"WheelEvent"): WheelEvent; diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 71778ecf907..dc082c8f0a6 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -51,11 +51,41 @@ interface SymbolConstructor { isConcatSpreadable: symbol; /** - * A method that returns the default iterator for an object.Called by the semantics of the + * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ iterator: symbol; + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + split: symbol; + /** * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive * abstract operation. @@ -3542,6 +3572,17 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + /** * Represents the completion of an asynchronous operation */ @@ -3552,14 +3593,17 @@ interface Promise { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; /** * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of the callback. */ - catch(onrejected?: (reason: any) => T | Promise): Promise; + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + + [Symbol.toStringTag]: string; } interface PromiseConstructor { @@ -3570,13 +3614,11 @@ interface PromiseConstructor { /** * Creates a new Promise. - * @param init A callback used to initialize the promise. This callback is passed two arguments: + * @param executor A callback used to initialize the promise. This callback is passed two arguments: * a resolve callback used resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ - new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; - - (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -3584,15 +3626,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: (T | Promise)[]): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of values. - * @returns A new Promise. - */ - all(values: Promise[]): Promise; + all(values: Iterable>): Promise; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved @@ -3600,7 +3634,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: (T | Promise)[]): Promise; + race(values: Iterable>): Promise; /** * Creates a new rejected promise for the provided reason. @@ -3621,13 +3655,15 @@ interface PromiseConstructor { * @param value A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | Promise): Promise; + resolve(value: T | PromiseLike): Promise; /** * Creates a new resolved promise . * @returns A resolved promise. */ resolve(): Promise; + + [Symbol.species]: Function; } declare var Promise: PromiseConstructor; diff --git a/src/server/client.ts b/src/server/client.ts index 9d71f627005..3582d508322 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -300,6 +300,32 @@ module ts.server { }); } + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); + var args: protocol.FileLocationRequestArgs = { + file: fileName, + line: lineOffset.line, + offset: lineOffset.offset, + }; + + var request = this.processRequest(CommandNames.TypeDefinition, args); + var response = this.processResponse(request); + + return response.body.map(entry => { + var fileName = entry.file; + var start = this.lineOffsetToPosition(fileName, entry.start); + var end = this.lineOffsetToPosition(fileName, entry.end); + return { + containerKind: "", + containerName: "", + fileName: fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: "", + name: "" + }; + }); + } + findReferences(fileName: string, position: number): ReferencedSymbol[]{ // Not yet implemented. return []; @@ -533,6 +559,14 @@ module ts.server { throw new Error("Not Implemented Yet."); } + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications { + throw new Error("Not Implemented Yet."); + } + + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { + throw new Error("Not Implemented Yet."); + } + getProgram(): Program { throw new Error("SourceFile objects are not serializable through the server protocol."); } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9ed31c91968..9c87a20c851 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -398,7 +398,7 @@ module ts.server { export class ProjectService { filenameToScriptInfo: ts.Map = {}; - // open, non-configured root files + // open, non-configured root files openFileRoots: ScriptInfo[] = []; // projects built from openFileRoots inferredProjects: Project[] = []; @@ -421,10 +421,10 @@ module ts.server { hostInfo: "Unknown host" } } - + getFormatCodeOptions(file?: string) { if (file) { - var info = this.filenameToScriptInfo[file]; + var info = this.filenameToScriptInfo[file]; if (info) { return info.formatCodeOptions; } @@ -448,7 +448,7 @@ module ts.server { } } } - + log(msg: string, type = "Err") { this.psLogger.msg(msg, type); } @@ -457,17 +457,17 @@ module ts.server { if (args.file) { var info = this.filenameToScriptInfo[args.file]; if (info) { - info.setFormatOptions(args.formatOptions); + info.setFormatOptions(args.formatOptions); this.log("Host configuration update for file " + args.file, "Info"); } } else { if (args.hostInfo !== undefined) { this.hostConfiguration.hostInfo = args.hostInfo; - this.log("Host information " + args.hostInfo, "Info"); + this.log("Host information " + args.hostInfo, "Info"); } if (args.formatOptions) { - mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions); + mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions); this.log("Format host information updated", "Info"); } } @@ -487,7 +487,7 @@ module ts.server { fileDeletedInFilesystem(info: ScriptInfo) { this.psLogger.info(info.fileName + " deleted"); - + if (info.fileWatcher) { info.fileWatcher.close(); info.fileWatcher = undefined; @@ -537,7 +537,7 @@ module ts.server { } return false; } - + addOpenFile(info: ScriptInfo) { if (this.setConfiguredProjectRoot(info)) { this.openFileRootsConfigured.push(info); @@ -561,7 +561,7 @@ module ts.server { copyListRemovingItem(r.defaultProject, this.inferredProjects); // put r in referenced open file list this.openFilesReferenced.push(r); - // set default project of r to the new project + // set default project of r to the new project r.defaultProject = info.defaultProject; } else { @@ -694,7 +694,7 @@ module ts.server { this.openFilesReferenced = openFilesReferenced; // Then, loop through all of the open files that are project roots. - // For each root file, note the project that it roots. Then see if + // For each root file, note the project that it roots. Then see if // any other projects newly reference the file. If zero projects // newly reference the file, keep it as a root. If one or more // projects newly references the file, remove its project from the @@ -719,7 +719,7 @@ module ts.server { // Finally, if we found any open, referenced files that are no longer // referenced by their default project, treat them as newly opened - // by the editor. + // by the editor. for (var i = 0, len = unattachedOpenFiles.length; i < len; i++) { this.addOpenFile(unattachedOpenFiles[i]); } @@ -750,6 +750,7 @@ module ts.server { if (content !== undefined) { var indentSize: number; info = new ScriptInfo(this.host, fileName, content, openedByClient); + info.setFormatOptions(this.getFormatCodeOptions()); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { info.fileWatcher = this.host.watchFile(fileName, _ => { this.watchedFileChanged(fileName); }); @@ -772,7 +773,7 @@ module ts.server { findConfigFile(searchPath: string): string { while (true) { var fileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (sys.fileExists(fileName)) { + if (this.host.fileExists(fileName)) { return fileName; } var parentPath = ts.getDirectoryPath(searchPath); @@ -808,7 +809,7 @@ module ts.server { } else { this.log("Opened configuration file " + configFileName,"Info"); - this.configuredProjects.push(configResult.project); + this.configuredProjects.push(configResult.project); } } var info = this.openFile(fileName, true); @@ -900,29 +901,29 @@ module ts.server { } return false; } - + openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { configFilename = ts.normalizePath(configFilename); // file references will be relative to dirPath (or absolute) var dirPath = ts.getDirectoryPath(configFilename); - var rawConfig = ts.readConfigFile(configFilename); - if (!rawConfig) { - return { errorMsg: "tsconfig syntax error" }; + var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.readConfigFile(configFilename); + if (rawConfig.error) { + return rawConfig.error; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig, ts.sys, dirPath); + var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } else if (parsedCommandLine.fileNames) { - var projectOptions: ProjectOptions = { + var projectOptions: ProjectOptions = { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; var proj = this.createProject(configFilename, projectOptions); for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { var rootFilename = parsedCommandLine.fileNames[i]; - if (ts.sys.fileExists(rootFilename)) { + if (this.host.fileExists(rootFilename)) { var info = this.openFile(rootFilename, clientFileName == rootFilename); proj.addRoot(info); } @@ -1039,7 +1040,7 @@ module ts.server { startPath: LineCollection[]; endBranch: LineCollection[] = []; branchNode: LineNode; - // path to current node + // path to current node stack: LineNode[]; state = CharRangeSection.Entire; lineCollectionAtBranch: LineCollection; @@ -1241,7 +1242,7 @@ module ts.server { } } - // text change information + // text change information class TextChange { constructor(public pos: number, public deleteLen: number, public insertedText?: string) { } @@ -1289,7 +1290,7 @@ module ts.server { if (cb) cb(); } - + // reload whole script, leaving no change history behind reload reload(script: string) { this.currentVersion++; @@ -1299,7 +1300,7 @@ module ts.server { snap.index = new LineIndex(); var lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); - // REVIEW: could use linked list + // REVIEW: could use linked list for (var i = this.minVersion; i < this.currentVersion; i++) { this.versions[i] = undefined; } @@ -1380,7 +1381,7 @@ module ts.server { return this.index.root.charCount(); } - // this requires linear space so don't hold on to these + // this requires linear space so don't hold on to these getLineStartPositions(): number[] { var starts: number[] = [-1]; var count = 1; @@ -1642,7 +1643,7 @@ module ts.server { } walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker) { - // assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars) + // assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars) var childIndex = 0; var child = this.children[0]; var childCharCount = child.charCount(); @@ -1728,7 +1729,7 @@ module ts.server { line: lineNumber, offset: charOffset } - } + } else if (childInfo.child.isLeaf()) { return { line: lineNumber, @@ -1916,4 +1917,4 @@ module ts.server { return 1; } } -} \ No newline at end of file +} diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 5bc1ffbe4dc..b95d5e99864 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -125,6 +125,14 @@ declare module ts.server.protocol { export interface DefinitionRequest extends FileLocationRequest { } + /** + * Go to type request; value of command field is + * "typeDefinition". Return response giving the file locations that + * define the type for the symbol found in file at location line, col. + */ + export interface TypeDefinitionRequest extends FileLocationRequest { + } + /** * Location in source code expressed as (one-based) line and character offset. */ @@ -165,6 +173,13 @@ declare module ts.server.protocol { body?: FileSpan[]; } + /** + * Definition response message. Gives text range for definition. + */ + export interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + /** * Get occurrences request; value of command field is * "occurrences". Return response giving spans that are relevant diff --git a/src/server/session.ts b/src/server/session.ts index 52d33234636..baf0a085ad4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -97,6 +97,7 @@ module ts.server { export var Rename = "rename"; export var Saveto = "saveto"; export var SignatureHelp = "signatureHelp"; + export var TypeDefinition = "typeDefinition"; export var Unknown = "unknown"; } @@ -285,7 +286,29 @@ module ts.server { })); } - getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[] { + getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + + var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + + return definitions.map(def => ({ + file: def.fileName, + start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), + end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) + })); + } + + getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[]{ fileName = ts.normalizePath(fileName); let project = this.projectService.getProjectForFile(fileName); @@ -519,7 +542,7 @@ module ts.server { IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: "\n", - ConvertTabsToSpaces: true, + ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, }; var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); @@ -817,6 +840,11 @@ module ts.server { response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); break; } + case CommandNames.TypeDefinition: { + var defArgs = request.arguments; + response = this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file); + break; + } case CommandNames.References: { var refArgs = request.arguments; response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 19235269f22..41079c08201 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -446,14 +446,14 @@ module ts.BreakpointResolver { // fall through. case SyntaxKind.CatchClause: - return spanInNode((node.parent).statements[(node.parent).statements.length - 1]);; + return spanInNode(lastOrUndefined((node.parent).statements));; case SyntaxKind.CaseBlock: // breakpoint in last statement of the last clause let caseBlock = node.parent; - let lastClause = caseBlock.clauses[caseBlock.clauses.length - 1]; + let lastClause = lastOrUndefined(caseBlock.clauses); if (lastClause) { - return spanInNode(lastClause.statements[lastClause.statements.length - 1]); + return spanInNode(lastOrUndefined(lastClause.statements)); } return undefined; diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 751f1a94027..ef25d23a5c9 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -323,6 +323,9 @@ module ts.formatting { let previousParent: Node; let previousRangeStartLine: number; + let lastIndentedLine: number; + let indentationOnLastIndentedLine: number; + let edits: TextChange[] = []; formattingScanner.advance(); @@ -416,7 +419,9 @@ module ts.formatting { // if node is located on the same line with the parent // - inherit indentation from the parent // - push children if either parent of node itself has non-zero delta - indentation = parentDynamicIndentation.getIndentation(); + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); } return { @@ -716,7 +721,6 @@ module ts.formatting { continue; } - let triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line; switch (triviaItem.kind) { case SyntaxKind.MultiLineCommentTrivia: let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); @@ -741,6 +745,9 @@ module ts.formatting { if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; } } diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 388d9428ffc..e09b5dfba92 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -51,7 +51,7 @@ module ts.formatting { if (isStarted) { if (trailingTrivia) { Debug.assert(trailingTrivia.length !== 0); - wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === SyntaxKind.NewLineTrivia; + wasNewLine = lastOrUndefined(trailingTrivia).kind === SyntaxKind.NewLineTrivia; } else { wasNewLine = false; diff --git a/src/services/services.ts b/src/services/services.ts index 06a606bb524..b2596682e50 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -197,6 +197,9 @@ module ts { let list = createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, NodeFlags.Synthetic, this); list._children = []; let pos = nodes.pos; + + + for (let node of nodes) { if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); @@ -946,6 +949,7 @@ module ts { export interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; + getProjectVersion?(): string; getScriptFileNames(): string[]; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; @@ -969,9 +973,20 @@ module ts { getSemanticDiagnostics(fileName: string): Diagnostic[]; getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + // Encoded as triples of [start, length, ClassificationType]. + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; @@ -987,6 +1002,8 @@ module ts { findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; findReferences(fileName: string, position: number): ReferencedSymbol[]; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; @@ -1015,6 +1032,11 @@ module ts { dispose(): void; } + export interface Classifications { + spans: number[], + endOfLineState: EndOfLineState + } + export interface ClassifiedSpan { textSpan: TextSpan; classificationType: string; // ClassificationTypeNames @@ -1258,7 +1280,7 @@ module ts { } export const enum EndOfLineState { - Start, + None, InMultiLineCommentTrivia, InSingleQuoteStringLiteral, InDoubleQuoteStringLiteral, @@ -1308,8 +1330,10 @@ module ts { * classifications which may be incorrectly categorized will be given * back as Identifiers in order to allow the syntactic classifier to * subsume the classification. + * @deprecated Use getLexicalClassifications instead. */ getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } /** @@ -1484,7 +1508,28 @@ module ts { public static interfaceName = "interface name"; public static moduleName = "module name"; public static typeParameterName = "type parameter name"; - public static typeAlias = "type alias name"; + public static typeAliasName = "type alias name"; + public static parameterName = "parameter name"; + } + + export const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17 } /// Language Service @@ -1588,7 +1633,7 @@ module ts { private fileNameToEntry: Map; private _compilationSettings: CompilerOptions; - constructor(private host: LanguageServiceHost) { + constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) { // script id => script index this.fileNameToEntry = {}; @@ -1606,6 +1651,10 @@ module ts { return this._compilationSettings; } + private normalizeFileName(fileName: string): string { + return this.getCanonicalFileName(normalizeSlashes(fileName)); + } + private createEntry(fileName: string) { let entry: HostFileInformation; let scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -1617,15 +1666,15 @@ module ts { }; } - return this.fileNameToEntry[normalizeSlashes(fileName)] = entry; + return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; } - public getEntry(fileName: string): HostFileInformation { - return lookUp(this.fileNameToEntry, normalizeSlashes(fileName)); + private getEntry(fileName: string): HostFileInformation { + return lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); } - public contains(fileName: string): boolean { - return hasProperty(this.fileNameToEntry, normalizeSlashes(fileName)); + private contains(fileName: string): boolean { + return hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); } public getOrCreateEntry(fileName: string): HostFileInformation { @@ -1640,8 +1689,10 @@ module ts { let fileNames: string[] = []; forEachKey(this.fileNameToEntry, key => { - if (hasProperty(this.fileNameToEntry, key) && this.fileNameToEntry[key]) - fileNames.push(key); + let entry = this.getEntry(key); + if (entry) { + fileNames.push(entry.hostFileName); + } }); return fileNames; @@ -2303,6 +2354,7 @@ module ts { let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); let ruleProvider: formatting.RulesProvider; let program: Program; + let lastProjectVersion: string; let useCaseSensitivefileNames = false; let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); @@ -2342,8 +2394,20 @@ module ts { } function synchronizeHostData(): void { + // perform fast check if host supports it + if (host.getProjectVersion) { + let hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + + lastProjectVersion = hostProjectVersion; + } + } + // Get a fresh cache of the host information - let hostCache = new HostCache(host); + let hostCache = new HostCache(host, getCanonicalFileName); // If the program is already up-to-date, we can reuse it if (programUpToDate()) { @@ -2364,7 +2428,7 @@ module ts { let newProgram = createProgram(hostCache.getRootFileNames(), newSettings, { getSourceFile: getOrCreateSourceFile, getCancellationToken: () => cancellationToken, - getCanonicalFileName: (fileName) => useCaseSensitivefileNames ? fileName : fileName.toLowerCase(), + getCanonicalFileName, useCaseSensitiveFileNames: () => useCaseSensitivefileNames, getNewLine: () => host.getNewLine ? host.getNewLine() : "\r\n", getDefaultLibFileName: (options) => host.getDefaultLibFileName(options), @@ -3466,19 +3530,6 @@ module ts { return ScriptElementKind.unknown; } - function getTypeKind(type: Type): string { - let flags = type.getFlags(); - - if (flags & TypeFlags.Enum) return ScriptElementKind.enumElement; - if (flags & TypeFlags.Class) return ScriptElementKind.classElement; - if (flags & TypeFlags.Interface) return ScriptElementKind.interfaceElement; - if (flags & TypeFlags.TypeParameter) return ScriptElementKind.typeParameterElement; - if (flags & TypeFlags.Intrinsic) return ScriptElementKind.primitiveType; - if (flags & TypeFlags.StringLiteral) return ScriptElementKind.primitiveType; - - return ScriptElementKind.unknown; - } - function getSymbolModifiers(symbol: Symbol): string { return symbol && symbol.declarations && symbol.declarations.length > 0 ? getNodeModifiers(symbol.declarations[0]) @@ -3893,6 +3944,71 @@ module ts { }; } + function getDefinitionFromSymbol(symbol: Symbol, node: Node): DefinitionInfo[] { + let typeChecker = program.getTypeChecker(); + let result: DefinitionInfo[] = []; + let declarations = symbol.getDeclarations(); + let symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol + let symbolKind = getSymbolKind(symbol, node); + let containerSymbol = symbol.parent; + let containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + // Just add all the declarations. + forEach(declarations, declaration => { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + + return result; + + function tryAddConstructSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { + // Applicable only if we are in a new expression, or we are on a constructor declaration + // and in either case the symbol has a construct signature definition, i.e. class + if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) { + if (symbol.flags & SymbolFlags.Class) { + let classDeclaration = symbol.getDeclarations()[0]; + Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration); + + return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + return false; + } + + function tryAddCallSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); + } + return false; + } + + function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { + let declarations: Declaration[] = []; + let definition: Declaration; + + forEach(signatureDeclarations, d => { + if ((selectConstructors && d.kind === SyntaxKind.Constructor) || + (!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.MethodDeclaration || d.kind === SyntaxKind.MethodSignature))) { + declarations.push(d); + if ((d).body) definition = d; + } + }); + + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + + return false; + } + } + /// Goto definition function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { synchronizeHostData(); @@ -3967,67 +4083,47 @@ module ts { declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); } - let result: DefinitionInfo[] = []; - let declarations = symbol.getDeclarations(); - let symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - let symbolKind = getSymbolKind(symbol, node); - let containerSymbol = symbol.parent; - let containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + return getDefinitionFromSymbol(symbol, node); + } - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. - forEach(declarations, declaration => { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); + /// Goto type + function getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { + synchronizeHostData(); + + let sourceFile = getValidSourceFile(fileName); + + let node = getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; } - return result; + let typeChecker = program.getTypeChecker(); - function tryAddConstructSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { - // Applicable only if we are in a new expression, or we are on a constructor declaration - // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) { - if (symbol.flags & SymbolFlags.Class) { - let classDeclaration = symbol.getDeclarations()[0]; - Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration); - - return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); - } - } - return false; + let symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; } - function tryAddCallSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); - } - return false; + let type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; } - function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { - let declarations: Declaration[] = []; - let definition: Declaration; - - forEach(signatureDeclarations, d => { - if ((selectConstructors && d.kind === SyntaxKind.Constructor) || - (!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.MethodDeclaration || d.kind === SyntaxKind.MethodSignature))) { - declarations.push(d); - if ((d).body) definition = d; + if (type.flags & TypeFlags.Union) { + var result: DefinitionInfo[] = []; + forEach((type).types, t => { + if (t.symbol) { + result.push(...getDefinitionFromSymbol(t.symbol, node)); } }); - - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName)); - return true; - } - - return false; + return result; } + + if (!type.symbol) { + return undefined; + } + + return getDefinitionFromSymbol(type.symbol, node); } function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { @@ -5810,35 +5906,45 @@ module ts { return NavigationBar.getNavigationBarItems(sourceFile); } - function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { + function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + + function getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { synchronizeHostData(); let sourceFile = getValidSourceFile(fileName); let typeChecker = program.getTypeChecker(); - let result: ClassifiedSpan[] = []; + let result: number[] = []; processNode(sourceFile); - return result; + return { spans: result, endOfLineState: EndOfLineState.None }; - function classifySymbol(symbol: Symbol, meaningAtPosition: SemanticMeaning) { + function pushClassification(start: number, length: number, type: ClassificationType) { + result.push(start); + result.push(length); + result.push(type); + } + + function classifySymbol(symbol: Symbol, meaningAtPosition: SemanticMeaning): ClassificationType { let flags = symbol.getFlags(); if (flags & SymbolFlags.Class) { - return ClassificationTypeNames.className; + return ClassificationType.className; } else if (flags & SymbolFlags.Enum) { - return ClassificationTypeNames.enumName; + return ClassificationType.enumName; } else if (flags & SymbolFlags.TypeAlias) { - return ClassificationTypeNames.typeAlias; + return ClassificationType.typeAliasName; } else if (meaningAtPosition & SemanticMeaning.Type) { if (flags & SymbolFlags.Interface) { - return ClassificationTypeNames.interfaceName; + return ClassificationType.interfaceName; } else if (flags & SymbolFlags.TypeParameter) { - return ClassificationTypeNames.typeParameterName; + return ClassificationType.typeParameterName; } } else if (flags & SymbolFlags.Module) { @@ -5847,7 +5953,7 @@ module ts { // - There exists a module declaration which actually impacts the value side. if (meaningAtPosition & SemanticMeaning.Namespace || (meaningAtPosition & SemanticMeaning.Value && hasValueSideModule(symbol))) { - return ClassificationTypeNames.moduleName; + return ClassificationType.moduleName; } } @@ -5871,10 +5977,7 @@ module ts { if (symbol) { let type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { - result.push({ - textSpan: createTextSpan(node.getStart(), node.getWidth()), - classificationType: type - }); + pushClassification(node.getStart(), node.getWidth(), type); } } } @@ -5884,7 +5987,46 @@ module ts { } } - function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { + function getClassificationTypeName(type: ClassificationType) { + switch (type) { + case ClassificationType.comment: return ClassificationTypeNames.comment; + case ClassificationType.identifier: return ClassificationTypeNames.identifier; + case ClassificationType.keyword: return ClassificationTypeNames.keyword; + case ClassificationType.numericLiteral: return ClassificationTypeNames.numericLiteral; + case ClassificationType.operator: return ClassificationTypeNames.operator; + case ClassificationType.stringLiteral: return ClassificationTypeNames.stringLiteral; + case ClassificationType.whiteSpace: return ClassificationTypeNames.whiteSpace; + case ClassificationType.text: return ClassificationTypeNames.text; + case ClassificationType.punctuation: return ClassificationTypeNames.punctuation; + case ClassificationType.className: return ClassificationTypeNames.className; + case ClassificationType.enumName: return ClassificationTypeNames.enumName; + case ClassificationType.interfaceName: return ClassificationTypeNames.interfaceName; + case ClassificationType.moduleName: return ClassificationTypeNames.moduleName; + case ClassificationType.typeParameterName: return ClassificationTypeNames.typeParameterName; + case ClassificationType.typeAliasName: return ClassificationTypeNames.typeAliasName; + case ClassificationType.parameterName: return ClassificationTypeNames.parameterName; + } + } + + function convertClassifications(classifications: Classifications): ClassifiedSpan[] { + Debug.assert(classifications.spans.length % 3 === 0); + let dense = classifications.spans; + let result: ClassifiedSpan[] = []; + for (let i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + + return result; + } + + function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + + function getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications { // doesn't use compiler - no need to synchronize with host let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -5892,10 +6034,16 @@ module ts { let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); - let result: ClassifiedSpan[] = []; + let result: number[] = []; processElement(sourceFile); - return result; + return { spans: result, endOfLineState: EndOfLineState.None }; + + function pushClassification(start: number, length: number, type: ClassificationType) { + result.push(start); + result.push(length); + result.push(type); + } function classifyLeadingTrivia(token: Node): void { let tokenStart = skipTrivia(sourceFile.text, token.pos, /*stopAfterLineBreak:*/ false); @@ -5911,17 +6059,16 @@ module ts { let end = triviaScanner.getTextPos(); let width = end - start; - if (textSpanIntersectsWith(span, start, width)) { - if (!isTrivia(kind)) { - return; - } + // The moment we get something that isn't trivia, then stop processing. + if (!isTrivia(kind)) { + return; + } + // Only bother with the trivia if it at least intersects the span of interest. + if (textSpanIntersectsWith(span, start, width)) { if (isComment(kind)) { // Simple comment. Just add as is. - result.push({ - textSpan: createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }) + pushClassification(start, width, ClassificationType.comment); continue; } @@ -5932,10 +6079,7 @@ module ts { // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) { - result.push({ - textSpan: createTextSpan(start, width), - classificationType: ClassificationTypeNames.comment - }); + pushClassification(start, width, ClassificationType.comment); continue; } @@ -5956,11 +6100,7 @@ module ts { break; } } - result.push({ - textSpan: createTextSpanFromBounds(start, i), - classificationType: ClassificationTypeNames.comment - }); - + pushClassification(start, i - start, ClassificationType.comment); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { @@ -5975,10 +6115,7 @@ module ts { let type = classifyTokenType(tokenKind); if (type) { - result.push({ - textSpan: createTextSpanFromBounds(start, end), - classificationType: type - }); + pushClassification(start, end - start, type); } } @@ -5988,10 +6125,7 @@ module ts { if (token.getWidth() > 0) { let type = classifyTokenType(token.kind, token); if (type) { - result.push({ - textSpan: createTextSpan(token.getStart(), token.getWidth()), - classificationType: type - }); + pushClassification(token.getStart(), token.getWidth(), type); } } } @@ -5999,9 +6133,9 @@ module ts { // for accurate classification, the actual token should be passed in. however, for // cases like 'disabled merge code' classification, we just get the token kind and // classify based on that instead. - function classifyTokenType(tokenKind: SyntaxKind, token?: Node): string { + function classifyTokenType(tokenKind: SyntaxKind, token?: Node): ClassificationType { if (isKeyword(tokenKind)) { - return ClassificationTypeNames.keyword; + return ClassificationType.keyword; } // Special case < and > If they appear in a generic context they are punctuation, @@ -6010,7 +6144,7 @@ module ts { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && getTypeArgumentOrTypeParameterList(token.parent)) { - return ClassificationTypeNames.punctuation; + return ClassificationType.punctuation; } } @@ -6021,7 +6155,7 @@ module ts { if (token.parent.kind === SyntaxKind.VariableDeclaration || token.parent.kind === SyntaxKind.PropertyDeclaration || token.parent.kind === SyntaxKind.Parameter) { - return ClassificationTypeNames.operator; + return ClassificationType.operator; } } @@ -6029,58 +6163,64 @@ module ts { token.parent.kind === SyntaxKind.PrefixUnaryExpression || token.parent.kind === SyntaxKind.PostfixUnaryExpression || token.parent.kind === SyntaxKind.ConditionalExpression) { - return ClassificationTypeNames.operator; + return ClassificationType.operator; } } - return ClassificationTypeNames.punctuation; + return ClassificationType.punctuation; } else if (tokenKind === SyntaxKind.NumericLiteral) { - return ClassificationTypeNames.numericLiteral; + return ClassificationType.numericLiteral; } else if (tokenKind === SyntaxKind.StringLiteral) { - return ClassificationTypeNames.stringLiteral; + return ClassificationType.stringLiteral; } else if (tokenKind === SyntaxKind.RegularExpressionLiteral) { // TODO: we should get another classification type for these literals. - return ClassificationTypeNames.stringLiteral; + return ClassificationType.stringLiteral; } else if (isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return ClassificationTypeNames.stringLiteral; + return ClassificationType.stringLiteral; } else if (tokenKind === SyntaxKind.Identifier) { if (token) { switch (token.parent.kind) { case SyntaxKind.ClassDeclaration: if ((token.parent).name === token) { - return ClassificationTypeNames.className; + return ClassificationType.className; } return; case SyntaxKind.TypeParameter: if ((token.parent).name === token) { - return ClassificationTypeNames.typeParameterName; + return ClassificationType.typeParameterName; } return; case SyntaxKind.InterfaceDeclaration: if ((token.parent).name === token) { - return ClassificationTypeNames.interfaceName; + return ClassificationType.interfaceName; } return; case SyntaxKind.EnumDeclaration: if ((token.parent).name === token) { - return ClassificationTypeNames.enumName; + return ClassificationType.enumName; } return; case SyntaxKind.ModuleDeclaration: if ((token.parent).name === token) { - return ClassificationTypeNames.moduleName; + return ClassificationType.moduleName; } return; + case SyntaxKind.Parameter: + if ((token.parent).name === token) { + return ClassificationType.parameterName; + } + return; + } } - return ClassificationTypeNames.text; + return ClassificationType.text; } } @@ -6411,11 +6551,14 @@ module ts { getCompilerOptionsDiagnostics, getSyntacticClassifications, getSemanticClassifications, + getEncodedSyntacticClassifications, + getEncodedSemanticClassifications, getCompletionsAtPosition, getCompletionEntryDetails, getSignatureHelpItems, getQuickInfoAtPosition, getDefinitionAtPosition, + getTypeDefinitionAtPosition, getReferencesAtPosition, findReferences, getOccurrencesAtPosition, @@ -6551,10 +6694,67 @@ module ts { // if there are more cases we want the classifier to be better at. return true; } - + + function convertClassifications(classifications: Classifications, text: string): ClassificationResult { + var entries: ClassificationInfo[] = []; + let dense = classifications.spans; + let lastEnd = 0; + + for (let i = 0, n = dense.length; i < n; i += 3) { + let start = dense[i]; + let length = dense[i + 1]; + let type = dense[i + 2]; + + // Make a whitespace entry between the last item and this one. + if (lastEnd >= 0) { + let whitespaceLength = start - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + } + + entries.push({ length, classification: convertClassification(type) }); + lastEnd = start + length; + } + + let whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + + return { entries, finalLexState: classifications.endOfLineState }; + } + + function convertClassification(type: ClassificationType): TokenClass { + switch (type) { + case ClassificationType.comment: return TokenClass.Comment; + case ClassificationType.keyword: return TokenClass.Keyword; + case ClassificationType.numericLiteral: return TokenClass.NumberLiteral; + case ClassificationType.operator: return TokenClass.Operator; + case ClassificationType.stringLiteral: return TokenClass.StringLiteral; + case ClassificationType.whiteSpace: return TokenClass.Whitespace; + case ClassificationType.punctuation: return TokenClass.Punctuation; + case ClassificationType.identifier: + case ClassificationType.className: + case ClassificationType.enumName: + case ClassificationType.interfaceName: + case ClassificationType.moduleName: + case ClassificationType.typeParameterName: + case ClassificationType.typeAliasName: + case ClassificationType.text: + case ClassificationType.parameterName: + default: + return TokenClass.Identifier; + } + } + + function getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } + // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. - function getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult { + function getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications { let offset = 0; let token = SyntaxKind.Unknown; let lastNonTriviaToken = SyntaxKind.Unknown; @@ -6597,9 +6797,9 @@ module ts { scanner.setText(text); - let result: ClassificationResult = { - finalLexState: EndOfLineState.Start, - entries: [] + let result: Classifications = { + endOfLineState: EndOfLineState.None, + spans: [] }; // We can run into an unfortunate interaction between the lexical and syntactic classifier @@ -6712,7 +6912,7 @@ module ts { let start = scanner.getTokenPos(); let end = scanner.getTextPos(); - addResult(end - start, classFromKind(token)); + addResult(start, end, classFromKind(token)); if (end >= text.length) { if (token === SyntaxKind.StringLiteral) { @@ -6729,7 +6929,7 @@ module ts { // If we have an odd number of backslashes, then the multiline string is unclosed if (numBackslashes & 1) { let quoteChar = tokenText.charCodeAt(0); - result.finalLexState = quoteChar === CharacterCodes.doubleQuote + result.endOfLineState = quoteChar === CharacterCodes.doubleQuote ? EndOfLineState.InDoubleQuoteStringLiteral : EndOfLineState.InSingleQuoteStringLiteral; } @@ -6738,16 +6938,16 @@ module ts { else if (token === SyntaxKind.MultiLineCommentTrivia) { // Check to see if the multiline comment was unclosed. if (scanner.isUnterminated()) { - result.finalLexState = EndOfLineState.InMultiLineCommentTrivia; + result.endOfLineState = EndOfLineState.InMultiLineCommentTrivia; } } else if (isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { if (token === SyntaxKind.TemplateTail) { - result.finalLexState = EndOfLineState.InTemplateMiddleOrTail; + result.endOfLineState = EndOfLineState.InTemplateMiddleOrTail; } else if (token === SyntaxKind.NoSubstitutionTemplateLiteral) { - result.finalLexState = EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate; + result.endOfLineState = EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate; } else { Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); @@ -6755,20 +6955,34 @@ module ts { } } else if (templateStack.length > 0 && lastOrUndefined(templateStack) === SyntaxKind.TemplateHead) { - result.finalLexState = EndOfLineState.InTemplateSubstitutionPosition; + result.endOfLineState = EndOfLineState.InTemplateSubstitutionPosition; } } } - function addResult(length: number, classification: TokenClass): void { - if (length > 0) { - // If this is the first classification we're adding to the list, then remove any - // offset we have if we were continuing a construct from the previous line. - if (result.entries.length === 0) { - length -= offset; - } + function addResult(start: number, end: number, classification: ClassificationType): void { + if (classification === ClassificationType.whiteSpace) { + // Don't bother with whitespace classifications. They're not needed. + return; + } - result.entries.push({ length: length, classification: classification }); + if (start === 0 && offset > 0) { + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of + // the original text. + start += offset; + } + + // All our tokens are in relation to the augmented text. Move them back to be + // relative to the original text. + start -= offset; + end -= offset; + let length = end - start; + + if (length > 0) { + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); } } } @@ -6835,41 +7049,44 @@ module ts { return token >= SyntaxKind.FirstKeyword && token <= SyntaxKind.LastKeyword; } - function classFromKind(token: SyntaxKind) { + function classFromKind(token: SyntaxKind): ClassificationType { if (isKeyword(token)) { - return TokenClass.Keyword; + return ClassificationType.keyword; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return TokenClass.Operator; + return ClassificationType.operator; } else if (token >= SyntaxKind.FirstPunctuation && token <= SyntaxKind.LastPunctuation) { - return TokenClass.Punctuation; + return ClassificationType.punctuation; } switch (token) { case SyntaxKind.NumericLiteral: - return TokenClass.NumberLiteral; + return ClassificationType.numericLiteral; case SyntaxKind.StringLiteral: - return TokenClass.StringLiteral; + return ClassificationType.stringLiteral; case SyntaxKind.RegularExpressionLiteral: - return TokenClass.RegExpLiteral; + return ClassificationType.regularExpressionLiteral; case SyntaxKind.ConflictMarkerTrivia: case SyntaxKind.MultiLineCommentTrivia: case SyntaxKind.SingleLineCommentTrivia: - return TokenClass.Comment; + return ClassificationType.comment; case SyntaxKind.WhitespaceTrivia: case SyntaxKind.NewLineTrivia: - return TokenClass.Whitespace; + return ClassificationType.whiteSpace; case SyntaxKind.Identifier: default: if (isTemplateLiteralKind(token)) { - return TokenClass.StringLiteral; + return ClassificationType.stringLiteral; } - return TokenClass.Identifier; + return ClassificationType.identifier; } } - return { getClassificationsForLine }; + return { + getClassificationsForLine, + getEncodedLexicalClassifications + }; } /// getDefaultLibraryFilePath diff --git a/src/services/shims.ts b/src/services/shims.ts index 993627619cb..27c70ddc878 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1,6 +1,6 @@ // // Copyright (c) Microsoft Corporation. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -55,6 +55,7 @@ module ts { getCurrentDirectory(): string; getDefaultLibFileName(options: string): string; getNewLine?(): string; + getProjectVersion?(): string; } /** Public interface of the the of a config service shim instance.*/ @@ -83,7 +84,7 @@ module ts { export interface Shim { dispose(dummy: any): void; } - + export interface LanguageServiceShim extends Shim { languageService: LanguageService; @@ -99,6 +100,8 @@ module ts { getSyntacticClassifications(fileName: string, start: number, length: number): string; getSemanticClassifications(fileName: string, start: number, length: number): string; + getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string; + getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; getCompletionsAtPosition(fileName: string, position: number): string; getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; @@ -130,12 +133,20 @@ module ts { */ getDefinitionAtPosition(fileName: string, position: number): string; + /** + * Returns a JSON-encoded value of the type: + * { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string } + * + * Or undefined value if no definition can be found. + */ + getTypeDefinitionAtPosition(fileName: string, position: number): string; + /** * Returns a JSON-encoded value of the type: * { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[] */ getReferencesAtPosition(fileName: string, position: number): string; - + /** * Returns a JSON-encoded value of the type: * { definition: ; references: [] }[] @@ -152,8 +163,8 @@ module ts { /** * Returns a JSON-encoded value of the type: * { fileName: string; highlights: { start: number; length: number, isDefinition: boolean }[] }[] - * - * @param fileToSearch A JSON encoded string[] containing the file names that should be + * + * @param fileToSearch A JSON encoded string[] containing the file names that should be * considered when searching. */ getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; @@ -189,6 +200,7 @@ module ts { } export interface ClassifierShim extends Shim { + getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; } @@ -199,7 +211,9 @@ module ts { } function logInternalError(logger: Logger, err: Error) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } } class ScriptSnapshotShimAdapter implements IScriptSnapshot { @@ -231,7 +245,7 @@ module ts { export class LanguageServiceShimHostAdapter implements LanguageServiceHost { private files: string[]; - + constructor(private shimHost: LanguageServiceShimHost) { } @@ -242,11 +256,20 @@ module ts { public trace(s: string): void { this.shimHost.trace(s); } - + public error(s: string): void { this.shimHost.error(s); } + public getProjectVersion(): string { + if (!this.shimHost.getProjectVersion) { + // shimmed host does not support getProjectVersion + return undefined; + } + + return this.shimHost.getProjectVersion(); + } + public getCompilationSettings(): CompilerOptions { var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { @@ -309,7 +332,7 @@ module ts { } } } - + export class CoreServicesShimHostAdapter implements ParseConfigHost { constructor(private shimHost: CoreServicesShimHost) { @@ -321,25 +344,32 @@ module ts { } } - function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any { - logger.log(actionDescription); - var start = Date.now(); - var result = action(); - var end = Date.now(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof (result) === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; - } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, noPerfLogging: boolean): any { + if (!noPerfLogging) { + logger.log(actionDescription); + var start = Date.now(); } + + var result = action(); + + if (!noPerfLogging) { + var end = Date.now(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof (result) === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; } - function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any): string { + function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, noPerfLogging: boolean): string { try { - var result = simpleForwardCall(logger, actionDescription, action); + var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); return JSON.stringify({ result: result }); } catch (err) { @@ -387,7 +417,7 @@ module ts { } public forwardJSONCall(actionDescription: string, action: () => any): string { - return forwardJSONCall(this.logger, actionDescription, action); + return forwardJSONCall(this.logger, actionDescription, action, /*noPerfLogging:*/ false); } /// DISPOSE @@ -457,6 +487,26 @@ module ts { }); } + public getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string { + return this.forwardJSONCall( + "getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + () => { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + return convertClassifications(this.languageService.getEncodedSyntacticClassifications(fileName, createTextSpan(start, length))); + }); + } + + public getEncodedSemanticClassifications(fileName: string, start: number, length: number): string { + return this.forwardJSONCall( + "getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + () => { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + return convertClassifications(this.languageService.getEncodedSemanticClassifications(fileName, createTextSpan(start, length))); + }); + } + private getNewLine(): string { return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; } @@ -547,7 +597,7 @@ module ts { /** * Computes the definition location and file for the symbol - * at the requested position. + * at the requested position. */ public getDefinitionAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( @@ -557,6 +607,20 @@ module ts { }); } + /// GOTO Type + + /** + * Computes the definition location of the type of the symbol + * at the requested position. + */ + public getTypeDefinitionAtPosition(fileName: string, position: number): string { + return this.forwardJSONCall( + "getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", + () => { + return this.languageService.getTypeDefinitionAtPosition(fileName, position); + }); + } + public getRenameInfo(fileName: string, position: number): string { return this.forwardJSONCall( "getRenameInfo('" + fileName + "', " + position + ")", @@ -630,8 +694,8 @@ module ts { /// COMPLETION LISTS /** - * Get a string based representation of the completions - * to provide at the given source position and providing a member completion + * Get a string based representation of the completions + * to provide at the given source position and providing a member completion * list if requested. */ public getCompletionsAtPosition(fileName: string, position: number) { @@ -736,14 +800,24 @@ module ts { } } + function convertClassifications(classifications: Classifications): { spans: string, endOfLineState: EndOfLineState } { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + class ClassifierShimObject extends ShimBase implements ClassifierShim { public classifier: Classifier; - constructor(factory: ShimFactory) { + constructor(factory: ShimFactory, private logger: Logger) { super(factory); this.classifier = createClassifier(); } + public getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string { + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", + () => convertClassifications(this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)), + /*noPerfLogging:*/ true); + } + /// COLORIZATION public getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): string { var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); @@ -765,7 +839,7 @@ module ts { } private forwardJSONCall(actionDescription: string, action: () => any): any { - return forwardJSONCall(this.logger, actionDescription, action); + return forwardJSONCall(this.logger, actionDescription, action, /*noPerfLogging:*/ false); } public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { @@ -858,7 +932,7 @@ module ts { public createClassifierShim(logger: Logger): ClassifierShim { try { - return new ClassifierShimObject(this); + return new ClassifierShimObject(this, logger); } catch (err) { logInternalError(logger, err); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5e1460bbdcd..f2074d43ec9 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -200,7 +200,7 @@ module ts { function nodeEndsWith(n: Node, expectedLastToken: SyntaxKind, sourceFile: SourceFile): boolean { let children = n.getChildren(sourceFile); if (children.length) { - let last = children[children.length - 1]; + let last = lastOrUndefined(children); if (last.kind === expectedLastToken) { return true; } diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index bfa243937d6..ec30d5b4dc7 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -21,7 +21,7 @@ module A { //// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js index 71a43788c55..4d296bf9ea5 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js @@ -25,7 +25,7 @@ module A { //// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.js b/tests/baselines/reference/accessOverriddenBaseClassMember1.js index b6817ed7621..f6d3f29f1ab 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.js +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.js @@ -16,7 +16,7 @@ class ColoredPoint extends Point { //// [accessOverriddenBaseClassMember1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.js b/tests/baselines/reference/accessors_spec_section-4.5_inference.js index 9aa7ce2f408..8b75e27031a 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_inference.js +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -25,7 +25,7 @@ class LanguageSpec_section_4_5_inference { } //// [accessors_spec_section-4.5_inference.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasErrors.errors.txt b/tests/baselines/reference/aliasErrors.errors.txt index ffc114f80e3..c74649618ba 100644 --- a/tests/baselines/reference/aliasErrors.errors.txt +++ b/tests/baselines/reference/aliasErrors.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/aliasErrors.ts(11,12): error TS2304: Cannot find name 'no'. -tests/cases/compiler/aliasErrors.ts(12,13): error TS2304: Cannot find name 'no'. +tests/cases/compiler/aliasErrors.ts(11,12): error TS2503: Cannot find namespace 'no'. +tests/cases/compiler/aliasErrors.ts(12,13): error TS2503: Cannot find namespace 'no'. tests/cases/compiler/aliasErrors.ts(13,12): error TS1003: Identifier expected. tests/cases/compiler/aliasErrors.ts(14,12): error TS1003: Identifier expected. tests/cases/compiler/aliasErrors.ts(15,12): error TS1003: Identifier expected. -tests/cases/compiler/aliasErrors.ts(16,12): error TS2304: Cannot find name 'undefined'. +tests/cases/compiler/aliasErrors.ts(16,12): error TS2503: Cannot find namespace 'undefined'. tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' has no exported member 'bar'. @@ -20,10 +20,10 @@ tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' h import m = no; ~~ -!!! error TS2304: Cannot find name 'no'. +!!! error TS2503: Cannot find namespace 'no'. import m2 = no.mod; ~~ -!!! error TS2304: Cannot find name 'no'. +!!! error TS2503: Cannot find namespace 'no'. import n = 5; ~ !!! error TS1003: Identifier expected. @@ -35,7 +35,7 @@ tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' h !!! error TS1003: Identifier expected. import r = undefined; ~~~~~~~~~ -!!! error TS2304: Cannot find name 'undefined'. +!!! error TS2503: Cannot find namespace 'undefined'. var p = new provide.Provide(); diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js index 485aedc971d..06c8b55e23d 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js @@ -35,7 +35,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsage1_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index 5712abf3443..e5d44320c7d 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -29,7 +29,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInArray_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.js b/tests/baselines/reference/aliasUsageInFunctionExpression.js index 661c8fd91e7..b7b95661ac8 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.js +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.js @@ -28,7 +28,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInFunctionExpression_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index 1070036adea..856e6ddb43e 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -32,7 +32,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInGenericFunction_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index 7b2907681e0..e05f5e4f5cd 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -34,7 +34,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInIndexerOfClass_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index 50ccfaf944d..cc4b8273e84 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -29,7 +29,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInObjectLiteral_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index 07a382ebca1..f382ee2f617 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -32,7 +32,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInOrExpression_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index 7161d065528..39ff58a5322 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -32,7 +32,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -48,7 +48,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInTypeArgumentOfExtendsClause_main.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index 31d976f6ef2..2de34f00566 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -28,7 +28,7 @@ var Model = (function () { })(); exports.Model = Model; //// [aliasUsageInVarAssignment_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/ambientEnumDeclaration1.errors.txt b/tests/baselines/reference/ambientEnumDeclaration1.errors.txt new file mode 100644 index 00000000000..419f7e184ac --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration1.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(7,5): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(8,5): error TS1066: Ambient enum elements can only have integer literal initializers. + + +==== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts (4 errors) ==== + // In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. + + declare enum E { + a = 10, + b = 10 + 1, + ~ +!!! error TS1066: Ambient enum elements can only have integer literal initializers. + c = b, + ~ +!!! error TS1066: Ambient enum elements can only have integer literal initializers. + d = (c) + 1, + ~ +!!! error TS1066: Ambient enum elements can only have integer literal initializers. + e = 10 << 2 * 8, + ~ +!!! error TS1066: Ambient enum elements can only have integer literal initializers. + } \ No newline at end of file diff --git a/tests/baselines/reference/ambientEnumDeclaration1.js b/tests/baselines/reference/ambientEnumDeclaration1.js new file mode 100644 index 00000000000..dcdb100e906 --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration1.js @@ -0,0 +1,13 @@ +//// [ambientEnumDeclaration1.ts] +// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. + +declare enum E { + a = 10, + b = 10 + 1, + c = b, + d = (c) + 1, + e = 10 << 2 * 8, +} + +//// [ambientEnumDeclaration1.js] +// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. diff --git a/tests/baselines/reference/ambientEnumDeclaration2.js b/tests/baselines/reference/ambientEnumDeclaration2.js new file mode 100644 index 00000000000..8ef6facfe6d --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration2.js @@ -0,0 +1,17 @@ +//// [ambientEnumDeclaration2.ts] +// In ambient enum declarations that specify no const modifier, enum member declarations +// that omit a value are considered computed members (as opposed to having auto- incremented values assigned). + +declare enum E { + a, // E.a + b, // E.b +} + +declare const enum E1 { + a, // E.a = 0 + b, // E.b = 1 +} + +//// [ambientEnumDeclaration2.js] +// In ambient enum declarations that specify no const modifier, enum member declarations +// that omit a value are considered computed members (as opposed to having auto- incremented values assigned). diff --git a/tests/baselines/reference/ambientEnumDeclaration2.symbols b/tests/baselines/reference/ambientEnumDeclaration2.symbols new file mode 100644 index 00000000000..7c4975f5878 --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration2.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/ambient/ambientEnumDeclaration2.ts === +// In ambient enum declarations that specify no const modifier, enum member declarations +// that omit a value are considered computed members (as opposed to having auto- incremented values assigned). + +declare enum E { +>E : Symbol(E, Decl(ambientEnumDeclaration2.ts, 0, 0)) + + a, // E.a +>a : Symbol(E.a, Decl(ambientEnumDeclaration2.ts, 3, 16)) + + b, // E.b +>b : Symbol(E.b, Decl(ambientEnumDeclaration2.ts, 4, 6)) +} + +declare const enum E1 { +>E1 : Symbol(E1, Decl(ambientEnumDeclaration2.ts, 6, 1)) + + a, // E.a = 0 +>a : Symbol(E1.a, Decl(ambientEnumDeclaration2.ts, 8, 23)) + + b, // E.b = 1 +>b : Symbol(E1.b, Decl(ambientEnumDeclaration2.ts, 9, 6)) +} diff --git a/tests/baselines/reference/ambientEnumDeclaration2.types b/tests/baselines/reference/ambientEnumDeclaration2.types new file mode 100644 index 00000000000..af66e4ac0c5 --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration2.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/ambient/ambientEnumDeclaration2.ts === +// In ambient enum declarations that specify no const modifier, enum member declarations +// that omit a value are considered computed members (as opposed to having auto- incremented values assigned). + +declare enum E { +>E : E + + a, // E.a +>a : E + + b, // E.b +>b : E +} + +declare const enum E1 { +>E1 : E1 + + a, // E.a = 0 +>a : E1 + + b, // E.b = 1 +>b : E1 +} diff --git a/tests/baselines/reference/ambiguousOverloadResolution.js b/tests/baselines/reference/ambiguousOverloadResolution.js index 2d817ba1385..8c2ceb055c7 100644 --- a/tests/baselines/reference/ambiguousOverloadResolution.js +++ b/tests/baselines/reference/ambiguousOverloadResolution.js @@ -9,7 +9,7 @@ var x: B; var t: number = f(x, x); // Not an error //// [ambiguousOverloadResolution.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/apparentTypeSubtyping.js b/tests/baselines/reference/apparentTypeSubtyping.js index fd01d0df2ba..087a91fb02c 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.js +++ b/tests/baselines/reference/apparentTypeSubtyping.js @@ -24,7 +24,7 @@ class Derived2 extends Base2 { // error because of the prototy //// [apparentTypeSubtyping.js] // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/apparentTypeSupertype.js b/tests/baselines/reference/apparentTypeSupertype.js index 75703fbd06b..0b4462bebe7 100644 --- a/tests/baselines/reference/apparentTypeSupertype.js +++ b/tests/baselines/reference/apparentTypeSupertype.js @@ -14,7 +14,7 @@ class Derived extends Base { // error //// [apparentTypeSupertype.js] // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/argumentExpressionContextualTyping.errors.txt b/tests/baselines/reference/argumentExpressionContextualTyping.errors.txt new file mode 100644 index 00000000000..c1bac0fb1ff --- /dev/null +++ b/tests/baselines/reference/argumentExpressionContextualTyping.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(16,5): error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'. + Property '0' is missing in type '(string | number | boolean)[]'. +tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(17,5): error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'. +tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(18,5): error TS2345: Argument of type '{ x: (string | number)[]; y: { c: boolean; d: string; e: number; }; }' is not assignable to parameter of type '{ x: [any, any]; y: { c: any; d: any; e: any; }; }'. + Types of property 'x' are incompatible. + Type '(string | number)[]' is not assignable to type '[any, any]'. + Property '0' is missing in type '(string | number)[]'. + + +==== tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts (3 errors) ==== + // In a typed function call, argument expressions are contextually typed by their corresponding parameter types. + function foo({x: [a, b], y: {c, d, e}}) { } + function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { } + function baz(x: [string, number, boolean]) { } + + var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; + var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; + foo(o1); // Not error since x has contextual type of tuple namely [string, number] + foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error + + var array = ["string", 1, true]; + var tuple: [string, number, boolean] = ["string", 1, true]; + baz(tuple); + baz(["string", 1, true]); + + baz(array); // Error + ~~~~~ +!!! error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'. +!!! error TS2345: Property '0' is missing in type '(string | number | boolean)[]'. + baz(["string", 1, true, ...array]); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'. + foo(o); // Error because x has an array type namely (string|number)[] + ~ +!!! error TS2345: Argument of type '{ x: (string | number)[]; y: { c: boolean; d: string; e: number; }; }' is not assignable to parameter of type '{ x: [any, any]; y: { c: any; d: any; e: any; }; }'. +!!! error TS2345: Types of property 'x' are incompatible. +!!! error TS2345: Type '(string | number)[]' is not assignable to type '[any, any]'. +!!! error TS2345: Property '0' is missing in type '(string | number)[]'. \ No newline at end of file diff --git a/tests/baselines/reference/argumentExpressionContextualTyping.js b/tests/baselines/reference/argumentExpressionContextualTyping.js new file mode 100644 index 00000000000..d3383612327 --- /dev/null +++ b/tests/baselines/reference/argumentExpressionContextualTyping.js @@ -0,0 +1,40 @@ +//// [argumentExpressionContextualTyping.ts] +// In a typed function call, argument expressions are contextually typed by their corresponding parameter types. +function foo({x: [a, b], y: {c, d, e}}) { } +function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { } +function baz(x: [string, number, boolean]) { } + +var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +foo(o1); // Not error since x has contextual type of tuple namely [string, number] +foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error + +var array = ["string", 1, true]; +var tuple: [string, number, boolean] = ["string", 1, true]; +baz(tuple); +baz(["string", 1, true]); + +baz(array); // Error +baz(["string", 1, true, ...array]); // Error +foo(o); // Error because x has an array type namely (string|number)[] + +//// [argumentExpressionContextualTyping.js] +// In a typed function call, argument expressions are contextually typed by their corresponding parameter types. +function foo(_a) { + var _b = _a.x, a = _b[0], b = _b[1], _c = _a.y, c = _c.c, d = _c.d, e = _c.e; +} +function bar(_a) { + var _b = _a.x, a = _b[0], _c = _b[1], b = _c === void 0 ? 10 : _c, _d = _a.y, c = _d.c, d = _d.d, _e = _d.e, e = _e === void 0 ? { f: 1 } : _e; +} +function baz(x) { } +var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +var o1 = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +foo(o1); // Not error since x has contextual type of tuple namely [string, number] +foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error +var array = ["string", 1, true]; +var tuple = ["string", 1, true]; +baz(tuple); +baz(["string", 1, true]); +baz(array); // Error +baz(["string", 1, true].concat(array)); // Error +foo(o); // Error because x has an array type namely (string|number)[] diff --git a/tests/baselines/reference/arrayAssignmentTest1.js b/tests/baselines/reference/arrayAssignmentTest1.js index 0abfa889bed..43aad9921bb 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.js +++ b/tests/baselines/reference/arrayAssignmentTest1.js @@ -86,7 +86,7 @@ arr_any = c3; // should be an error - is arr_any = i1; // should be an error - is //// [arrayAssignmentTest1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/arrayAssignmentTest2.js b/tests/baselines/reference/arrayAssignmentTest2.js index 977862866ed..5aeb74114bc 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.js +++ b/tests/baselines/reference/arrayAssignmentTest2.js @@ -60,7 +60,7 @@ arr_any = i1; // should be an error - is //// [arrayAssignmentTest2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index f8e158e5b02..8d2445e2739 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -108,7 +108,7 @@ module NonEmptyTypes { //// [arrayBestCommonTypes.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt new file mode 100644 index 00000000000..3e9777aea7c --- /dev/null +++ b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(8,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'. + Types of property 'pop' are incompatible. + Type '() => string | number' is not assignable to type '() => number'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(14,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. + Property '0' is missing in type 'number[]'. + + +==== tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts (2 errors) ==== + // In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by + // the type of the property with the numeric name N in the contextual type, if any, or otherwise + // the numeric index type of the contextual type, if any. + var array = [1, 2, 3]; + var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type + var tup: [number, number, number] = [1, 2, 3, 4]; + var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"]; + var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error + ~~~~ +!!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'. +!!! error TS2322: Types of property 'pop' are incompatible. +!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'. +!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + // In a contextually typed array literal expression containing one or more spread elements, + // an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. + var spr = [1, 2, 3, ...array]; + var spr1 = [1, 2, 3, ...tup]; + var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error + ~~~~ +!!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. +!!! error TS2322: Property '0' is missing in type 'number[]'. + \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js new file mode 100644 index 00000000000..852a632f361 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js @@ -0,0 +1,31 @@ +//// [arrayLiteralExpressionContextualTyping.ts] +// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by +// the type of the property with the numeric name N in the contextual type, if any, or otherwise +// the numeric index type of the contextual type, if any. +var array = [1, 2, 3]; +var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type +var tup: [number, number, number] = [1, 2, 3, 4]; +var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"]; +var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error + +// In a contextually typed array literal expression containing one or more spread elements, +// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. +var spr = [1, 2, 3, ...array]; +var spr1 = [1, 2, 3, ...tup]; +var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error + + +//// [arrayLiteralExpressionContextualTyping.js] +// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by +// the type of the property with the numeric name N in the contextual type, if any, or otherwise +// the numeric index type of the contextual type, if any. +var array = [1, 2, 3]; +var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type +var tup = [1, 2, 3, 4]; +var tup1 = [1, 2, 3, "string"]; +var tup2 = [1, 2, 3, "string"]; // Error +// In a contextually typed array literal expression containing one or more spread elements, +// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. +var spr = [1, 2, 3].concat(array); +var spr1 = [1, 2, 3].concat(tup); +var spr2 = [1, 2, 3].concat(tup); // Error diff --git a/tests/baselines/reference/arrayLiteralSpread.js b/tests/baselines/reference/arrayLiteralSpread.js index 73a60714526..3561189671e 100644 --- a/tests/baselines/reference/arrayLiteralSpread.js +++ b/tests/baselines/reference/arrayLiteralSpread.js @@ -26,7 +26,7 @@ function f2() { //// [arrayLiteralSpread.js] function f0() { var a = [1, 2, 3]; - var a1 = a; + var a1 = a.slice(); var a2 = [1].concat(a); var a3 = [1, 2].concat(a); var a4 = a.concat([1]); diff --git a/tests/baselines/reference/arrayLiteralTypeInference.js b/tests/baselines/reference/arrayLiteralTypeInference.js index 28aa143fa61..dfd662bbf1c 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.js +++ b/tests/baselines/reference/arrayLiteralTypeInference.js @@ -52,7 +52,7 @@ var z3: { id: number }[] = //// [arrayLiteralTypeInference.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index 16e5ec7eee4..cb1d25258f2 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -38,7 +38,7 @@ var context4: Base[] = [new Derived1(), new Derived1()]; //// [arrayLiterals.js] // Empty array literal with no contextual type has type Undefined[] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/arrayLiterals2ES5.js b/tests/baselines/reference/arrayLiterals2ES5.js new file mode 100644 index 00000000000..6a81ab465a2 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals2ES5.js @@ -0,0 +1,104 @@ +//// [arrayLiterals2ES5.ts] +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [,, 2, 3, 4] +var a1 = ["hello", "world"] +var a2 = [, , , ...a0, "hello"]; +var a3 = [,, ...a0] +var a4 = [() => 1, ]; +var a5 = [...a0, , ] + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +var temp3 = [undefined, null, undefined]; +var temp4 = []; + +interface myArray extends Array { } +interface myArray2 extends Array { } +var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] +var d1 = [...temp]; // has type string[] +var d2: number[] = [...temp1]; +var d3: myArray = [...temp1]; +var d4: myArray2 = [...temp, ...temp1]; +var d5 = [...temp3]; +var d6 = [...temp4]; +var d7 = [...[...temp1]]; +var d8: number[][] = [[...temp1]] +var d9 = [[...temp1], ...["hello"]]; + +//// [arrayLiterals2ES5.js] +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement +// SpreadElement: +// ... AssignmentExpression +var a0 = [, , 2, 3, 4]; +var a1 = ["hello", "world"]; +var a2 = [, , ].concat(a0, ["hello"]); +var a3 = [, ].concat(a0); +var a4 = [function () { return 1; },]; +var a5 = a0.concat([,]); +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. +var b0 = [undefined, null, undefined]; +var b1 = [[1, 2, 3], ["hello", "string"]]; +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. +var _a = [1, 2], c0 = _a[0], c1 = _a[1]; // tuple type [number, number] +var _b = [1, 2, true], c2 = _b[0], c3 = _b[1]; // tuple type [number, number, boolean] +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2 = [[1, 2, 3], ["hello", "string"]]; +var temp3 = [undefined, null, undefined]; +var temp4 = []; +var d0 = [1, true].concat(temp); // has type (string|number|boolean)[] +var d1 = temp.slice(); // has type string[] +var d2 = temp1.slice(); +var d3 = temp1.slice(); +var d4 = temp.concat(temp1); +var d5 = temp3.slice(); +var d6 = temp4.slice(); +var d7 = temp1.slice(); +var d8 = [temp1.slice()]; +var d9 = [temp1.slice()].concat(["hello"]); diff --git a/tests/baselines/reference/arrayLiterals2ES5.symbols b/tests/baselines/reference/arrayLiterals2ES5.symbols new file mode 100644 index 00000000000..c69b79de272 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals2ES5.symbols @@ -0,0 +1,134 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES5.ts === +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [,, 2, 3, 4] +>a0 : Symbol(a0, Decl(arrayLiterals2ES5.ts, 9, 3)) + +var a1 = ["hello", "world"] +>a1 : Symbol(a1, Decl(arrayLiterals2ES5.ts, 10, 3)) + +var a2 = [, , , ...a0, "hello"]; +>a2 : Symbol(a2, Decl(arrayLiterals2ES5.ts, 11, 3)) +>a0 : Symbol(a0, Decl(arrayLiterals2ES5.ts, 9, 3)) + +var a3 = [,, ...a0] +>a3 : Symbol(a3, Decl(arrayLiterals2ES5.ts, 12, 3)) +>a0 : Symbol(a0, Decl(arrayLiterals2ES5.ts, 9, 3)) + +var a4 = [() => 1, ]; +>a4 : Symbol(a4, Decl(arrayLiterals2ES5.ts, 13, 3)) + +var a5 = [...a0, , ] +>a5 : Symbol(a5, Decl(arrayLiterals2ES5.ts, 14, 3)) +>a0 : Symbol(a0, Decl(arrayLiterals2ES5.ts, 9, 3)) + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +>b0 : Symbol(b0, Decl(arrayLiterals2ES5.ts, 25, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>b1 : Symbol(b1, Decl(arrayLiterals2ES5.ts, 26, 3)) + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +>c0 : Symbol(c0, Decl(arrayLiterals2ES5.ts, 32, 5)) +>c1 : Symbol(c1, Decl(arrayLiterals2ES5.ts, 32, 8)) + +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] +>c2 : Symbol(c2, Decl(arrayLiterals2ES5.ts, 33, 5)) +>c3 : Symbol(c3, Decl(arrayLiterals2ES5.ts, 33, 8)) + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +>temp : Symbol(temp, Decl(arrayLiterals2ES5.ts, 38, 3)) + +var temp1 = [1, 2, 3]; +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>temp2 : Symbol(temp2, Decl(arrayLiterals2ES5.ts, 40, 3)) + +var temp3 = [undefined, null, undefined]; +>temp3 : Symbol(temp3, Decl(arrayLiterals2ES5.ts, 41, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +var temp4 = []; +>temp4 : Symbol(temp4, Decl(arrayLiterals2ES5.ts, 42, 3)) + +interface myArray extends Array { } +>myArray : Symbol(myArray, Decl(arrayLiterals2ES5.ts, 42, 15)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) + +interface myArray2 extends Array { } +>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES5.ts, 44, 43)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11)) + +var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] +>d0 : Symbol(d0, Decl(arrayLiterals2ES5.ts, 46, 3)) +>temp : Symbol(temp, Decl(arrayLiterals2ES5.ts, 38, 3)) + +var d1 = [...temp]; // has type string[] +>d1 : Symbol(d1, Decl(arrayLiterals2ES5.ts, 47, 3)) +>temp : Symbol(temp, Decl(arrayLiterals2ES5.ts, 38, 3)) + +var d2: number[] = [...temp1]; +>d2 : Symbol(d2, Decl(arrayLiterals2ES5.ts, 48, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + +var d3: myArray = [...temp1]; +>d3 : Symbol(d3, Decl(arrayLiterals2ES5.ts, 49, 3)) +>myArray : Symbol(myArray, Decl(arrayLiterals2ES5.ts, 42, 15)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + +var d4: myArray2 = [...temp, ...temp1]; +>d4 : Symbol(d4, Decl(arrayLiterals2ES5.ts, 50, 3)) +>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES5.ts, 44, 43)) +>temp : Symbol(temp, Decl(arrayLiterals2ES5.ts, 38, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + +var d5 = [...temp3]; +>d5 : Symbol(d5, Decl(arrayLiterals2ES5.ts, 51, 3)) +>temp3 : Symbol(temp3, Decl(arrayLiterals2ES5.ts, 41, 3)) + +var d6 = [...temp4]; +>d6 : Symbol(d6, Decl(arrayLiterals2ES5.ts, 52, 3)) +>temp4 : Symbol(temp4, Decl(arrayLiterals2ES5.ts, 42, 3)) + +var d7 = [...[...temp1]]; +>d7 : Symbol(d7, Decl(arrayLiterals2ES5.ts, 53, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + +var d8: number[][] = [[...temp1]] +>d8 : Symbol(d8, Decl(arrayLiterals2ES5.ts, 54, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + +var d9 = [[...temp1], ...["hello"]]; +>d9 : Symbol(d9, Decl(arrayLiterals2ES5.ts, 55, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES5.ts, 39, 3)) + diff --git a/tests/baselines/reference/arrayLiterals2ES5.types b/tests/baselines/reference/arrayLiterals2ES5.types new file mode 100644 index 00000000000..6eae997f465 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals2ES5.types @@ -0,0 +1,225 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES5.ts === +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [,, 2, 3, 4] +>a0 : number[] +>[,, 2, 3, 4] : number[] +> : undefined +> : undefined +>2 : number +>3 : number +>4 : number + +var a1 = ["hello", "world"] +>a1 : string[] +>["hello", "world"] : string[] +>"hello" : string +>"world" : string + +var a2 = [, , , ...a0, "hello"]; +>a2 : (string | number)[] +>[, , , ...a0, "hello"] : (string | number)[] +> : undefined +> : undefined +> : undefined +>...a0 : number +>a0 : number[] +>"hello" : string + +var a3 = [,, ...a0] +>a3 : number[] +>[,, ...a0] : number[] +> : undefined +> : undefined +>...a0 : number +>a0 : number[] + +var a4 = [() => 1, ]; +>a4 : (() => number)[] +>[() => 1, ] : (() => number)[] +>() => 1 : () => number +>1 : number + +var a5 = [...a0, , ] +>a5 : number[] +>[...a0, , ] : number[] +>...a0 : number +>a0 : number[] +> : undefined + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +>b0 : [any, any, any] +>[undefined, null, undefined] : [undefined, null, undefined] +>undefined : undefined +>null : null +>undefined : undefined + +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>b1 : [number[], string[]] +>[[1, 2, 3], ["hello", "string"]] : [number[], string[]] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number +>["hello", "string"] : string[] +>"hello" : string +>"string" : string + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +>c0 : number +>c1 : number +>[1, 2] : [number, number] +>1 : number +>2 : number + +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] +>c2 : number +>c3 : number +>[1, 2, true] : [number, number, boolean] +>1 : number +>2 : number +>true : boolean + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +>temp : string[] +>["s", "t", "r"] : string[] +>"s" : string +>"t" : string +>"r" : string + +var temp1 = [1, 2, 3]; +>temp1 : number[] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number + +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>temp2 : [number[], string[]] +>[[1, 2, 3], ["hello", "string"]] : [number[], string[]] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number +>["hello", "string"] : string[] +>"hello" : string +>"string" : string + +var temp3 = [undefined, null, undefined]; +>temp3 : any[] +>[undefined, null, undefined] : null[] +>undefined : undefined +>null : null +>undefined : undefined + +var temp4 = []; +>temp4 : any[] +>[] : undefined[] + +interface myArray extends Array { } +>myArray : myArray +>Array : T[] +>Number : Number + +interface myArray2 extends Array { } +>myArray2 : myArray2 +>Array : T[] +>Number : Number +>String : String + +var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] +>d0 : (string | number | boolean)[] +>[1, true, ...temp,] : (string | number | boolean)[] +>1 : number +>true : boolean +>...temp : string +>temp : string[] + +var d1 = [...temp]; // has type string[] +>d1 : string[] +>[...temp] : string[] +>...temp : string +>temp : string[] + +var d2: number[] = [...temp1]; +>d2 : number[] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d3: myArray = [...temp1]; +>d3 : myArray +>myArray : myArray +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d4: myArray2 = [...temp, ...temp1]; +>d4 : myArray2 +>myArray2 : myArray2 +>[...temp, ...temp1] : (string | number)[] +>...temp : string +>temp : string[] +>...temp1 : number +>temp1 : number[] + +var d5 = [...temp3]; +>d5 : any[] +>[...temp3] : any[] +>...temp3 : any +>temp3 : any[] + +var d6 = [...temp4]; +>d6 : any[] +>[...temp4] : any[] +>...temp4 : any +>temp4 : any[] + +var d7 = [...[...temp1]]; +>d7 : number[] +>[...[...temp1]] : number[] +>...[...temp1] : number +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d8: number[][] = [[...temp1]] +>d8 : number[][] +>[[...temp1]] : number[][] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d9 = [[...temp1], ...["hello"]]; +>d9 : (string | number[])[] +>[[...temp1], ...["hello"]] : (string | number[])[] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] +>...["hello"] : string +>["hello"] : string[] +>"hello" : string + diff --git a/tests/baselines/reference/arrayLiterals2ES6.js b/tests/baselines/reference/arrayLiterals2ES6.js new file mode 100644 index 00000000000..cb6bf2684e8 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals2ES6.js @@ -0,0 +1,100 @@ +//// [arrayLiterals2ES6.ts] +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [, , 2, 3, 4] +var a1 = ["hello", "world"] +var a2 = [, , , ...a0, "hello"]; +var a3 = [, , ...a0] +var a4 = [() => 1, ]; +var a5 = [...a0, , ] + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +interface myArray extends Array { } +interface myArray2 extends Array { } +var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] +var d1 = [...temp]; // has type string[] +var d2: number[] = [...temp1]; +var d3: myArray = [...temp1]; +var d4: myArray2 = [...temp, ...temp1]; +var d5 = [...a2]; +var d6 = [...a3]; +var d7 = [...a4]; +var d8: number[][] = [[...temp1]] +var d9 = [[...temp1], ...["hello"]]; + +//// [arrayLiterals2ES6.js] +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement +// SpreadElement: +// ... AssignmentExpression +var a0 = [, , 2, 3, 4]; +var a1 = ["hello", "world"]; +var a2 = [, , , ...a0, "hello"]; +var a3 = [, , ...a0]; +var a4 = [() => 1,]; +var a5 = [...a0, ,]; +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. +var b0 = [undefined, null, undefined]; +var b1 = [[1, 2, 3], ["hello", "string"]]; +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. +var [c0, c1] = [1, 2]; // tuple type [number, number] +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2 = [[1, 2, 3], ["hello", "string"]]; +var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] +var d1 = [...temp]; // has type string[] +var d2 = [...temp1]; +var d3 = [...temp1]; +var d4 = [...temp, ...temp1]; +var d5 = [...a2]; +var d6 = [...a3]; +var d7 = [...a4]; +var d8 = [[...temp1]]; +var d9 = [[...temp1], ...["hello"]]; diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols new file mode 100644 index 00000000000..3b435de2e51 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -0,0 +1,126 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES6.ts === +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [, , 2, 3, 4] +>a0 : Symbol(a0, Decl(arrayLiterals2ES6.ts, 9, 3)) + +var a1 = ["hello", "world"] +>a1 : Symbol(a1, Decl(arrayLiterals2ES6.ts, 10, 3)) + +var a2 = [, , , ...a0, "hello"]; +>a2 : Symbol(a2, Decl(arrayLiterals2ES6.ts, 11, 3)) +>a0 : Symbol(a0, Decl(arrayLiterals2ES6.ts, 9, 3)) + +var a3 = [, , ...a0] +>a3 : Symbol(a3, Decl(arrayLiterals2ES6.ts, 12, 3)) +>a0 : Symbol(a0, Decl(arrayLiterals2ES6.ts, 9, 3)) + +var a4 = [() => 1, ]; +>a4 : Symbol(a4, Decl(arrayLiterals2ES6.ts, 13, 3)) + +var a5 = [...a0, , ] +>a5 : Symbol(a5, Decl(arrayLiterals2ES6.ts, 14, 3)) +>a0 : Symbol(a0, Decl(arrayLiterals2ES6.ts, 9, 3)) + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +>b0 : Symbol(b0, Decl(arrayLiterals2ES6.ts, 25, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>b1 : Symbol(b1, Decl(arrayLiterals2ES6.ts, 26, 3)) + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +>c0 : Symbol(c0, Decl(arrayLiterals2ES6.ts, 32, 5)) +>c1 : Symbol(c1, Decl(arrayLiterals2ES6.ts, 32, 8)) + +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] +>c2 : Symbol(c2, Decl(arrayLiterals2ES6.ts, 33, 5)) +>c3 : Symbol(c3, Decl(arrayLiterals2ES6.ts, 33, 8)) + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +>temp : Symbol(temp, Decl(arrayLiterals2ES6.ts, 38, 3)) + +var temp1 = [1, 2, 3]; +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES6.ts, 39, 3)) + +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>temp2 : Symbol(temp2, Decl(arrayLiterals2ES6.ts, 40, 3)) + +interface myArray extends Array { } +>myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) + +interface myArray2 extends Array { } +>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] +>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) +>temp : Symbol(temp, Decl(arrayLiterals2ES6.ts, 38, 3)) + +var d1 = [...temp]; // has type string[] +>d1 : Symbol(d1, Decl(arrayLiterals2ES6.ts, 45, 3)) +>temp : Symbol(temp, Decl(arrayLiterals2ES6.ts, 38, 3)) + +var d2: number[] = [...temp1]; +>d2 : Symbol(d2, Decl(arrayLiterals2ES6.ts, 46, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES6.ts, 39, 3)) + +var d3: myArray = [...temp1]; +>d3 : Symbol(d3, Decl(arrayLiterals2ES6.ts, 47, 3)) +>myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES6.ts, 39, 3)) + +var d4: myArray2 = [...temp, ...temp1]; +>d4 : Symbol(d4, Decl(arrayLiterals2ES6.ts, 48, 3)) +>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) +>temp : Symbol(temp, Decl(arrayLiterals2ES6.ts, 38, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES6.ts, 39, 3)) + +var d5 = [...a2]; +>d5 : Symbol(d5, Decl(arrayLiterals2ES6.ts, 49, 3)) +>a2 : Symbol(a2, Decl(arrayLiterals2ES6.ts, 11, 3)) + +var d6 = [...a3]; +>d6 : Symbol(d6, Decl(arrayLiterals2ES6.ts, 50, 3)) +>a3 : Symbol(a3, Decl(arrayLiterals2ES6.ts, 12, 3)) + +var d7 = [...a4]; +>d7 : Symbol(d7, Decl(arrayLiterals2ES6.ts, 51, 3)) +>a4 : Symbol(a4, Decl(arrayLiterals2ES6.ts, 13, 3)) + +var d8: number[][] = [[...temp1]] +>d8 : Symbol(d8, Decl(arrayLiterals2ES6.ts, 52, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES6.ts, 39, 3)) + +var d9 = [[...temp1], ...["hello"]]; +>d9 : Symbol(d9, Decl(arrayLiterals2ES6.ts, 53, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals2ES6.ts, 39, 3)) + diff --git a/tests/baselines/reference/arrayLiterals2ES6.types b/tests/baselines/reference/arrayLiterals2ES6.types new file mode 100644 index 00000000000..f05b0ca9282 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals2ES6.types @@ -0,0 +1,212 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES6.ts === +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [, , 2, 3, 4] +>a0 : number[] +>[, , 2, 3, 4] : number[] +> : undefined +> : undefined +>2 : number +>3 : number +>4 : number + +var a1 = ["hello", "world"] +>a1 : string[] +>["hello", "world"] : string[] +>"hello" : string +>"world" : string + +var a2 = [, , , ...a0, "hello"]; +>a2 : (string | number)[] +>[, , , ...a0, "hello"] : (string | number)[] +> : undefined +> : undefined +> : undefined +>...a0 : number +>a0 : number[] +>"hello" : string + +var a3 = [, , ...a0] +>a3 : number[] +>[, , ...a0] : number[] +> : undefined +> : undefined +>...a0 : number +>a0 : number[] + +var a4 = [() => 1, ]; +>a4 : (() => number)[] +>[() => 1, ] : (() => number)[] +>() => 1 : () => number +>1 : number + +var a5 = [...a0, , ] +>a5 : number[] +>[...a0, , ] : number[] +>...a0 : number +>a0 : number[] +> : undefined + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +>b0 : [any, any, any] +>[undefined, null, undefined] : [undefined, null, undefined] +>undefined : undefined +>null : null +>undefined : undefined + +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>b1 : [number[], string[]] +>[[1, 2, 3], ["hello", "string"]] : [number[], string[]] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number +>["hello", "string"] : string[] +>"hello" : string +>"string" : string + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +>c0 : number +>c1 : number +>[1, 2] : [number, number] +>1 : number +>2 : number + +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] +>c2 : number +>c3 : number +>[1, 2, true] : [number, number, boolean] +>1 : number +>2 : number +>true : boolean + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +>temp : string[] +>["s", "t", "r"] : string[] +>"s" : string +>"t" : string +>"r" : string + +var temp1 = [1, 2, 3]; +>temp1 : number[] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number + +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>temp2 : [number[], string[]] +>[[1, 2, 3], ["hello", "string"]] : [number[], string[]] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number +>["hello", "string"] : string[] +>"hello" : string +>"string" : string + +interface myArray extends Array { } +>myArray : myArray +>Array : T[] +>Number : Number + +interface myArray2 extends Array { } +>myArray2 : myArray2 +>Array : T[] +>Number : Number +>String : String + +var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] +>d0 : (string | number | boolean)[] +>[1, true, ...temp, ] : (string | number | boolean)[] +>1 : number +>true : boolean +>...temp : string +>temp : string[] + +var d1 = [...temp]; // has type string[] +>d1 : string[] +>[...temp] : string[] +>...temp : string +>temp : string[] + +var d2: number[] = [...temp1]; +>d2 : number[] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d3: myArray = [...temp1]; +>d3 : myArray +>myArray : myArray +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d4: myArray2 = [...temp, ...temp1]; +>d4 : myArray2 +>myArray2 : myArray2 +>[...temp, ...temp1] : (string | number)[] +>...temp : string +>temp : string[] +>...temp1 : number +>temp1 : number[] + +var d5 = [...a2]; +>d5 : (string | number)[] +>[...a2] : (string | number)[] +>...a2 : string | number +>a2 : (string | number)[] + +var d6 = [...a3]; +>d6 : number[] +>[...a3] : number[] +>...a3 : number +>a3 : number[] + +var d7 = [...a4]; +>d7 : (() => number)[] +>[...a4] : (() => number)[] +>...a4 : () => number +>a4 : (() => number)[] + +var d8: number[][] = [[...temp1]] +>d8 : number[][] +>[[...temp1]] : number[][] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var d9 = [[...temp1], ...["hello"]]; +>d9 : (string | number[])[] +>[[...temp1], ...["hello"]] : (string | number[])[] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] +>...["hello"] : string +>["hello"] : string[] +>"hello" : string + diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt new file mode 100644 index 00000000000..74cfdb165d7 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -0,0 +1,86 @@ +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2322: Type 'undefined[]' is not assignable to type '[any, any, any]'. + Property '0' is missing in type 'undefined[]'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. + Types of property 'pop' are incompatible. + Type '() => string | number | boolean' is not assignable to type '() => number'. + Type 'string | number | boolean' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(string[] | number[])[]' is not assignable to type 'tup'. + Property '0' is missing in type '(string[] | number[])[]'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. + Property '0' is missing in type 'number[]'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. + Types of property 'push' are incompatible. + Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'. + Types of parameters 'items' and 'items' are incompatible. + Type 'string | number' is not assignable to type 'Number'. + Type 'string' is not assignable to type 'Number'. + Property 'toFixed' is missing in type 'String'. + + +==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ==== + // Each element expression in a non-empty array literal is processed as follows: + // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) + // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, + // the element expression is contextually typed by the type of that property. + + // The resulting type an array literal expression is determined as follows: + // - If the array literal contains no spread elements and is contextually typed by a tuple-like type, + // the resulting type is a tuple type constructed from the types of the element expressions. + + var a0: [any, any, any] = []; // Error + ~~ +!!! error TS2322: Type 'undefined[]' is not assignable to type '[any, any, any]'. +!!! error TS2322: Property '0' is missing in type 'undefined[]'. + var a1: [boolean, string, number] = ["string", 1, true]; // Error + ~~ +!!! error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + + // The resulting type an array literal expression is determined as follows: + // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), + // the resulting type is a tuple type constructed from the types of the element expressions. + + var [b1, b2]: [number, number] = [1, 2, "string", true]; + ~~~~~~~~ +!!! error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. +!!! error TS2322: Types of property 'pop' are incompatible. +!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => number'. +!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + // The resulting type an array literal expression is determined as follows: + // - the resulting type is an array type with an element type that is the union of the types of the + // non - spread element expressions and the numeric index signature types of the spread element expressions + var temp = ["s", "t", "r"]; + var temp1 = [1, 2, 3]; + var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + + interface tup { + 0: number[]|string[]; + 1: number[]|string[]; + } + interface myArray extends Array { } + interface myArray2 extends Array { } + var c0: tup = [...temp2]; // Error + ~~ +!!! error TS2322: Type '(string[] | number[])[]' is not assignable to type 'tup'. +!!! error TS2322: Property '0' is missing in type '(string[] | number[])[]'. + var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] + ~~ +!!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. +!!! error TS2322: Property '0' is missing in type 'number[]'. + var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] + ~~ +!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. +!!! error TS2322: Types of property 'push' are incompatible. +!!! error TS2322: Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'. +!!! error TS2322: Types of parameters 'items' and 'items' are incompatible. +!!! error TS2322: Type 'string | number' is not assignable to type 'Number'. +!!! error TS2322: Type 'string' is not assignable to type 'Number'. +!!! error TS2322: Property 'toFixed' is missing in type 'String'. + \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiterals3.js b/tests/baselines/reference/arrayLiterals3.js new file mode 100644 index 00000000000..4769c069988 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals3.js @@ -0,0 +1,60 @@ +//// [arrayLiterals3.ts] +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var a0: [any, any, any] = []; // Error +var a1: [boolean, string, number] = ["string", 1, true]; // Error + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [b1, b2]: [number, number] = [1, 2, "string", true]; + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +interface tup { + 0: number[]|string[]; + 1: number[]|string[]; +} +interface myArray extends Array { } +interface myArray2 extends Array { } +var c0: tup = [...temp2]; // Error +var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] +var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] + + +//// [arrayLiterals3.js] +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. +var a0 = []; // Error +var a1 = ["string", 1, true]; // Error +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. +var _a = [1, 2, "string", true], b1 = _a[0], b2 = _a[1]; +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2 = [[1, 2, 3], ["hello", "string"]]; +var c0 = temp2.slice(); // Error +var c1 = temp1.slice(); // Error cannot assign number[] to [number, number, number] +var c2 = temp1.concat(temp); // Error cannot assign (number|string)[] to number[] diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js index f15215a88eb..b3c0a0f7877 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js @@ -26,7 +26,7 @@ var myDerivedList: DerivedList; var as = [list, myDerivedList]; // List[] //// [arrayLiteralsWithRecursiveGenerics.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index a10e3955ae0..f4a11fb47ae 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -97,7 +97,7 @@ var asserted2: any; //// [arrowFunctionContexts.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js index 8d33412bb4b..1ad82ca531b 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js @@ -101,7 +101,7 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures3.js] // these are all permitted with the current rules, since we do not do contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js index 926d8eb13e1..387395525ad 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js @@ -100,7 +100,7 @@ module Errors { //// [assignmentCompatWithCallSignatures4.js] // These are mostly permitted with the current loose rules. All ok unless otherwise noted. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js index afe3166ccb5..2e3790cd529 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js @@ -67,7 +67,7 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures5.js] // checking assignment compat for function types. No errors in this file -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js index 0db1f1f79fb..a29a607f9ef 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js @@ -44,7 +44,7 @@ b16 = x.a16; //// [assignmentCompatWithCallSignatures6.js] // checking assignment compatibility relations for function types. All valid -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js index 1926f0e0684..32176e764e9 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js @@ -101,7 +101,7 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures3.js] // checking assignment compatibility relations for function types. All of these are valid. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js index 9e12f0f360d..21bace1645c 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js @@ -100,7 +100,7 @@ module Errors { //// [assignmentCompatWithConstructSignatures4.js] // checking assignment compatibility relations for function types. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js index 1b26d813d45..76be317e95a 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js @@ -67,7 +67,7 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures5.js] // checking assignment compat for function types. All valid -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js index ccca809c281..dc1d0dd2dee 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js @@ -44,7 +44,7 @@ b16 = x.a16; //// [assignmentCompatWithConstructSignatures6.js] // checking assignment compatibility relations for function types. All valid. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js index a139787130e..6044c40b3cc 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js @@ -45,7 +45,7 @@ module Generics { //// [assignmentCompatWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js index 8aa8dca511e..b3c073ea0b7 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js @@ -42,7 +42,7 @@ module Generics { //// [assignmentCompatWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js index 0d535cbb20d..229525a91f0 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js @@ -93,7 +93,7 @@ module WithBase { //// [assignmentCompatWithObjectMembers4.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js index 5525b623ecc..629f7bf5113 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js @@ -90,7 +90,7 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality.js] // Derived member is not optional but base member is, should be ok -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index 8859a4c9ab0..4ffec4aa7dd 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -92,7 +92,7 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality2.js] // M is optional and S contains no property with the same name as M // N is optional and T contains no property with the same name as N -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.js b/tests/baselines/reference/assignmentCompatWithStringIndexer.js index b54c75a1bec..99457453af4 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.js @@ -55,7 +55,7 @@ module Generics { //// [assignmentCompatWithStringIndexer.js] // index signatures must be compatible in assignments -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/assignmentLHSIsValue.js b/tests/baselines/reference/assignmentLHSIsValue.js index 4b17f855171..d5276e71a9b 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.js +++ b/tests/baselines/reference/assignmentLHSIsValue.js @@ -71,7 +71,7 @@ foo() = value; (foo()) = value; //// [assignmentLHSIsValue.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 6a903b890d8..5986ef4a3f5 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -24,7 +24,7 @@ class Point3D extends Point { //// [autolift4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/baseCheck.js b/tests/baselines/reference/baseCheck.js index 2ebefcbade2..4e7db8e6a5b 100644 --- a/tests/baselines/reference/baseCheck.js +++ b/tests/baselines/reference/baseCheck.js @@ -30,7 +30,7 @@ function f() { //// [baseCheck.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 4720e92b969..85b76221e3c 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -25,7 +25,7 @@ var z: Derived = b.foo(); */ //// [baseIndexSignatureResolution.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/baseTypeOrderChecking.js b/tests/baselines/reference/baseTypeOrderChecking.js index b206ef2b911..754d90e21ea 100644 --- a/tests/baselines/reference/baseTypeOrderChecking.js +++ b/tests/baselines/reference/baseTypeOrderChecking.js @@ -37,7 +37,7 @@ class Class4 extends Class3 //// [baseTypeOrderChecking.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js index 97180f42133..aaa93710339 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -27,7 +27,7 @@ class Wrapper { } //// [baseTypeWrappingInstantiationChain.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/bases.js b/tests/baselines/reference/bases.js index 32d65d1a248..5687e9e0fe1 100644 --- a/tests/baselines/reference/bases.js +++ b/tests/baselines/reference/bases.js @@ -21,7 +21,7 @@ new C().y; //// [bases.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js index 49bc535dbfe..e56e530ad64 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js @@ -29,7 +29,7 @@ function foo5(t: T, u: U): Object { //// [bestCommonTypeOfConditionalExpressions.js] // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // no errors expected here -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js index 49659de94d4..fb3c15a8fba 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js @@ -27,7 +27,7 @@ function foo3(t: T, u: U) { //// [bestCommonTypeOfConditionalExpressions2.js] // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // these are errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.js b/tests/baselines/reference/bestCommonTypeOfTuple2.js index f9183f41348..5642df5570c 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.js @@ -23,7 +23,7 @@ var e51 = t5[2]; // {} //// [bestCommonTypeOfTuple2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 8bb4cb665a2..685e33acb6b 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -71,7 +71,7 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js index 31cdc8980fd..135c0c056ae 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js @@ -116,7 +116,7 @@ module Errors { //// [callSignatureAssignabilityInInheritance3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js index 2f9cbc2a9e7..c578a49ee55 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js @@ -51,7 +51,7 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index 0cb4830188a..74987308ef7 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -51,7 +51,7 @@ interface I extends B { //// [callSignatureAssignabilityInInheritance5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js index dd471f09223..aa2e9787bd1 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js @@ -54,7 +54,7 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures4 but using class type parameters instead of generic signatures // all are errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index d676c0f2a33..c9cd5d2adce 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -54,7 +54,7 @@ var c = new C(1, 2, ...a); //// [callWithSpread.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 0dd186210b2..94e0b94b002 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1325, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1355, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/captureThisInSuperCall.js b/tests/baselines/reference/captureThisInSuperCall.js index 7200fabd8c4..27c80e2991d 100644 --- a/tests/baselines/reference/captureThisInSuperCall.js +++ b/tests/baselines/reference/captureThisInSuperCall.js @@ -9,7 +9,7 @@ class B extends A { } //// [captureThisInSuperCall.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/castingTuple.js b/tests/baselines/reference/castingTuple.js index 2c41d81cd6a..8b1005d4487 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -33,7 +33,7 @@ t4[2] = 10; //// [castingTuple.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/chainedAssignment3.js b/tests/baselines/reference/chainedAssignment3.js index 11b9ceb3a07..022668ba7cf 100644 --- a/tests/baselines/reference/chainedAssignment3.js +++ b/tests/baselines/reference/chainedAssignment3.js @@ -23,7 +23,7 @@ a = b = new A(); //// [chainedAssignment3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js index 70456b9e9d1..494f0bc1b5d 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js @@ -20,7 +20,7 @@ class C extends B { (new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A); //// [chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/checkForObjectTooStrict.js b/tests/baselines/reference/checkForObjectTooStrict.js index b134ff2a40a..bcdde6b3be1 100644 --- a/tests/baselines/reference/checkForObjectTooStrict.js +++ b/tests/baselines/reference/checkForObjectTooStrict.js @@ -32,7 +32,7 @@ class Baz extends Object { //// [checkForObjectTooStrict.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/circularImportAlias.js b/tests/baselines/reference/circularImportAlias.js index b1d435cc8ce..1a50a46221b 100644 --- a/tests/baselines/reference/circularImportAlias.js +++ b/tests/baselines/reference/circularImportAlias.js @@ -21,7 +21,7 @@ var c = new B.a.C(); //// [circularImportAlias.js] // expected no error -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt b/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt new file mode 100644 index 00000000000..26bff709ae1 --- /dev/null +++ b/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(1,6): error TS2456: Type alias 'typeAlias1' circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(2,5): error TS2502: 'varOfAliasedType1' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(4,5): error TS2502: 'varOfAliasedType2' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(5,6): error TS2456: Type alias 'typeAlias2' circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(9,6): error TS2456: Type alias 'typeAlias3' circularly references itself. + + +==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (5 errors) ==== + type typeAlias1 = typeof varOfAliasedType1; + ~~~~~~~~~~ +!!! error TS2456: Type alias 'typeAlias1' circularly references itself. + var varOfAliasedType1: typeAlias1; + ~~~~~~~~~~~~~~~~~ +!!! error TS2502: 'varOfAliasedType1' is referenced directly or indirectly in its own type annotation. + + var varOfAliasedType2: typeAlias2; + ~~~~~~~~~~~~~~~~~ +!!! error TS2502: 'varOfAliasedType2' is referenced directly or indirectly in its own type annotation. + type typeAlias2 = typeof varOfAliasedType2; + ~~~~~~~~~~ +!!! error TS2456: Type alias 'typeAlias2' circularly references itself. + + function func(): typeAlias3 { return null; } + var varOfAliasedType3 = func(); + type typeAlias3 = typeof varOfAliasedType3; + ~~~~~~~~~~ +!!! error TS2456: Type alias 'typeAlias3' circularly references itself. + \ No newline at end of file diff --git a/tests/baselines/reference/circularTypeofWithVarOrFunc.js b/tests/baselines/reference/circularTypeofWithVarOrFunc.js new file mode 100644 index 00000000000..9d569a3d219 --- /dev/null +++ b/tests/baselines/reference/circularTypeofWithVarOrFunc.js @@ -0,0 +1,17 @@ +//// [circularTypeofWithVarOrFunc.ts] +type typeAlias1 = typeof varOfAliasedType1; +var varOfAliasedType1: typeAlias1; + +var varOfAliasedType2: typeAlias2; +type typeAlias2 = typeof varOfAliasedType2; + +function func(): typeAlias3 { return null; } +var varOfAliasedType3 = func(); +type typeAlias3 = typeof varOfAliasedType3; + + +//// [circularTypeofWithVarOrFunc.js] +var varOfAliasedType1; +var varOfAliasedType2; +function func() { return null; } +var varOfAliasedType3 = func(); diff --git a/tests/baselines/reference/classConstructorParametersAccessibility.js b/tests/baselines/reference/classConstructorParametersAccessibility.js index 03d56d94e58..5d715556ec1 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility.js @@ -27,7 +27,7 @@ class Derived extends C3 { //// [classConstructorParametersAccessibility.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility2.js b/tests/baselines/reference/classConstructorParametersAccessibility2.js index 1b16d13c82a..1d273e119ec 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility2.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility2.js @@ -27,7 +27,7 @@ class Derived extends C3 { //// [classConstructorParametersAccessibility2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility3.js b/tests/baselines/reference/classConstructorParametersAccessibility3.js index 9bd6c4bf7f5..43823bbb4d9 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility3.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility3.js @@ -14,7 +14,7 @@ var d: Derived; d.p; // public, OK //// [classConstructorParametersAccessibility3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js index c2bd2f09cf2..7299b04720f 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js @@ -12,7 +12,7 @@ module M { } //// [classDeclarationMergedInModuleWithContinuation.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js index a62d5b1532b..52474582315 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js @@ -13,7 +13,7 @@ class StringTreeCollectionBase { class StringTreeCollection extends StringTreeCollectionBase { } //// [classDoesNotDependOnBaseTypes.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExpressionWithDecorator1.js b/tests/baselines/reference/classExpressionWithDecorator1.js index 754d6199115..4b1700df7af 100644 --- a/tests/baselines/reference/classExpressionWithDecorator1.js +++ b/tests/baselines/reference/classExpressionWithDecorator1.js @@ -2,7 +2,7 @@ var v = @decorate class C { static p = 1 }; //// [classExpressionWithDecorator1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/classExtendingClass.js b/tests/baselines/reference/classExtendingClass.js index 130bf5818ee..b8e079e8ecb 100644 --- a/tests/baselines/reference/classExtendingClass.js +++ b/tests/baselines/reference/classExtendingClass.js @@ -32,7 +32,7 @@ var r7 = d2.thing(''); var r8 = D2.other(1); //// [classExtendingClass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendingPrimitive.js b/tests/baselines/reference/classExtendingPrimitive.js index 45e92dde5f8..b099ce763e8 100644 --- a/tests/baselines/reference/classExtendingPrimitive.js +++ b/tests/baselines/reference/classExtendingPrimitive.js @@ -16,7 +16,7 @@ class C8 extends E { } //// [classExtendingPrimitive.js] // classes cannot extend primitives -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendingPrimitive2.js b/tests/baselines/reference/classExtendingPrimitive2.js index 4ac6b14121a..3dcff0b44b9 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.js +++ b/tests/baselines/reference/classExtendingPrimitive2.js @@ -6,7 +6,7 @@ class C5a extends null { } //// [classExtendingPrimitive2.js] // classes cannot extend primitives -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendingQualifiedName.js b/tests/baselines/reference/classExtendingQualifiedName.js index c6721909db7..0289797d1e3 100644 --- a/tests/baselines/reference/classExtendingQualifiedName.js +++ b/tests/baselines/reference/classExtendingQualifiedName.js @@ -8,7 +8,7 @@ module M { } //// [classExtendingQualifiedName.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendingQualifiedName2.js b/tests/baselines/reference/classExtendingQualifiedName2.js index 9fc31a231ea..76065ccc577 100644 --- a/tests/baselines/reference/classExtendingQualifiedName2.js +++ b/tests/baselines/reference/classExtendingQualifiedName2.js @@ -8,7 +8,7 @@ module M { } //// [classExtendingQualifiedName2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js index 6d4a9a09b67..21e0326f741 100644 --- a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js @@ -14,7 +14,7 @@ module Foo { } //// [classExtendsClauseClassMergedWithModuleNotReferingConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js index 03fcfa19a37..8dc3410a179 100644 --- a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js @@ -7,7 +7,7 @@ module Foo { //// [classExtendsClauseClassNotReferringConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsEveryObjectType.js b/tests/baselines/reference/classExtendsEveryObjectType.js index 30966fedafc..afbb4dab714 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.js +++ b/tests/baselines/reference/classExtendsEveryObjectType.js @@ -17,7 +17,7 @@ class C5 extends foo { } // error class C6 extends []{ } // error //// [classExtendsEveryObjectType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.js b/tests/baselines/reference/classExtendsEveryObjectType2.js index 37c0861f5ec..c41943072dd 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.js +++ b/tests/baselines/reference/classExtendsEveryObjectType2.js @@ -4,7 +4,7 @@ class C2 extends { foo: string; } { } // error class C6 extends []{ } // error //// [classExtendsEveryObjectType2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsInterface.js b/tests/baselines/reference/classExtendsInterface.js index e40c9154e31..a3e596299fa 100644 --- a/tests/baselines/reference/classExtendsInterface.js +++ b/tests/baselines/reference/classExtendsInterface.js @@ -9,7 +9,7 @@ class B2 implements Comparable2 {} //// [classExtendsInterface.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsItself.js b/tests/baselines/reference/classExtendsItself.js index bb6b68f07d6..79a4226731f 100644 --- a/tests/baselines/reference/classExtendsItself.js +++ b/tests/baselines/reference/classExtendsItself.js @@ -6,7 +6,7 @@ class D extends D { } // error class E extends E { } // error //// [classExtendsItself.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.js b/tests/baselines/reference/classExtendsItselfIndirectly.js index 11b697cff6b..eee52b877e3 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly.js @@ -12,7 +12,7 @@ class D2 extends C2 { bar: T; } class E2 extends D2 { baz: T; } //// [classExtendsItselfIndirectly.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.js b/tests/baselines/reference/classExtendsItselfIndirectly2.js index 129b2f51b36..02201425cba 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.js @@ -23,7 +23,7 @@ module O { } //// [classExtendsItselfIndirectly2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsItselfIndirectly3.js b/tests/baselines/reference/classExtendsItselfIndirectly3.js index 679525a40a6..bff6dd92bc9 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly3.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly3.js @@ -19,7 +19,7 @@ class D2 extends C2 { bar: T; } class E2 extends D2 { baz: T; } //// [classExtendsItselfIndirectly_file1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -33,7 +33,7 @@ var C = (function (_super) { return C; })(E); // error //// [classExtendsItselfIndirectly_file2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -47,7 +47,7 @@ var D = (function (_super) { return D; })(C); //// [classExtendsItselfIndirectly_file3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -61,7 +61,7 @@ var E = (function (_super) { return E; })(D); //// [classExtendsItselfIndirectly_file4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -75,7 +75,7 @@ var C2 = (function (_super) { return C2; })(E2); // error //// [classExtendsItselfIndirectly_file5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -89,7 +89,7 @@ var D2 = (function (_super) { return D2; })(C2); //// [classExtendsItselfIndirectly_file6.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsMultipleBaseClasses.js b/tests/baselines/reference/classExtendsMultipleBaseClasses.js index 07d6450f405..7027e85450d 100644 --- a/tests/baselines/reference/classExtendsMultipleBaseClasses.js +++ b/tests/baselines/reference/classExtendsMultipleBaseClasses.js @@ -4,7 +4,7 @@ class B { } class C extends A,B { } //// [classExtendsMultipleBaseClasses.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js index b7245b8095c..48f2e791139 100644 --- a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js +++ b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js @@ -9,7 +9,7 @@ module M { } //// [classExtendsShadowedConstructorFunction.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classExtendsValidConstructorFunction.js b/tests/baselines/reference/classExtendsValidConstructorFunction.js index c2f0f17e534..411bd3c2fba 100644 --- a/tests/baselines/reference/classExtendsValidConstructorFunction.js +++ b/tests/baselines/reference/classExtendsValidConstructorFunction.js @@ -6,7 +6,7 @@ var x = new foo(); // can be used as a constructor function class C extends foo { } // error, cannot extend it though //// [classExtendsValidConstructorFunction.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classHeritageWithTrailingSeparator.js b/tests/baselines/reference/classHeritageWithTrailingSeparator.js index 5c6470ffdfd..6d33f79a4d5 100644 --- a/tests/baselines/reference/classHeritageWithTrailingSeparator.js +++ b/tests/baselines/reference/classHeritageWithTrailingSeparator.js @@ -4,7 +4,7 @@ class D extends C, { } //// [classHeritageWithTrailingSeparator.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classImplementsClass2.js b/tests/baselines/reference/classImplementsClass2.js index bc4f6b6748c..49b73bfdb18 100644 --- a/tests/baselines/reference/classImplementsClass2.js +++ b/tests/baselines/reference/classImplementsClass2.js @@ -14,7 +14,7 @@ c = c2; c2 = c; //// [classImplementsClass2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classImplementsClass3.js b/tests/baselines/reference/classImplementsClass3.js index 450263d00c9..f8773b435bd 100644 --- a/tests/baselines/reference/classImplementsClass3.js +++ b/tests/baselines/reference/classImplementsClass3.js @@ -15,7 +15,7 @@ c = c2; c2 = c; //// [classImplementsClass3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classImplementsClass4.js b/tests/baselines/reference/classImplementsClass4.js index ac5c899bbbf..cf442b0ad24 100644 --- a/tests/baselines/reference/classImplementsClass4.js +++ b/tests/baselines/reference/classImplementsClass4.js @@ -17,7 +17,7 @@ c = c2; c2 = c; //// [classImplementsClass4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classImplementsClass5.js b/tests/baselines/reference/classImplementsClass5.js index a0971904cc3..a648f6bd63f 100644 --- a/tests/baselines/reference/classImplementsClass5.js +++ b/tests/baselines/reference/classImplementsClass5.js @@ -18,7 +18,7 @@ c = c2; c2 = c; //// [classImplementsClass5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classImplementsClass6.js b/tests/baselines/reference/classImplementsClass6.js index 931218e2bea..af6f0844d28 100644 --- a/tests/baselines/reference/classImplementsClass6.js +++ b/tests/baselines/reference/classImplementsClass6.js @@ -22,7 +22,7 @@ c.bar(); // error c2.bar(); // should error //// [classImplementsClass6.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classIndexer3.js b/tests/baselines/reference/classIndexer3.js index ca5c5913d75..9f630b96306 100644 --- a/tests/baselines/reference/classIndexer3.js +++ b/tests/baselines/reference/classIndexer3.js @@ -11,7 +11,7 @@ class D123 extends C123 { } //// [classIndexer3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classInheritence.js b/tests/baselines/reference/classInheritence.js index 3378aea91c0..374248c3a2c 100644 --- a/tests/baselines/reference/classInheritence.js +++ b/tests/baselines/reference/classInheritence.js @@ -3,7 +3,7 @@ class B extends A { } class A extends A { } //// [classInheritence.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.js b/tests/baselines/reference/classIsSubtypeOfBaseType.js index db9ae2adc28..a33bf5499be 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.js +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.js @@ -16,7 +16,7 @@ class Derived2 extends Base<{ bar: string; }> { } //// [classIsSubtypeOfBaseType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classOrder2.js b/tests/baselines/reference/classOrder2.js index 4bc1c3f790c..8eed39bddeb 100644 --- a/tests/baselines/reference/classOrder2.js +++ b/tests/baselines/reference/classOrder2.js @@ -20,7 +20,7 @@ a.foo(); //// [classOrder2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classOrderBug.js b/tests/baselines/reference/classOrderBug.js index ddf33831873..ae50152d608 100644 --- a/tests/baselines/reference/classOrderBug.js +++ b/tests/baselines/reference/classOrderBug.js @@ -16,7 +16,7 @@ class foo extends baz {} //// [classOrderBug.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classSideInheritance1.js b/tests/baselines/reference/classSideInheritance1.js index 74df624a78c..66cbc0c25c7 100644 --- a/tests/baselines/reference/classSideInheritance1.js +++ b/tests/baselines/reference/classSideInheritance1.js @@ -16,7 +16,7 @@ A.bar(); // valid C2.bar(); // valid //// [classSideInheritance1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classSideInheritance2.js b/tests/baselines/reference/classSideInheritance2.js index f848226bb0e..e09301fe85f 100644 --- a/tests/baselines/reference/classSideInheritance2.js +++ b/tests/baselines/reference/classSideInheritance2.js @@ -21,7 +21,7 @@ class TextBase implements IText { } //// [classSideInheritance2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classSideInheritance3.js b/tests/baselines/reference/classSideInheritance3.js index 9f90fad487b..a69b6ff0345 100644 --- a/tests/baselines/reference/classSideInheritance3.js +++ b/tests/baselines/reference/classSideInheritance3.js @@ -19,7 +19,7 @@ var r2: new (x: string) => A = B; // error var r3: typeof A = C; // ok //// [classSideInheritance3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classUpdateTests.js b/tests/baselines/reference/classUpdateTests.js index 351ddac52e8..90149d88d9d 100644 --- a/tests/baselines/reference/classUpdateTests.js +++ b/tests/baselines/reference/classUpdateTests.js @@ -114,7 +114,7 @@ class R { } //// [classUpdateTests.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classWithBaseClassButNoConstructor.js b/tests/baselines/reference/classWithBaseClassButNoConstructor.js index 2c881a29a7c..f1a10b317a1 100644 --- a/tests/baselines/reference/classWithBaseClassButNoConstructor.js +++ b/tests/baselines/reference/classWithBaseClassButNoConstructor.js @@ -41,7 +41,7 @@ var d5 = new D(); // error var d6 = new D(1); // ok //// [classWithBaseClassButNoConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classWithConstructors.js b/tests/baselines/reference/classWithConstructors.js index 10afc3a9f1b..467738e0966 100644 --- a/tests/baselines/reference/classWithConstructors.js +++ b/tests/baselines/reference/classWithConstructors.js @@ -50,7 +50,7 @@ module Generics { } //// [classWithConstructors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 4de87229ad0..7d86e1c7229 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -29,7 +29,7 @@ class D extends C { //// [classWithProtectedProperty.js] // accessing any protected outside the class is an error -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classWithStaticMembers.js b/tests/baselines/reference/classWithStaticMembers.js index 36b8bd0af64..edad6c22c70 100644 --- a/tests/baselines/reference/classWithStaticMembers.js +++ b/tests/baselines/reference/classWithStaticMembers.js @@ -20,7 +20,7 @@ var r2 = r.x; var r3 = r.foo; //// [classWithStaticMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js index e9253b61cac..127e0e9f32b 100644 --- a/tests/baselines/reference/classdecl.js +++ b/tests/baselines/reference/classdecl.js @@ -94,7 +94,7 @@ class e { } //// [classdecl.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/clodulesDerivedClasses.js b/tests/baselines/reference/clodulesDerivedClasses.js index b4b31e59d3e..c37b9f0e96a 100644 --- a/tests/baselines/reference/clodulesDerivedClasses.js +++ b/tests/baselines/reference/clodulesDerivedClasses.js @@ -23,7 +23,7 @@ module Path.Utils { //// [clodulesDerivedClasses.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js index 92ddebd156c..a58f4aa9f94 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js @@ -40,7 +40,7 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInAccessors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js index 0d6f15cc374..b89a8753acd 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js @@ -25,7 +25,7 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js index 4e116deb802..efa9c1d9f03 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js @@ -29,7 +29,7 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js index 45a4c704b52..228b7243d4f 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js @@ -19,7 +19,7 @@ class b extends Foo { } //// [collisionSuperAndLocalFunctionInProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js index 5a8e54a6c3d..d2392f4df38 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js @@ -33,7 +33,7 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInAccessors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js index 2cd7549c78c..dc3210c1f8e 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js @@ -21,7 +21,7 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js index e7b374e5a61..7a6ee0c45c5 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js @@ -19,7 +19,7 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js index 55777f920a2..f678c7cf6ca 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js @@ -18,7 +18,7 @@ class b extends Foo { } //// [collisionSuperAndLocalVarInProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndNameResolution.js b/tests/baselines/reference/collisionSuperAndNameResolution.js index 763e151247e..540a2b659d9 100644 --- a/tests/baselines/reference/collisionSuperAndNameResolution.js +++ b/tests/baselines/reference/collisionSuperAndNameResolution.js @@ -12,7 +12,7 @@ class Foo extends base { } //// [collisionSuperAndNameResolution.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndParameter.js b/tests/baselines/reference/collisionSuperAndParameter.js index be9e0ce3f68..ac8947e00d3 100644 --- a/tests/baselines/reference/collisionSuperAndParameter.js +++ b/tests/baselines/reference/collisionSuperAndParameter.js @@ -63,7 +63,7 @@ class Foo4 extends Foo { } //// [collisionSuperAndParameter.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndParameter1.js b/tests/baselines/reference/collisionSuperAndParameter1.js index 11a4206624a..b072667396d 100644 --- a/tests/baselines/reference/collisionSuperAndParameter1.js +++ b/tests/baselines/reference/collisionSuperAndParameter1.js @@ -10,7 +10,7 @@ class Foo2 extends Foo { } //// [collisionSuperAndParameter1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js index fd523d010fb..e96ae7d8928 100644 --- a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js +++ b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js @@ -31,7 +31,7 @@ class b4 extends a { } //// [collisionSuperAndPropertyNameAsConstuctorParameter.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js index d502fc5c03a..dbf36111dfb 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js @@ -19,7 +19,7 @@ class b2 extends a { } //// [collisionThisExpressionAndLocalVarWithSuperExperssion.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/commentsInheritance.js b/tests/baselines/reference/commentsInheritance.js index 06cd5840d68..4fe5a30cb8b 100644 --- a/tests/baselines/reference/commentsInheritance.js +++ b/tests/baselines/reference/commentsInheritance.js @@ -152,7 +152,7 @@ i2_i = i3_i; //// [commentsInheritance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js index 4bdb1e38ba7..aebb486a1b5 100644 --- a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js @@ -195,7 +195,7 @@ var r8b6 = b5 !== a5; var r8b7 = b6 !== a6; //// [comparisonOperatorWithIdenticalObjects.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js index 10250785642..3d7e96be633 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js @@ -169,7 +169,7 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; //// [comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js index 6235eb4b4d9..097246f183b 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js @@ -169,7 +169,7 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; //// [comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js index 43ae21c3b03..6bb3cddc8a7 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js @@ -112,7 +112,7 @@ var r8b3 = b3 !== a3; var r8b4 = b4 !== a4; //// [comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js index 83adba638a6..dee8fb5ed5a 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js @@ -150,7 +150,7 @@ var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; //// [comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js index a5a52dccf83..bc7db12ebf2 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js @@ -150,7 +150,7 @@ var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; //// [comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js index 5a00fd85f3c..a35ece1b617 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js @@ -260,7 +260,7 @@ var r8b11 = b11 !== a11; //var r8b12 = b12 !== a12; //// [comparisonOperatorWithSubtypeObjectOnCallSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js index cba4f67933b..8ade79daa20 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js @@ -222,7 +222,7 @@ var r8b9 = b9 !== a9; //var r8b10 = b10 !== a10; //// [comparisonOperatorWithSubtypeObjectOnConstructorSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js index ec152ef0da5..080c7990c04 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js @@ -108,7 +108,7 @@ var r8b1 = b3 !== a3; var r8b1 = b4 !== a4; //// [comparisonOperatorWithSubtypeObjectOnIndexSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js index 1f2400f9bea..f01b18496d5 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js @@ -165,7 +165,7 @@ var r8b6 = b6 !== a6; //var r8b7 = b7 !== a7; //// [comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js index e80480e1a4e..bd4525e5c7b 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js @@ -165,7 +165,7 @@ var r8b6 = b6 !== a6; //var r8b7 = b7 !== a7; //// [comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js index 99c64617531..cbd31f56b30 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js @@ -79,7 +79,7 @@ var rh3 = b1 !== a1; var rh4 = b2 !== a2; //// [comparisonOperatorWithSubtypeObjectOnProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/complexClassRelationships.js b/tests/baselines/reference/complexClassRelationships.js index e8dc954e14c..2d750b77f71 100644 --- a/tests/baselines/reference/complexClassRelationships.js +++ b/tests/baselines/reference/complexClassRelationships.js @@ -48,7 +48,7 @@ class FooBase { } //// [complexClassRelationships.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js index 49171d4c87b..920172b206d 100644 --- a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js +++ b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js @@ -6,7 +6,7 @@ class S18 extends S18 //// [complicatedGenericRecursiveBaseClassReference.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.js b/tests/baselines/reference/compoundAssignmentLHSIsValue.js index d85d053f8eb..6e355e136e3 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.js @@ -123,7 +123,7 @@ foo() += value; (foo()) += value; //// [compoundAssignmentLHSIsValue.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.js b/tests/baselines/reference/computedPropertyNames24_ES5.js index 3fd4d41d0c2..e433383eb5c 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.js +++ b/tests/baselines/reference/computedPropertyNames24_ES5.js @@ -9,7 +9,7 @@ class C extends Base { } //// [computedPropertyNames24_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index b6a8d254b26..eca2485ab7d 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -14,7 +14,7 @@ class C extends Base { } //// [computedPropertyNames25_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 7a0a982eb41..0e3b6c126bc 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -11,7 +11,7 @@ class C extends Base { } //// [computedPropertyNames26_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames27_ES5.js b/tests/baselines/reference/computedPropertyNames27_ES5.js index df1fed09724..12f02fbefa9 100644 --- a/tests/baselines/reference/computedPropertyNames27_ES5.js +++ b/tests/baselines/reference/computedPropertyNames27_ES5.js @@ -6,7 +6,7 @@ class C extends Base { } //// [computedPropertyNames27_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index 5940c498db8..b2be5f120a5 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -11,7 +11,7 @@ class C extends Base { } //// [computedPropertyNames28_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index 05196e23c5b..6bbca3da056 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -16,7 +16,7 @@ class C extends Base { } //// [computedPropertyNames30_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index 173e3c7222b..fb7d651364b 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -16,7 +16,7 @@ class C extends Base { } //// [computedPropertyNames31_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.js b/tests/baselines/reference/computedPropertyNames43_ES5.js index b689f02ee98..e51df61a8c1 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.js +++ b/tests/baselines/reference/computedPropertyNames43_ES5.js @@ -13,7 +13,7 @@ class D extends C { } //// [computedPropertyNames43_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.js b/tests/baselines/reference/computedPropertyNames44_ES5.js index 32d3505e252..5efc5a11496 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.js +++ b/tests/baselines/reference/computedPropertyNames44_ES5.js @@ -12,7 +12,7 @@ class D extends C { } //// [computedPropertyNames44_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.js b/tests/baselines/reference/computedPropertyNames45_ES5.js index 3d924b00b73..d7fb6f35407 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.js +++ b/tests/baselines/reference/computedPropertyNames45_ES5.js @@ -13,7 +13,7 @@ class D extends C { } //// [computedPropertyNames45_ES5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js index 722310815ae..18c09a500a6 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js @@ -48,7 +48,7 @@ var result11: any = true ? 1 : 'string'; //// [conditionalOperatorWithIdenticalBCT.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js index 83262ed1301..62b887d7e60 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js @@ -24,7 +24,7 @@ var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.p //// [conditionalOperatorWithoutIdenticalBCT.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constEnum1.js b/tests/baselines/reference/constEnum1.js new file mode 100644 index 00000000000..d5ccede3ff1 --- /dev/null +++ b/tests/baselines/reference/constEnum1.js @@ -0,0 +1,34 @@ +//// [constEnum1.ts] + +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + +const enum E { + a = 10, + b = a, + c = (a+1), + e, + d = ~e, + f = a << 2 >> 1, + g = a << 2 >>> 1, + h = a | b +} + +//// [constEnum1.js] +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + + +//// [constEnum1.d.ts] +declare const enum E { + a = 10, + b = 10, + c = 11, + e = 12, + d = -13, + f = 20, + g = 20, + h = 10, +} diff --git a/tests/baselines/reference/constEnum1.symbols b/tests/baselines/reference/constEnum1.symbols new file mode 100644 index 00000000000..e94ed0a4722 --- /dev/null +++ b/tests/baselines/reference/constEnum1.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/constEnums/constEnum1.ts === + +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + +const enum E { +>E : Symbol(E, Decl(constEnum1.ts, 0, 0)) + + a = 10, +>a : Symbol(E.a, Decl(constEnum1.ts, 5, 14)) + + b = a, +>b : Symbol(E.b, Decl(constEnum1.ts, 6, 11)) +>a : Symbol(E.a, Decl(constEnum1.ts, 5, 14)) + + c = (a+1), +>c : Symbol(E.c, Decl(constEnum1.ts, 7, 10)) +>a : Symbol(E.a, Decl(constEnum1.ts, 5, 14)) + + e, +>e : Symbol(E.e, Decl(constEnum1.ts, 8, 14)) + + d = ~e, +>d : Symbol(E.d, Decl(constEnum1.ts, 9, 6)) +>e : Symbol(E.e, Decl(constEnum1.ts, 8, 14)) + + f = a << 2 >> 1, +>f : Symbol(E.f, Decl(constEnum1.ts, 10, 11)) +>a : Symbol(E.a, Decl(constEnum1.ts, 5, 14)) + + g = a << 2 >>> 1, +>g : Symbol(E.g, Decl(constEnum1.ts, 11, 20)) +>a : Symbol(E.a, Decl(constEnum1.ts, 5, 14)) + + h = a | b +>h : Symbol(E.h, Decl(constEnum1.ts, 12, 21)) +>a : Symbol(E.a, Decl(constEnum1.ts, 5, 14)) +>b : Symbol(E.b, Decl(constEnum1.ts, 6, 11)) +} diff --git a/tests/baselines/reference/constEnum1.types b/tests/baselines/reference/constEnum1.types new file mode 100644 index 00000000000..9ae95992847 --- /dev/null +++ b/tests/baselines/reference/constEnum1.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/constEnums/constEnum1.ts === + +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + +const enum E { +>E : E + + a = 10, +>a : E +>10 : number + + b = a, +>b : E +>a : E + + c = (a+1), +>c : E +>(a+1) : number +>a+1 : number +>a : E +>1 : number + + e, +>e : E + + d = ~e, +>d : E +>~e : number +>e : E + + f = a << 2 >> 1, +>f : E +>a << 2 >> 1 : number +>a << 2 : number +>a : E +>2 : number +>1 : number + + g = a << 2 >>> 1, +>g : E +>a << 2 >>> 1 : number +>a << 2 : number +>a : E +>2 : number +>1 : number + + h = a | b +>h : E +>a | b : number +>a : E +>b : E +} diff --git a/tests/baselines/reference/constEnum2.errors.txt b/tests/baselines/reference/constEnum2.errors.txt new file mode 100644 index 00000000000..f0cac0c2f5d --- /dev/null +++ b/tests/baselines/reference/constEnum2.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/constEnums/constEnum2.ts(11,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. +tests/cases/conformance/constEnums/constEnum2.ts(12,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. +tests/cases/conformance/constEnums/constEnum2.ts(13,5): error TS1005: ',' expected. +tests/cases/conformance/constEnums/constEnum2.ts(13,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. + + +==== tests/cases/conformance/constEnums/constEnum2.ts (4 errors) ==== + + // An enum declaration that specifies a const modifier is a constant enum declaration. + // In a constant enum declaration, all members must have constant values and + // it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + + // Error : not a constant enum expression + + const CONST = 9000 % 2; + const enum D { + d = 10, + e = 199 * Math.floor(Math.random() * 1000), + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2474: In 'const' enum declarations member initializer must be constant expression. + f = d - (100 * Math.floor(Math.random() % 8)) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2474: In 'const' enum declarations member initializer must be constant expression. + g = CONST, + ~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS2474: In 'const' enum declarations member initializer must be constant expression. + } \ No newline at end of file diff --git a/tests/baselines/reference/constEnum2.js b/tests/baselines/reference/constEnum2.js new file mode 100644 index 00000000000..c0c640b87fd --- /dev/null +++ b/tests/baselines/reference/constEnum2.js @@ -0,0 +1,32 @@ +//// [constEnum2.ts] + +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + +// Error : not a constant enum expression + +const CONST = 9000 % 2; +const enum D { + d = 10, + e = 199 * Math.floor(Math.random() * 1000), + f = d - (100 * Math.floor(Math.random() % 8)) + g = CONST, +} + +//// [constEnum2.js] +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. +// Error : not a constant enum expression +var CONST = 9000 % 2; + + +//// [constEnum2.d.ts] +declare const CONST: number; +declare const enum D { + d = 10, + e, + f, + g, +} diff --git a/tests/baselines/reference/constEnumPropertyAccess1.js b/tests/baselines/reference/constEnumPropertyAccess1.js new file mode 100644 index 00000000000..114f1e1928e --- /dev/null +++ b/tests/baselines/reference/constEnumPropertyAccess1.js @@ -0,0 +1,67 @@ +//// [constEnumPropertyAccess1.ts] + +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members + +const enum G { + A = 1, + B = 2, + C = A + B, + D = A * 2 +} + +var o: { + [idx: number]: boolean +} = { + 1: true + }; + +var a = G.A; +var a1 = G["A"]; +var g = o[G.A]; + +class C { + [G.A]() { } + get [G.B]() { + return true; + } + set [G.B](x: number) { } +} + + + +//// [constEnumPropertyAccess1.js] +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members +var o = { + 1: true +}; +var a = 1 /* A */; +var a1 = 1 /* "A" */; +var g = o[1 /* A */]; +class C { + [1 /* A */]() { } + get [2 /* B */]() { + return true; + } + set [2 /* B */](x) { } +} + + +//// [constEnumPropertyAccess1.d.ts] +declare const enum G { + A = 1, + B = 2, + C = 3, + D = 2, +} +declare var o: { + [idx: number]: boolean; +}; +declare var a: G; +declare var a1: G; +declare var g: boolean; +declare class C { +} diff --git a/tests/baselines/reference/constEnumPropertyAccess1.symbols b/tests/baselines/reference/constEnumPropertyAccess1.symbols new file mode 100644 index 00000000000..e5f2853f157 --- /dev/null +++ b/tests/baselines/reference/constEnumPropertyAccess1.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts === + +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members + +const enum G { +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) + + A = 1, +>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) + + B = 2, +>B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 6, 10)) + + C = A + B, +>C : Symbol(G.C, Decl(constEnumPropertyAccess1.ts, 7, 10)) +>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) +>B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 6, 10)) + + D = A * 2 +>D : Symbol(G.D, Decl(constEnumPropertyAccess1.ts, 8, 14)) +>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) +} + +var o: { +>o : Symbol(o, Decl(constEnumPropertyAccess1.ts, 12, 3)) + + [idx: number]: boolean +>idx : Symbol(idx, Decl(constEnumPropertyAccess1.ts, 13, 5)) + +} = { + 1: true + }; + +var a = G.A; +>a : Symbol(a, Decl(constEnumPropertyAccess1.ts, 18, 3)) +>G.A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) +>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) + +var a1 = G["A"]; +>a1 : Symbol(a1, Decl(constEnumPropertyAccess1.ts, 19, 3)) +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) +>"A" : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) + +var g = o[G.A]; +>g : Symbol(g, Decl(constEnumPropertyAccess1.ts, 20, 3)) +>o : Symbol(o, Decl(constEnumPropertyAccess1.ts, 12, 3)) +>G.A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) +>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) + +class C { +>C : Symbol(C, Decl(constEnumPropertyAccess1.ts, 20, 15)) + + [G.A]() { } +>G.A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) +>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 5, 14)) + + get [G.B]() { +>G.B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 6, 10)) +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) +>B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 6, 10)) + + return true; + } + set [G.B](x: number) { } +>G.B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 6, 10)) +>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0)) +>B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 6, 10)) +>x : Symbol(x, Decl(constEnumPropertyAccess1.ts, 27, 14)) +} + + diff --git a/tests/baselines/reference/constEnumPropertyAccess1.types b/tests/baselines/reference/constEnumPropertyAccess1.types new file mode 100644 index 00000000000..5ed2b932bd0 --- /dev/null +++ b/tests/baselines/reference/constEnumPropertyAccess1.types @@ -0,0 +1,88 @@ +=== tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts === + +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members + +const enum G { +>G : G + + A = 1, +>A : G +>1 : number + + B = 2, +>B : G +>2 : number + + C = A + B, +>C : G +>A + B : number +>A : G +>B : G + + D = A * 2 +>D : G +>A * 2 : number +>A : G +>2 : number +} + +var o: { +>o : { [idx: number]: boolean; } + + [idx: number]: boolean +>idx : number + +} = { +>{ 1: true } : { [x: number]: boolean; 1: boolean; } + + 1: true +>true : boolean + + }; + +var a = G.A; +>a : G +>G.A : G +>G : typeof G +>A : G + +var a1 = G["A"]; +>a1 : G +>G["A"] : G +>G : typeof G +>"A" : string + +var g = o[G.A]; +>g : boolean +>o[G.A] : boolean +>o : { [idx: number]: boolean; } +>G.A : G +>G : typeof G +>A : G + +class C { +>C : C + + [G.A]() { } +>G.A : G +>G : typeof G +>A : G + + get [G.B]() { +>G.B : G +>G : typeof G +>B : G + + return true; +>true : boolean + } + set [G.B](x: number) { } +>G.B : G +>G : typeof G +>B : G +>x : number +} + + diff --git a/tests/baselines/reference/constEnumPropertyAccess2.errors.txt b/tests/baselines/reference/constEnumPropertyAccess2.errors.txt new file mode 100644 index 00000000000..19b273faffa --- /dev/null +++ b/tests/baselines/reference/constEnumPropertyAccess2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(14,9): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. +tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(15,12): error TS2476: A const enum member can only be accessed using a string literal. +tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(17,1): error TS2322: Type 'string' is not assignable to type 'G'. +tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS2364: Invalid left-hand side of assignment expression. + + +==== tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts (4 errors) ==== + + // constant enum declarations are completely erased in the emitted JavaScript code. + // it is an error to reference a constant enum object in any other context + // than a property access that selects one of the enum's members + + const enum G { + A = 1, + B = 2, + C = A + B, + D = A * 2 + } + + // Error from referring constant enum in any other context than a property access + var z = G; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. + var z1 = G[G.A]; + ~~~ +!!! error TS2476: A const enum member can only be accessed using a string literal. + var g: G; + g = "string"; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'G'. + function foo(x: G) { } + G.B = 3; + ~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + \ No newline at end of file diff --git a/tests/baselines/reference/constEnumPropertyAccess2.js b/tests/baselines/reference/constEnumPropertyAccess2.js new file mode 100644 index 00000000000..46a1d918b94 --- /dev/null +++ b/tests/baselines/reference/constEnumPropertyAccess2.js @@ -0,0 +1,46 @@ +//// [constEnumPropertyAccess2.ts] + +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members + +const enum G { + A = 1, + B = 2, + C = A + B, + D = A * 2 +} + +// Error from referring constant enum in any other context than a property access +var z = G; +var z1 = G[G.A]; +var g: G; +g = "string"; +function foo(x: G) { } +G.B = 3; + + +//// [constEnumPropertyAccess2.js] +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members +// Error from referring constant enum in any other context than a property access +var z = G; +var z1 = G[1 /* A */]; +var g; +g = "string"; +function foo(x) { } +2 /* B */ = 3; + + +//// [constEnumPropertyAccess2.d.ts] +declare const enum G { + A = 1, + B = 2, + C = 3, + D = 2, +} +declare var z: typeof G; +declare var z1: any; +declare var g: G; +declare function foo(x: G): void; diff --git a/tests/baselines/reference/constantOverloadFunction.js b/tests/baselines/reference/constantOverloadFunction.js index 408b56805fb..aa89c619e7e 100644 --- a/tests/baselines/reference/constantOverloadFunction.js +++ b/tests/baselines/reference/constantOverloadFunction.js @@ -14,7 +14,7 @@ function foo(tagName: any): Base { //// [constantOverloadFunction.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js index 591d6171dbe..529f888bfc9 100644 --- a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js +++ b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js @@ -15,7 +15,7 @@ function foo(tagName: any): Base { //// [constantOverloadFunctionNoSubtypeError.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js index caeb2d32ee4..22b77ba6816 100644 --- a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js +++ b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js @@ -20,7 +20,7 @@ class Container { } //// [constraintCheckInGenericBaseTypeReference.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index 3cc7bddd1d0..c1c10ead1e3 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -71,7 +71,7 @@ interface I extends A { //// [constructSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js index f9f8ca0c089..12907c6d032 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js @@ -114,7 +114,7 @@ module Errors { //// [constructSignatureAssignabilityInInheritance3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js index 4119b87ba97..ef03802a17e 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js @@ -61,7 +61,7 @@ interface I extends A { //// [constructSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index a33d2a03b26..9964a3464a1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -51,7 +51,7 @@ interface I extends B { //// [constructSignatureAssignabilityInInheritance5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js index f94845e82bf..4cf9b7d71f5 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js @@ -54,7 +54,7 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorArgs.js b/tests/baselines/reference/constructorArgs.js index e77c6ed8e0f..93a47178d52 100644 --- a/tests/baselines/reference/constructorArgs.js +++ b/tests/baselines/reference/constructorArgs.js @@ -16,7 +16,7 @@ class Sub extends Super { //// [constructorArgs.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js index 7262e5b7e0d..9c92f31ce97 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js @@ -20,7 +20,7 @@ class Derived2 extends Base { } //// [constructorFunctionTypeIsAssignableToBaseType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js index 79094a38b1d..61cf399f613 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js @@ -34,7 +34,7 @@ class Derived2 extends Base { //// [constructorFunctionTypeIsAssignableToBaseType2.js] // the constructor function itself does not need to be a subtype of the base type constructor function -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorHasPrototypeProperty.js b/tests/baselines/reference/constructorHasPrototypeProperty.js index 951593e9353..47020120f9f 100644 --- a/tests/baselines/reference/constructorHasPrototypeProperty.js +++ b/tests/baselines/reference/constructorHasPrototypeProperty.js @@ -32,7 +32,7 @@ module Generic { } //// [constructorHasPrototypeProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorOverloads2.js b/tests/baselines/reference/constructorOverloads2.js index e3eae0ed5a9..16da3f0fa0a 100644 --- a/tests/baselines/reference/constructorOverloads2.js +++ b/tests/baselines/reference/constructorOverloads2.js @@ -26,7 +26,7 @@ f1.bar1(); //// [constructorOverloads2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorOverloads3.js b/tests/baselines/reference/constructorOverloads3.js index c54226745c2..f4299466aa1 100644 --- a/tests/baselines/reference/constructorOverloads3.js +++ b/tests/baselines/reference/constructorOverloads3.js @@ -23,7 +23,7 @@ f1.bar1(); //// [constructorOverloads3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 5d607c8f5b2..2818793948f 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2304: Cannot find name 'module'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2503: Cannot find namespace 'module'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,19): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,35): error TS1005: ')' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,39): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -82,7 +83,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (82 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (83 errors) ==== declare module "fs" { export class File { constructor(filename: string); @@ -96,6 +97,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS import fs = module("fs"); ~~~~~~ !!! error TS2304: Cannot find name 'module'. + ~~~~~~ +!!! error TS2503: Cannot find namespace 'module'. ~ !!! error TS1005: ';' expected. diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index b44d7faa5a6..01a1880ffd5 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -280,7 +280,7 @@ TypeScriptAllInOne.Program.Main(); //// [constructorWithIncompleteTypeAnnotation.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.js b/tests/baselines/reference/contextualTypingArrayOfLambdas.js index 844a50428e2..e24ae90176c 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.js +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.js @@ -15,7 +15,7 @@ var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; //// [contextualTypingArrayOfLambdas.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression.js b/tests/baselines/reference/contextualTypingOfConditionalExpression.js index b1100ba80a9..72c15455e8e 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression.js @@ -15,7 +15,7 @@ var x2: (a: A) => void = true ? (a) => a.foo : (b) => b.foo; //// [contextualTypingOfConditionalExpression.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js index f832d2766ee..4e6b95a6857 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js @@ -13,7 +13,7 @@ var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { }; //// [contextualTypingOfConditionalExpression2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js index 8928e45694c..17c9ac649d8 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js @@ -11,7 +11,7 @@ var a: D = foo("hi", []); //// [crashInsourcePropertyIsRelatableToTargetProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js index c19ab9a3fb1..134bacd6053 100644 --- a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js +++ b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js @@ -10,7 +10,7 @@ interface I extends X<() => number> { //// [declFileForFunctionTypeAsTypeParameter.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js index dfeb6f5d3c3..23630ba5218 100644 --- a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js +++ b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js @@ -13,7 +13,7 @@ class Baz implements IBar { //// [declFileGenericClassWithGenericExtendedClass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declFileGenericType.js b/tests/baselines/reference/declFileGenericType.js index e01626a7ead..35fde5bde00 100644 --- a/tests/baselines/reference/declFileGenericType.js +++ b/tests/baselines/reference/declFileGenericType.js @@ -40,7 +40,7 @@ export var j = C.F6; //// [declFileGenericType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declFileGenericType2.js b/tests/baselines/reference/declFileGenericType2.js index db1399e64d3..03649af4ba6 100644 --- a/tests/baselines/reference/declFileGenericType2.js +++ b/tests/baselines/reference/declFileGenericType2.js @@ -43,7 +43,7 @@ module templa.dom.mvc.composite { //// [declFileGenericType2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js index 7da7dd8716a..8881122839e 100644 --- a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js +++ b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js @@ -21,7 +21,7 @@ module X.Y.base.Z { //// [declFileWithClassNameConflictingWithClassReferredByExtendsClause.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js index 5f6509cb597..c06461e89fc 100644 --- a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js +++ b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js @@ -19,7 +19,7 @@ module A.B.C { } //// [declFileWithExtendsClauseThatHasItsContainerNameConflict.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declarationEmitDestructuring2.errors.txt b/tests/baselines/reference/declarationEmitDestructuring2.errors.txt new file mode 100644 index 00000000000..4e8561e83ad --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuring2.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/declarationEmitDestructuring2.ts(3,13): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/declarationEmitDestructuring2.ts(3,17): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/declarationEmitDestructuring2.ts(3,23): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/declarationEmitDestructuring2.ts(3,41): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/declarationEmitDestructuring2.ts(3,44): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/declarationEmitDestructuring2.ts(3,47): error TS2300: Duplicate identifier 'c'. + + +==== tests/cases/compiler/declarationEmitDestructuring2.ts (6 errors) ==== + function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { } + function g([a, b, c, d] = [1, 2, 3, 4]) { } + function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ } + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + ~ +!!! error TS2300: Duplicate identifier 'c'. + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + ~ +!!! error TS2300: Duplicate identifier 'c'. + function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuring2.symbols b/tests/baselines/reference/declarationEmitDestructuring2.symbols deleted file mode 100644 index 9cf35c1d866..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuring2.symbols +++ /dev/null @@ -1,40 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuring2.ts === -function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { } ->f : Symbol(f, Decl(declarationEmitDestructuring2.ts, 0, 0)) ->x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 0, 12)) ->a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 0, 24)) ->b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 0, 26)) ->c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 0, 29)) ->d : Symbol(d, Decl(declarationEmitDestructuring2.ts, 0, 32)) ->x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 0, 55)) ->y : Symbol(y, Decl(declarationEmitDestructuring2.ts, 0, 62)) - -function g([a, b, c, d] = [1, 2, 3, 4]) { } ->g : Symbol(g, Decl(declarationEmitDestructuring2.ts, 0, 85)) ->a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 1, 12)) ->b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 1, 14)) ->c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 1, 17)) ->d : Symbol(d, Decl(declarationEmitDestructuring2.ts, 1, 20)) - -function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ } ->h : Symbol(h, Decl(declarationEmitDestructuring2.ts, 1, 43)) ->a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 2, 12), Decl(declarationEmitDestructuring2.ts, 2, 40)) ->b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 2, 16), Decl(declarationEmitDestructuring2.ts, 2, 42)) ->c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 2, 22), Decl(declarationEmitDestructuring2.ts, 2, 45)) ->x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 2, 28)) ->a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 2, 12), Decl(declarationEmitDestructuring2.ts, 2, 40)) ->b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 2, 16), Decl(declarationEmitDestructuring2.ts, 2, 42)) ->c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 2, 22), Decl(declarationEmitDestructuring2.ts, 2, 45)) ->a1 : Symbol(a1, Decl(declarationEmitDestructuring2.ts, 2, 54)) ->b1 : Symbol(b1, Decl(declarationEmitDestructuring2.ts, 2, 57)) - -function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ } ->h1 : Symbol(h1, Decl(declarationEmitDestructuring2.ts, 2, 67)) ->a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 3, 13)) ->b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 3, 17)) ->c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 3, 23)) ->x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 3, 29)) ->y : Symbol(y, Decl(declarationEmitDestructuring2.ts, 3, 36)) ->a1 : Symbol(a1, Decl(declarationEmitDestructuring2.ts, 3, 56)) ->b1 : Symbol(b1, Decl(declarationEmitDestructuring2.ts, 3, 59)) - diff --git a/tests/baselines/reference/declarationEmitDestructuring2.types b/tests/baselines/reference/declarationEmitDestructuring2.types deleted file mode 100644 index 619ad13d084..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuring2.types +++ /dev/null @@ -1,68 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuring2.ts === -function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { } ->f : ({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]}?: { x: number; y: [number, number, number, number]; }) => void ->x : number ->10 : number ->y : any ->a : number ->b : number ->c : number ->d : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number ->{ x: 10, y: [2, 4, 6, 8] } : { x: number; y: [number, number, number, number]; } ->x : number ->10 : number ->y : [number, number, number, number] ->[2, 4, 6, 8] : [number, number, number, number] ->2 : number ->4 : number ->6 : number ->8 : number - -function g([a, b, c, d] = [1, 2, 3, 4]) { } ->g : ([a, b, c, d]?: [number, number, number, number]) => void ->a : number ->b : number ->c : number ->d : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ } ->h : ([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]: [any, [any], [[any]], { x?: number; y: [any, any, any]; z: { a1: any; b1: any; }; }]) => void ->a : any ->b : any ->c : any ->x : number ->10 : number ->y : any ->a : any ->b : any ->c : any ->z : any ->a1 : any ->b1 : any - -function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ } ->h1 : ([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]: [any, [any], [[any]], { x?: number; y?: number[]; z: { a1: any; b1: any; }; }]) => void ->a : any ->b : any ->c : any ->x : number ->10 : number ->y : number[] ->[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number ->z : any ->a1 : any ->b1 : any - diff --git a/tests/baselines/reference/declarationEmit_nameConflicts3.js b/tests/baselines/reference/declarationEmit_nameConflicts3.js index 0d68c38cfda..8f4fa686e44 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts3.js +++ b/tests/baselines/reference/declarationEmit_nameConflicts3.js @@ -27,7 +27,7 @@ module M.P { } //// [declarationEmit_nameConflicts3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.js b/tests/baselines/reference/declarationEmit_protectedMembers.js index 61a4ebdfcab..faa1dc298e1 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.js +++ b/tests/baselines/reference/declarationEmit_protectedMembers.js @@ -51,7 +51,7 @@ class C4 { } //// [declarationEmit_protectedMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declareDottedExtend.js b/tests/baselines/reference/declareDottedExtend.js index 974a678abda..2579a5557fc 100644 --- a/tests/baselines/reference/declareDottedExtend.js +++ b/tests/baselines/reference/declareDottedExtend.js @@ -12,7 +12,7 @@ class E extends A.B.C{ } //// [declareDottedExtend.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/declareModifierOnImport1.errors.txt b/tests/baselines/reference/declareModifierOnImport1.errors.txt index 776f2c07bcb..7260a8e48f3 100644 --- a/tests/baselines/reference/declareModifierOnImport1.errors.txt +++ b/tests/baselines/reference/declareModifierOnImport1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/declareModifierOnImport1.ts(1,1): error TS1079: A 'declare' modifier cannot be used with an import declaration. -tests/cases/compiler/declareModifierOnImport1.ts(1,20): error TS2304: Cannot find name 'b'. +tests/cases/compiler/declareModifierOnImport1.ts(1,20): error TS2503: Cannot find namespace 'b'. ==== tests/cases/compiler/declareModifierOnImport1.ts (2 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/declareModifierOnImport1.ts(1,20): error TS2304: Cannot fin ~~~~~~~ !!! error TS1079: A 'declare' modifier cannot be used with an import declaration. ~ -!!! error TS2304: Cannot find name 'b'. \ No newline at end of file +!!! error TS2503: Cannot find namespace 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.js b/tests/baselines/reference/decoratedClassFromExternalModule.js index da31e7c2f92..163a4a094b4 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.js +++ b/tests/baselines/reference/decoratedClassFromExternalModule.js @@ -10,7 +10,7 @@ export default class Decorated { } import Decorated from 'decorated'; //// [decorated.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -21,7 +21,6 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target, function decorate() { } let Decorated = class { }; -Object.defineProperty(Decorated, "name", { value: "Decorated", configurable: true }); Decorated = __decorate([ decorate ], Decorated); diff --git a/tests/baselines/reference/decoratorOnClass1.js b/tests/baselines/reference/decoratorOnClass1.js index 49b2b27ac8b..b8099222acc 100644 --- a/tests/baselines/reference/decoratorOnClass1.js +++ b/tests/baselines/reference/decoratorOnClass1.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClass1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index 71ac2358555..18492794331 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -6,7 +6,7 @@ export class C { } //// [decoratorOnClass2.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js index 37da7043615..2291a2dbc57 100644 --- a/tests/baselines/reference/decoratorOnClass3.js +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -7,7 +7,7 @@ class C { } //// [decoratorOnClass3.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClass4.js b/tests/baselines/reference/decoratorOnClass4.js index e56e427b797..484efdf6128 100644 --- a/tests/baselines/reference/decoratorOnClass4.js +++ b/tests/baselines/reference/decoratorOnClass4.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClass4.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClass5.js b/tests/baselines/reference/decoratorOnClass5.js index b415fcf8f9a..02ea01c3fd6 100644 --- a/tests/baselines/reference/decoratorOnClass5.js +++ b/tests/baselines/reference/decoratorOnClass5.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClass5.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClass8.js b/tests/baselines/reference/decoratorOnClass8.js index 500cdcf4511..e75ccac3c86 100644 --- a/tests/baselines/reference/decoratorOnClass8.js +++ b/tests/baselines/reference/decoratorOnClass8.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClass8.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.js b/tests/baselines/reference/decoratorOnClassAccessor1.js index 2e0f3520b43..2700c531e42 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.js +++ b/tests/baselines/reference/decoratorOnClassAccessor1.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassAccessor1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.js b/tests/baselines/reference/decoratorOnClassAccessor2.js index a339c3b1663..c29c7598013 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.js +++ b/tests/baselines/reference/decoratorOnClassAccessor2.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassAccessor2.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.js b/tests/baselines/reference/decoratorOnClassAccessor3.js index 843a1113255..61430a986ac 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.js +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassAccessor3.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.js b/tests/baselines/reference/decoratorOnClassAccessor4.js index 416472ba5ff..0ad11c4c09e 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor4.js +++ b/tests/baselines/reference/decoratorOnClassAccessor4.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassAccessor4.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.js b/tests/baselines/reference/decoratorOnClassAccessor5.js index ba4e20955e9..53a43f7912c 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor5.js +++ b/tests/baselines/reference/decoratorOnClassAccessor5.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassAccessor5.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.js b/tests/baselines/reference/decoratorOnClassAccessor6.js index 05f0651e1e5..eaa21f45234 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.js +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassAccessor6.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js index aa477bcdaef..b2af1450123 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassConstructorParameter1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -14,7 +14,7 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target, case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -if (typeof __param !== "function") __param = function (paramIndex, decorator) { +var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var C = (function () { diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js index 7b7f418ed02..5273482586e 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassConstructorParameter4.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -14,7 +14,7 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target, case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -if (typeof __param !== "function") __param = function (paramIndex, decorator) { +var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var C = (function () { diff --git a/tests/baselines/reference/decoratorOnClassMethod1.js b/tests/baselines/reference/decoratorOnClassMethod1.js index c2f64cb0639..65c2f4b6008 100644 --- a/tests/baselines/reference/decoratorOnClassMethod1.js +++ b/tests/baselines/reference/decoratorOnClassMethod1.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod10.js b/tests/baselines/reference/decoratorOnClassMethod10.js index ad934eb6d08..bae4e97fb5b 100644 --- a/tests/baselines/reference/decoratorOnClassMethod10.js +++ b/tests/baselines/reference/decoratorOnClassMethod10.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod10.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod11.js b/tests/baselines/reference/decoratorOnClassMethod11.js index b55cdf81b24..5d4ac60c14e 100644 --- a/tests/baselines/reference/decoratorOnClassMethod11.js +++ b/tests/baselines/reference/decoratorOnClassMethod11.js @@ -9,7 +9,7 @@ module M { } //// [decoratorOnClassMethod11.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 4c2c19bd6a5..aa938eaaaf4 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -10,13 +10,13 @@ module M { } //// [decoratorOnClassMethod12.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; d.prototype = new __(); }; -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod13.js b/tests/baselines/reference/decoratorOnClassMethod13.js index be6d7449ee4..967cc05ba4d 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.js +++ b/tests/baselines/reference/decoratorOnClassMethod13.js @@ -7,7 +7,7 @@ class C { } //// [decoratorOnClassMethod13.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod2.js b/tests/baselines/reference/decoratorOnClassMethod2.js index 7500cebc12d..8b4ceeb47ee 100644 --- a/tests/baselines/reference/decoratorOnClassMethod2.js +++ b/tests/baselines/reference/decoratorOnClassMethod2.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod2.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod3.js b/tests/baselines/reference/decoratorOnClassMethod3.js index 54b2ae20d87..fff0e845860 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.js +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod3.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod4.js b/tests/baselines/reference/decoratorOnClassMethod4.js index 7ce4596fc17..9f5b0d67eb1 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.js +++ b/tests/baselines/reference/decoratorOnClassMethod4.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod4.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod5.js b/tests/baselines/reference/decoratorOnClassMethod5.js index 9f768816b47..f767b176207 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.js +++ b/tests/baselines/reference/decoratorOnClassMethod5.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod5.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod6.js b/tests/baselines/reference/decoratorOnClassMethod6.js index 064992b1c7a..33dc4c86fd2 100644 --- a/tests/baselines/reference/decoratorOnClassMethod6.js +++ b/tests/baselines/reference/decoratorOnClassMethod6.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod6.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod7.js b/tests/baselines/reference/decoratorOnClassMethod7.js index 8635fe25b6a..c20a726fc46 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.js +++ b/tests/baselines/reference/decoratorOnClassMethod7.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod7.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethod8.js b/tests/baselines/reference/decoratorOnClassMethod8.js index e63de6d4db3..a664bdb8494 100644 --- a/tests/baselines/reference/decoratorOnClassMethod8.js +++ b/tests/baselines/reference/decoratorOnClassMethod8.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethod8.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js index a81cdaa19c8..4a3ed36eec5 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.js +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassMethodParameter1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -14,7 +14,7 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target, case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -if (typeof __param !== "function") __param = function (paramIndex, decorator) { +var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var C = (function () { diff --git a/tests/baselines/reference/decoratorOnClassProperty1.js b/tests/baselines/reference/decoratorOnClassProperty1.js index 23e5eec1cc0..567eb510cb3 100644 --- a/tests/baselines/reference/decoratorOnClassProperty1.js +++ b/tests/baselines/reference/decoratorOnClassProperty1.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty1.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassProperty10.js b/tests/baselines/reference/decoratorOnClassProperty10.js index b3848e73d57..b64986a8c97 100644 --- a/tests/baselines/reference/decoratorOnClassProperty10.js +++ b/tests/baselines/reference/decoratorOnClassProperty10.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty10.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassProperty11.js b/tests/baselines/reference/decoratorOnClassProperty11.js index 72ad6f276de..a33fc724180 100644 --- a/tests/baselines/reference/decoratorOnClassProperty11.js +++ b/tests/baselines/reference/decoratorOnClassProperty11.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty11.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassProperty2.js b/tests/baselines/reference/decoratorOnClassProperty2.js index 72fb1bcb331..f5de593b057 100644 --- a/tests/baselines/reference/decoratorOnClassProperty2.js +++ b/tests/baselines/reference/decoratorOnClassProperty2.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty2.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassProperty3.js b/tests/baselines/reference/decoratorOnClassProperty3.js index af72503b914..d2876d2cd6a 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.js +++ b/tests/baselines/reference/decoratorOnClassProperty3.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty3.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassProperty6.js b/tests/baselines/reference/decoratorOnClassProperty6.js index a8621e253e8..4ebd19ceee8 100644 --- a/tests/baselines/reference/decoratorOnClassProperty6.js +++ b/tests/baselines/reference/decoratorOnClassProperty6.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty6.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/decoratorOnClassProperty7.js b/tests/baselines/reference/decoratorOnClassProperty7.js index 6c7b3292235..045f8722b97 100644 --- a/tests/baselines/reference/decoratorOnClassProperty7.js +++ b/tests/baselines/reference/decoratorOnClassProperty7.js @@ -6,7 +6,7 @@ class C { } //// [decoratorOnClassProperty7.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js index 32e8cf4199e..37dc2db870b 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js @@ -34,7 +34,7 @@ class Derived4 extends Base2 { //// [derivedClassConstructorWithoutSuperCall.js] // derived class constructors must contain a super call -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js index 615c3e7f7a6..eaf7dfd5698 100644 --- a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js +++ b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js @@ -15,7 +15,7 @@ class Derived extends Base { } //// [derivedClassFunctionOverridesBaseClassAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js index f2e816604d2..b83255ccf93 100644 --- a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js +++ b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js @@ -41,7 +41,7 @@ var r8 = d2[1]; //// [derivedClassIncludesInheritedMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js index a942e1ee237..1fe59d78044 100644 --- a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js +++ b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js @@ -18,7 +18,7 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesIndexersWithAssignmentCompatibility.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js index c1519f7695c..b9cd6df0338 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js +++ b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js @@ -16,7 +16,7 @@ class DerivedClass extends BaseClass { new DerivedClass(); //// [derivedClassOverridesPrivateFunction1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesPrivates.js b/tests/baselines/reference/derivedClassOverridesPrivates.js index f6a704e076a..2cc8360a803 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivates.js +++ b/tests/baselines/reference/derivedClassOverridesPrivates.js @@ -16,7 +16,7 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesPrivates.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js index b66d356a73e..48ee6eded6c 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js @@ -37,7 +37,7 @@ class Derived extends Base { //// [derivedClassOverridesProtectedMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js index 80f7456ab9a..fca27b0de04 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js @@ -64,7 +64,7 @@ var r8 = d2[1]; //// [derivedClassOverridesProtectedMembers2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js index cfb6116ee85..2a102d55eac 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js @@ -72,7 +72,7 @@ class Derived10 extends Base { } //// [derivedClassOverridesProtectedMembers3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js index e1d5b766b82..5145f3919a8 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js @@ -15,7 +15,7 @@ class Derived2 extends Derived1 { } //// [derivedClassOverridesProtectedMembers4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.js b/tests/baselines/reference/derivedClassOverridesPublicMembers.js index 9d7df0eee40..0529189e4c1 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.js +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.js @@ -63,7 +63,7 @@ var r8 = d2[1]; //// [derivedClassOverridesPublicMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js index 7a18c0d71a5..5cb746bfdd3 100644 --- a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js @@ -24,7 +24,7 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesWithoutSubtype.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassParameterProperties.js b/tests/baselines/reference/derivedClassParameterProperties.js index 0ad14313c17..dd5b206ecdd 100644 --- a/tests/baselines/reference/derivedClassParameterProperties.js +++ b/tests/baselines/reference/derivedClassParameterProperties.js @@ -96,7 +96,7 @@ class Derived10 extends Base2 { //// [derivedClassParameterProperties.js] // ordering of super calls in derived constructors matters depending on other class contents -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index 14ac1f47e2f..d2914cd6949 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -33,7 +33,7 @@ class Derived extends Base { //// [derivedClassSuperCallsInNonConstructorMembers.js] // error to use super calls outside a constructor -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js index 1902b6f4068..7c7e9b40cec 100644 --- a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js +++ b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js @@ -29,7 +29,7 @@ class Derived4 extends Base { } //// [derivedClassSuperCallsWithThisArg.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassTransitivity.js b/tests/baselines/reference/derivedClassTransitivity.js index 2088fc1122b..ad4f3e481a7 100644 --- a/tests/baselines/reference/derivedClassTransitivity.js +++ b/tests/baselines/reference/derivedClassTransitivity.js @@ -22,7 +22,7 @@ var r2 = e.foo(''); //// [derivedClassTransitivity.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassTransitivity2.js b/tests/baselines/reference/derivedClassTransitivity2.js index 458aede164c..efeb25195ff 100644 --- a/tests/baselines/reference/derivedClassTransitivity2.js +++ b/tests/baselines/reference/derivedClassTransitivity2.js @@ -22,7 +22,7 @@ var r2 = e.foo(1, ''); //// [derivedClassTransitivity2.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassTransitivity3.js b/tests/baselines/reference/derivedClassTransitivity3.js index 9768a8f5fa3..8befbf18731 100644 --- a/tests/baselines/reference/derivedClassTransitivity3.js +++ b/tests/baselines/reference/derivedClassTransitivity3.js @@ -22,7 +22,7 @@ var r2 = e.foo('', 1); //// [derivedClassTransitivity3.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassTransitivity4.js b/tests/baselines/reference/derivedClassTransitivity4.js index abf1a3b5bd0..546c7e4a849 100644 --- a/tests/baselines/reference/derivedClassTransitivity4.js +++ b/tests/baselines/reference/derivedClassTransitivity4.js @@ -22,7 +22,7 @@ var r2 = e.foo(''); //// [derivedClassTransitivity4.js] // subclassing is not transitive when you can remove required parameters and add optional parameters on protected members -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithAny.js b/tests/baselines/reference/derivedClassWithAny.js index 8070e689bd0..6f9ef484627 100644 --- a/tests/baselines/reference/derivedClassWithAny.js +++ b/tests/baselines/reference/derivedClassWithAny.js @@ -60,7 +60,7 @@ var r = c.foo(); // e.foo would return string //// [derivedClassWithAny.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js index 8b00c632058..bf8b1b51cd1 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js @@ -23,7 +23,7 @@ class Derived extends Base { //// [derivedClassWithPrivateInstanceShadowingProtectedInstance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js index 4ac57d159e6..131c529f3bf 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js @@ -33,7 +33,7 @@ var r6 = Derived.a; // error Derived.a = 2; // error //// [derivedClassWithPrivateInstanceShadowingPublicInstance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js index 1037d3faaae..d661eeadc06 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js @@ -22,7 +22,7 @@ class Derived extends Base { } //// [derivedClassWithPrivateStaticShadowingProtectedStatic.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js index c5bfea288bd..c3fc34b21c1 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js @@ -34,7 +34,7 @@ var r6 = Derived.a; // error Derived.a = 2; // error //// [derivedClassWithPrivateStaticShadowingPublicStatic.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js index 350e36b9bf7..16b9b110a5f 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js @@ -26,7 +26,7 @@ var d = new D(); // error var d2 = new D(new Date()); // ok //// [derivedClassWithoutExplicitConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js index b0f10960578..6e413752f1d 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js @@ -34,7 +34,7 @@ var d3 = new D(new Date(), new Date()); var d4 = new D(new Date(), new Date(), new Date()); //// [derivedClassWithoutExplicitConstructor2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js index 618750d3321..b72fdb1503d 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js @@ -48,7 +48,7 @@ var d3 = new D2(new Date(), new Date()); // ok //// [derivedClassWithoutExplicitConstructor3.js] // automatic constructors with a class hieararchy of depth > 2 -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedClasses.js b/tests/baselines/reference/derivedClasses.js index e256313d27b..7221031cb8b 100644 --- a/tests/baselines/reference/derivedClasses.js +++ b/tests/baselines/reference/derivedClasses.js @@ -31,7 +31,7 @@ b.hue(); //// [derivedClasses.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedGenericClassWithAny.js b/tests/baselines/reference/derivedGenericClassWithAny.js index 4d1f0452be4..b5bfbd5e5db 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.js +++ b/tests/baselines/reference/derivedGenericClassWithAny.js @@ -43,7 +43,7 @@ c = e; var r = c.foo(); // e.foo would return string //// [derivedGenericClassWithAny.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js index 39e87b620d6..564a51f2b13 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js @@ -18,7 +18,7 @@ class Derived extends Base { } //// [derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js index 50c8aba1ef8..f981a5e6e54 100644 --- a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js +++ b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js @@ -21,7 +21,7 @@ b = d2; var r: Base[] = [d1, d2]; //// [derivedTypeDoesNotRequireExtendsClause.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js new file mode 100644 index 00000000000..4f071b5e5ec --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js @@ -0,0 +1,100 @@ +//// [destructuringArrayBindingPatternAndAssignment1ES5.ts] +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +var [a2 = false, a3 = 1]: any = undefined; + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + +function foo() { + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +var [...b8] = foo(); + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +var [c0, c1] = [...temp]; +var [c2] = []; +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +var [, c7] = [1, 2, 3]; +var [,,, c8] = [1, 2, 3, 4]; +var [,,, c9] = [1, 2, 3, 4]; +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +var [c11, c12, ...c13] = [1, 2, "string"]; +var [c14, c15, c16] = [1, 2, "string"]; + + + +//// [destructuringArrayBindingPatternAndAssignment1ES5.js] +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or +var a0 = undefined[0], a1 = undefined[1]; +var _a = undefined[0], a2 = _a === void 0 ? false : _a, _b = undefined[1], a3 = _b === void 0 ? 1 : _b; +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var _c = [2, 3, 4], b0 = _c[0], b1 = _c[1], b2 = _c[2]; +var _d = [1, 2, "string"], b3 = _d[0], b4 = _d[1], b5 = _d[2]; +function foo() { + return [1, 2, 3]; +} +var _e = foo(), b6 = _e[0], b7 = _e[1]; +var b8 = foo().slice(0); +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1, 2, 3]; +var _f = temp.slice(), c0 = _f[0], c1 = _f[1]; +var c2 = [][0]; +var _g = [[[]], [[[[]]]]], c3 = _g[0][0][0], c4 = _g[1][0][0][0][0]; +var _h = [[1], true], c5 = _h[0][0], c6 = _h[1]; +var _j = [1, 2, 3], c7 = _j[1]; +var _k = [1, 2, 3, 4], c8 = _k[3]; +var _l = [1, 2, 3, 4], c9 = _l[3]; +var _m = [1, 2, 3, 4, "hello"], c10 = _m.slice(3); +var _o = [1, 2, "string"], c11 = _o[0], c12 = _o[1], c13 = _o.slice(2); +var _p = [1, 2, "string"], c14 = _p[0], c15 = _p[1], c16 = _p[2]; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols new file mode 100644 index 00000000000..d8e319f4120 --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols @@ -0,0 +1,105 @@ +=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts === +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +>a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 5)) +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 8)) +>undefined : Symbol(undefined) + +var [a2 = false, a3 = 1]: any = undefined; +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 5)) +>a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 16)) +>undefined : Symbol(undefined) + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +>b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 5)) +>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 8)) +>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 12)) + +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; +>b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 5)) +>b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 8)) +>b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 12)) + +function foo() { +>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) + + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +>b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 5)) +>b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 8)) +>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) + +var [...b8] = foo(); +>b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 37, 5)) +>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3)) + +var [c0, c1] = [...temp]; +>c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 5)) +>c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 8)) +>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3)) + +var [c2] = []; +>c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 42, 5)) + +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +>c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 7)) +>c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 17)) + +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +>c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 6)) +>c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 10)) + +var [, c7] = [1, 2, 3]; +>c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 45, 6)) + +var [,,, c8] = [1, 2, 3, 4]; +>c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 46, 8)) + +var [,,, c9] = [1, 2, 3, 4]; +>c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 47, 8)) + +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +>c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 48, 8)) + +var [c11, c12, ...c13] = [1, 2, "string"]; +>c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 5)) +>c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 9)) +>c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 14)) + +var [c14, c15, c16] = [1, 2, "string"]; +>c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 5)) +>c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 9)) +>c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 14)) + + diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types new file mode 100644 index 00000000000..bde9c867e2b --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types @@ -0,0 +1,177 @@ +=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts === +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +>a0 : any +>a1 : any +>undefined : undefined + +var [a2 = false, a3 = 1]: any = undefined; +>a2 : boolean +>false : boolean +>a3 : number +>1 : number +>undefined : undefined + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +>b0 : number +>b1 : number +>b2 : number +>[2, 3, 4] : [number, number, number] +>2 : number +>3 : number +>4 : number + +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; +>b3 : number +>b4 : number +>b5 : string +>[1, 2, "string"] : [number, number, string] +>1 : number +>2 : number +>"string" : string + +function foo() { +>foo : () => number[] + + return [1, 2, 3]; +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number +} + +var [b6, b7] = foo(); +>b6 : number +>b7 : number +>foo() : number[] +>foo : () => number[] + +var [...b8] = foo(); +>b8 : number[] +>foo() : number[] +>foo : () => number[] + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +>temp : number[] +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +var [c0, c1] = [...temp]; +>c0 : number +>c1 : number +>[...temp] : number[] +>...temp : number +>temp : number[] + +var [c2] = []; +>c2 : any +>[] : undefined[] + +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +>c3 : any +>c4 : any +>[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]] +>[[]] : [undefined[]] +>[] : undefined[] +>[[[[]]]] : [[[undefined[]]]] +>[[[]]] : [[undefined[]]] +>[[]] : [undefined[]] +>[] : undefined[] + +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +>c5 : string | number +>c6 : boolean +>[[1], true] : [[number], boolean] +>[1] : [number] +>1 : number +>true : boolean + +var [, c7] = [1, 2, 3]; +> : undefined +>c7 : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +var [,,, c8] = [1, 2, 3, 4]; +> : undefined +> : undefined +> : undefined +>c8 : number +>[1, 2, 3, 4] : [number, number, number, number] +>1 : number +>2 : number +>3 : number +>4 : number + +var [,,, c9] = [1, 2, 3, 4]; +> : undefined +> : undefined +> : undefined +>c9 : number +>[1, 2, 3, 4] : [number, number, number, number] +>1 : number +>2 : number +>3 : number +>4 : number + +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +> : undefined +> : undefined +> : undefined +>c10 : (string | number)[] +>[1, 2, 3, 4, "hello"] : (string | number)[] +>1 : number +>2 : number +>3 : number +>4 : number +>"hello" : string + +var [c11, c12, ...c13] = [1, 2, "string"]; +>c11 : string | number +>c12 : string | number +>c13 : (string | number)[] +>[1, 2, "string"] : (string | number)[] +>1 : number +>2 : number +>"string" : string + +var [c14, c15, c16] = [1, 2, "string"]; +>c14 : number +>c15 : number +>c16 : string +>[1, 2, "string"] : [number, number, string] +>1 : number +>2 : number +>"string" : string + + diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.js new file mode 100644 index 00000000000..d3a5c9ff5aa --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.js @@ -0,0 +1,99 @@ +//// [destructuringArrayBindingPatternAndAssignment1ES6.ts] + +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +var [a2 = false, a3 = 1]: any = undefined; + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + +function foo() { + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +var [...b8] = foo(); + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +var [c0, c1] = [...temp]; +var [c2] = []; +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +var [, c7] = [1, 2, 3]; +var [,,, c8] = [1, 2, 3, 4]; +var [,,, c9] = [1, 2, 3, 4]; +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +var [c11, c12, ...c13] = [1, 2, "string"]; +var [c14, c15, c16] = [1, 2, "string"]; + +//// [destructuringArrayBindingPatternAndAssignment1ES6.js] +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or +var [a0, a1] = undefined; +var [a2 = false, a3 = 1] = undefined; +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +var [b3, b4, b5] = [1, 2, "string"]; +function foo() { + return [1, 2, 3]; +} +var [b6, b7] = foo(); +var [...b8] = foo(); +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1, 2, 3]; +var [c0, c1] = [...temp]; +var [c2] = []; +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]; +var [[c5], c6] = [[1], true]; +var [, c7] = [1, 2, 3]; +var [, , , c8] = [1, 2, 3, 4]; +var [, , , c9] = [1, 2, 3, 4]; +var [, , , ...c10] = [1, 2, 3, 4, "hello"]; +var [c11, c12, ...c13] = [1, 2, "string"]; +var [c14, c15, c16] = [1, 2, "string"]; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols new file mode 100644 index 00000000000..33f9b4e88be --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols @@ -0,0 +1,105 @@ +=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts === + +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +>a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 5)) +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 8)) +>undefined : Symbol(undefined) + +var [a2 = false, a3 = 1]: any = undefined; +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 5)) +>a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 16)) +>undefined : Symbol(undefined) + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +>b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 5)) +>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 8)) +>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 12)) + +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; +>b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 5)) +>b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 8)) +>b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 12)) + +function foo() { +>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) + + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +>b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 5)) +>b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 8)) +>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) + +var [...b8] = foo(); +>b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 38, 5)) +>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3)) + +var [c0, c1] = [...temp]; +>c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 5)) +>c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 8)) +>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3)) + +var [c2] = []; +>c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 43, 5)) + +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +>c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 7)) +>c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 17)) + +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +>c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 6)) +>c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 10)) + +var [, c7] = [1, 2, 3]; +>c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 46, 6)) + +var [,,, c8] = [1, 2, 3, 4]; +>c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 47, 8)) + +var [,,, c9] = [1, 2, 3, 4]; +>c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 48, 8)) + +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +>c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 49, 8)) + +var [c11, c12, ...c13] = [1, 2, "string"]; +>c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 5)) +>c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 9)) +>c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 14)) + +var [c14, c15, c16] = [1, 2, "string"]; +>c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 5)) +>c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 9)) +>c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 14)) + diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types new file mode 100644 index 00000000000..2d5d82c5efe --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types @@ -0,0 +1,177 @@ +=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts === + +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +>a0 : any +>a1 : any +>undefined : undefined + +var [a2 = false, a3 = 1]: any = undefined; +>a2 : boolean +>false : boolean +>a3 : number +>1 : number +>undefined : undefined + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +>b0 : number +>b1 : number +>b2 : number +>[2, 3, 4] : [number, number, number] +>2 : number +>3 : number +>4 : number + +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; +>b3 : number +>b4 : number +>b5 : string +>[1, 2, "string"] : [number, number, string] +>1 : number +>2 : number +>"string" : string + +function foo() { +>foo : () => number[] + + return [1, 2, 3]; +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number +} + +var [b6, b7] = foo(); +>b6 : number +>b7 : number +>foo() : number[] +>foo : () => number[] + +var [...b8] = foo(); +>b8 : number[] +>foo() : number[] +>foo : () => number[] + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +>temp : number[] +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +var [c0, c1] = [...temp]; +>c0 : number +>c1 : number +>[...temp] : number[] +>...temp : number +>temp : number[] + +var [c2] = []; +>c2 : any +>[] : undefined[] + +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +>c3 : any +>c4 : any +>[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]] +>[[]] : [undefined[]] +>[] : undefined[] +>[[[[]]]] : [[[undefined[]]]] +>[[[]]] : [[undefined[]]] +>[[]] : [undefined[]] +>[] : undefined[] + +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +>c5 : string | number +>c6 : boolean +>[[1], true] : [[number], boolean] +>[1] : [number] +>1 : number +>true : boolean + +var [, c7] = [1, 2, 3]; +> : undefined +>c7 : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +var [,,, c8] = [1, 2, 3, 4]; +> : undefined +> : undefined +> : undefined +>c8 : number +>[1, 2, 3, 4] : [number, number, number, number] +>1 : number +>2 : number +>3 : number +>4 : number + +var [,,, c9] = [1, 2, 3, 4]; +> : undefined +> : undefined +> : undefined +>c9 : number +>[1, 2, 3, 4] : [number, number, number, number] +>1 : number +>2 : number +>3 : number +>4 : number + +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +> : undefined +> : undefined +> : undefined +>c10 : (string | number)[] +>[1, 2, 3, 4, "hello"] : (string | number)[] +>1 : number +>2 : number +>3 : number +>4 : number +>"hello" : string + +var [c11, c12, ...c13] = [1, 2, "string"]; +>c11 : string | number +>c12 : string | number +>c13 : (string | number)[] +>[1, 2, "string"] : (string | number)[] +>1 : number +>2 : number +>"string" : string + +var [c14, c15, c16] = [1, 2, "string"]; +>c14 : number +>c15 : number +>c16 : string +>[1, 2, "string"] : [number, number, string] +>1 : number +>2 : number +>"string" : string + diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt new file mode 100644 index 00000000000..a2e5cb7e17c --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. + Types of property '1' are incompatible. + Type 'number' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'. + Property 'toFixed' is missing in type 'String'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. + Property '0' is missing in type 'number[]'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'. + Property '0' is missing in type 'number[]'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type. + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (8 errors) ==== + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is the type Any, or + var [[a0], [[a1]]] = [] // Error + ~~~~ +!!! error TS2461: Type 'undefined' is not an array type. + ~~~~~~ +!!! error TS2461: Type 'undefined' is not an array type. + var [[a2], [[a3]]] = undefined // Error + ~~~~~~~~~~~~~~ +!!! error TS2461: Type 'undefined' is not an array type. + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, + // where N is the numeric index of E in the array assignment pattern, or + var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error + ~~~~~~~~~~~~ +!!! error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. +!!! error TS2322: Types of property '1' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. + interface J extends Array { + 2: number; + } + + function bar(): J { + return <[number, number, number]>[1, 2, 3]; + } + var [b3 = "string", b4, b5] = bar(); // Error + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'Number'. +!!! error TS2322: Property 'toFixed' is missing in type 'String'. + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. + var temp = [1, 2, 3] + var [c0, c1]: [number, number] = [...temp]; // Error + ~~~~~~~~ +!!! error TS2322: Type 'number[]' is not assignable to type '[number, number]'. +!!! error TS2322: Property '0' is missing in type 'number[]'. + var [c2, c3]: [string, string] = [...temp]; // Error + ~~~~~~~~ +!!! error TS2322: Type 'number[]' is not assignable to type '[string, string]'. +!!! error TS2322: Property '0' is missing in type 'number[]'. + + interface F { + [idx: number]: boolean + } + + function foo(idx: number): F { + return { + 2: true + } + } + var [c4, c5, c6] = foo(1); // Error + ~~~~~~~~~~~~ +!!! error TS2461: Type 'F' is not an array type. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js new file mode 100644 index 00000000000..223090ea8ca --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js @@ -0,0 +1,60 @@ +//// [destructuringArrayBindingPatternAndAssignment2.ts] +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or +var [[a0], [[a1]]] = [] // Error +var [[a2], [[a3]]] = undefined // Error + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error +interface J extends Array { + 2: number; +} + +function bar(): J { + return <[number, number, number]>[1, 2, 3]; +} +var [b3 = "string", b4, b5] = bar(); // Error + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1, 2, 3] +var [c0, c1]: [number, number] = [...temp]; // Error +var [c2, c3]: [string, string] = [...temp]; // Error + +interface F { + [idx: number]: boolean +} + +function foo(idx: number): F { + return { + 2: true + } +} +var [c4, c5, c6] = foo(1); // Error + +//// [destructuringArrayBindingPatternAndAssignment2.js] +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or +var _a = [], a0 = _a[0][0], a1 = _a[1][0][0]; // Error +var a2 = undefined[0][0], a3 = undefined[1][0][0]; // Error +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var _b = [1, 2, "string"], b0 = _b[0], b1 = _b[1], b2 = _b[2]; // Error +function bar() { + return [1, 2, 3]; +} +var _c = bar(), _d = _c[0], b3 = _d === void 0 ? "string" : _d, b4 = _c[1], b5 = _c[2]; // Error +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1, 2, 3]; +var _e = temp.slice(), c0 = _e[0], c1 = _e[1]; // Error +var _f = temp.slice(), c2 = _f[0], c3 = _f[1]; // Error +function foo(idx) { + return { + 2: true + }; +} +var _g = foo(1), c4 = _g[0], c5 = _g[1], c6 = _g[2]; // Error diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js new file mode 100644 index 00000000000..f201b17deda --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js @@ -0,0 +1,90 @@ +//// [destructuringObjectBindingPatternAndAssignment1ES5.ts] +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +var { a2 }: any = {}; + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +var {1: b3} = { 1: "string" }; +var {b4 = 1}: any = { b4: 100000 }; +var {b5: { b52 } } = { b5: { b52 } }; + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { + [idx: number]: boolean; +} + +function foo(): F { + return { + 1: true + }; +} + +function bar(): F { + return { + 2: true + }; +} +var {1: c0} = foo(); +var {1: c1} = bar(); + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { + [str: string]: number; +} + +function foo1(): F1 { + return { + "prop1": 2 + } +} + +var {"prop1": d1} = foo1(); +var {"prop2": d1} = foo1(); + +//// [destructuringObjectBindingPatternAndAssignment1ES5.js] +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var a1 = undefined.a1; +var a2 = {}.a2; +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var b1 = { b1: 1 }.b1; +var _a = { b2: { b21: "world" } }.b2, b21 = (_a === void 0 ? { b21: "string" } : _a).b21; +var b3 = { 1: "string" }[1]; +var _b = { b4: 100000 }.b4, b4 = _b === void 0 ? 1 : _b; +var b52 = { b5: { b52: b52 } }.b5.b52; +function foo() { + return { + 1: true + }; +} +function bar() { + return { + 2: true + }; +} +var c0 = foo()[1]; +var c1 = bar()[1]; +function foo1() { + return { + "prop1": 2 + }; +} +var d1 = foo1()["prop1"]; +var d1 = foo1()["prop2"]; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols new file mode 100644 index 00000000000..017a7f71e61 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols @@ -0,0 +1,101 @@ +=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5.ts === +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 5, 5)) +>undefined : Symbol(undefined) + +var { a2 }: any = {}; +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 6, 5)) + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 11, 5)) +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 11, 15)) + +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 11)) +>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 21)) +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 44)) +>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 50)) + +var {1: b3} = { 1: "string" }; +>b3 : Symbol(b3, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 13, 5)) + +var {b4 = 1}: any = { b4: 100000 }; +>b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 14, 5)) +>b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 14, 21)) + +var {b5: { b52 } } = { b5: { b52 } }; +>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 10)) +>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 23)) +>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 29)) + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { +>F : Symbol(F, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 38)) + + [idx: number]: boolean; +>idx : Symbol(idx, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 22, 5)) +} + +function foo(): F { +>foo : Symbol(foo, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 23, 1)) +>F : Symbol(F, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 38)) + + return { + 1: true + }; +} + +function bar(): F { +>bar : Symbol(bar, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 29, 1)) +>F : Symbol(F, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 38)) + + return { + 2: true + }; +} +var {1: c0} = foo(); +>c0 : Symbol(c0, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 36, 5)) +>foo : Symbol(foo, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 23, 1)) + +var {1: c1} = bar(); +>c1 : Symbol(c1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 37, 5)) +>bar : Symbol(bar, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 29, 1)) + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { +>F1 : Symbol(F1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 37, 20)) + + [str: string]: number; +>str : Symbol(str, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 43, 5)) +} + +function foo1(): F1 { +>foo1 : Symbol(foo1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 44, 1)) +>F1 : Symbol(F1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 37, 20)) + + return { + "prop1": 2 + } +} + +var {"prop1": d1} = foo1(); +>d1 : Symbol(d1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 52, 5), Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 53, 5)) +>foo1 : Symbol(foo1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 44, 1)) + +var {"prop2": d1} = foo1(); +>d1 : Symbol(d1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 52, 5), Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 53, 5)) +>foo1 : Symbol(foo1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 44, 1)) + diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types new file mode 100644 index 00000000000..f44adab359f --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types @@ -0,0 +1,133 @@ +=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5.ts === +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +>a1 : any +>undefined : undefined + +var { a2 }: any = {}; +>a2 : any +>{} : {} + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +>b1 : number +>{ b1:1, } : { b1: number; } +>b1 : number +>1 : number + +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +>b2 : any +>b21 : string +>{ b21: "string" } : { b21: string; } +>b21 : string +>"string" : string +>{ b2: { b21: "world" } } : { b2: { b21: string; }; } +>b2 : { b21: string; } +>{ b21: "world" } : { b21: string; } +>b21 : string +>"world" : string + +var {1: b3} = { 1: "string" }; +>b3 : string +>{ 1: "string" } : { 1: string; } +>"string" : string + +var {b4 = 1}: any = { b4: 100000 }; +>b4 : number +>1 : number +>{ b4: 100000 } : { b4: number; } +>b4 : number +>100000 : number + +var {b5: { b52 } } = { b5: { b52 } }; +>b5 : any +>b52 : any +>{ b5: { b52 } } : { b5: { b52: any; }; } +>b5 : { b52: any; } +>{ b52 } : { b52: any; } +>b52 : any + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { +>F : F + + [idx: number]: boolean; +>idx : number +} + +function foo(): F { +>foo : () => F +>F : F + + return { +>{ 1: true } : { [x: number]: boolean; 1: boolean; } + + 1: true +>true : boolean + + }; +} + +function bar(): F { +>bar : () => F +>F : F + + return { +>{ 2: true } : { [x: number]: boolean; 2: boolean; } + + 2: true +>true : boolean + + }; +} +var {1: c0} = foo(); +>c0 : boolean +>foo() : F +>foo : () => F + +var {1: c1} = bar(); +>c1 : boolean +>bar() : F +>bar : () => F + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { +>F1 : F1 + + [str: string]: number; +>str : string +} + +function foo1(): F1 { +>foo1 : () => F1 +>F1 : F1 + + return { +>{ "prop1": 2 } : { [x: string]: number; "prop1": number; } + + "prop1": 2 +>2 : number + } +} + +var {"prop1": d1} = foo1(); +>d1 : number +>foo1() : F1 +>foo1 : () => F1 + +var {"prop2": d1} = foo1(); +>d1 : number +>foo1() : F1 +>foo1 : () => F1 + diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.js new file mode 100644 index 00000000000..0173645d8a3 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.js @@ -0,0 +1,90 @@ +//// [destructuringObjectBindingPatternAndAssignment1ES6.ts] +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +var { a2 }: any = {}; + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +var {1: b3} = { 1: "string" }; +var {b4 = 1}: any = { b4: 100000 }; +var {b5: { b52 } } = { b5: { b52 } }; + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { + [idx: number]: boolean; +} + +function foo(): F { + return { + 1: true + }; +} + +function bar(): F { + return { + 2: true + }; +} +var {1: c0} = foo(); +var {1: c1} = bar(); + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { + [str: string]: number; +} + +function foo1(): F1 { + return { + "prop1": 2 + } +} + +var {"prop1": d1} = foo1(); +var {"prop2": d1} = foo1(); + +//// [destructuringObjectBindingPatternAndAssignment1ES6.js] +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 } = undefined; +var { a2 } = {}; +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1: 1, }; +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +var { 1: b3 } = { 1: "string" }; +var { b4 = 1 } = { b4: 100000 }; +var { b5: { b52 } } = { b5: { b52 } }; +function foo() { + return { + 1: true + }; +} +function bar() { + return { + 2: true + }; +} +var { 1: c0 } = foo(); +var { 1: c1 } = bar(); +function foo1() { + return { + "prop1": 2 + }; +} +var { "prop1": d1 } = foo1(); +var { "prop2": d1 } = foo1(); diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols new file mode 100644 index 00000000000..11289210ee4 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols @@ -0,0 +1,101 @@ +=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.ts === +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 5, 5)) +>undefined : Symbol(undefined) + +var { a2 }: any = {}; +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 6, 5)) + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 11, 5)) +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 11, 15)) + +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 11)) +>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 21)) +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 44)) +>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 50)) + +var {1: b3} = { 1: "string" }; +>b3 : Symbol(b3, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 13, 5)) + +var {b4 = 1}: any = { b4: 100000 }; +>b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 14, 5)) +>b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 14, 21)) + +var {b5: { b52 } } = { b5: { b52 } }; +>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 10)) +>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 23)) +>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 29)) + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { +>F : Symbol(F, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 38)) + + [idx: number]: boolean; +>idx : Symbol(idx, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 22, 5)) +} + +function foo(): F { +>foo : Symbol(foo, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 23, 1)) +>F : Symbol(F, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 38)) + + return { + 1: true + }; +} + +function bar(): F { +>bar : Symbol(bar, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 29, 1)) +>F : Symbol(F, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 38)) + + return { + 2: true + }; +} +var {1: c0} = foo(); +>c0 : Symbol(c0, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 36, 5)) +>foo : Symbol(foo, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 23, 1)) + +var {1: c1} = bar(); +>c1 : Symbol(c1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 37, 5)) +>bar : Symbol(bar, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 29, 1)) + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { +>F1 : Symbol(F1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 37, 20)) + + [str: string]: number; +>str : Symbol(str, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 43, 5)) +} + +function foo1(): F1 { +>foo1 : Symbol(foo1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 44, 1)) +>F1 : Symbol(F1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 37, 20)) + + return { + "prop1": 2 + } +} + +var {"prop1": d1} = foo1(); +>d1 : Symbol(d1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 52, 5), Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 53, 5)) +>foo1 : Symbol(foo1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 44, 1)) + +var {"prop2": d1} = foo1(); +>d1 : Symbol(d1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 52, 5), Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 53, 5)) +>foo1 : Symbol(foo1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 44, 1)) + diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types new file mode 100644 index 00000000000..47d4474b63e --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types @@ -0,0 +1,133 @@ +=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.ts === +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +>a1 : any +>undefined : undefined + +var { a2 }: any = {}; +>a2 : any +>{} : {} + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +>b1 : number +>{ b1:1, } : { b1: number; } +>b1 : number +>1 : number + +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +>b2 : any +>b21 : string +>{ b21: "string" } : { b21: string; } +>b21 : string +>"string" : string +>{ b2: { b21: "world" } } : { b2: { b21: string; }; } +>b2 : { b21: string; } +>{ b21: "world" } : { b21: string; } +>b21 : string +>"world" : string + +var {1: b3} = { 1: "string" }; +>b3 : string +>{ 1: "string" } : { 1: string; } +>"string" : string + +var {b4 = 1}: any = { b4: 100000 }; +>b4 : number +>1 : number +>{ b4: 100000 } : { b4: number; } +>b4 : number +>100000 : number + +var {b5: { b52 } } = { b5: { b52 } }; +>b5 : any +>b52 : any +>{ b5: { b52 } } : { b5: { b52: any; }; } +>b5 : { b52: any; } +>{ b52 } : { b52: any; } +>b52 : any + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { +>F : F + + [idx: number]: boolean; +>idx : number +} + +function foo(): F { +>foo : () => F +>F : F + + return { +>{ 1: true } : { [x: number]: boolean; 1: boolean; } + + 1: true +>true : boolean + + }; +} + +function bar(): F { +>bar : () => F +>F : F + + return { +>{ 2: true } : { [x: number]: boolean; 2: boolean; } + + 2: true +>true : boolean + + }; +} +var {1: c0} = foo(); +>c0 : boolean +>foo() : F +>foo : () => F + +var {1: c1} = bar(); +>c1 : boolean +>bar() : F +>bar : () => F + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { +>F1 : F1 + + [str: string]: number; +>str : string +} + +function foo1(): F1 { +>foo1 : () => F1 +>F1 : F1 + + return { +>{ "prop1": 2 } : { [x: string]: number; "prop1": number; } + + "prop1": 2 +>2 : number + } +} + +var {"prop1": d1} = foo1(); +>d1 : number +>foo1() : F1 +>foo1 : () => F1 + +var {"prop2": d1} = foo1(); +>d1 : number +>foo1() : F1 +>foo1 : () => F1 + diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt new file mode 100644 index 00000000000..9025f24f992 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(2,7): error TS1005: ',' expected. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,5): error TS2322: Type '{ i: number; }' is not assignable to type 'string | number'. + Type '{ i: number; }' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2459: Type 'string | number' has no property 'i' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1180: Property destructuring pattern expected. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,7): error TS1005: ':' expected. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,15): error TS1005: ':' expected. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(10,12): error TS1005: ':' expected. + + +==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (9 errors) ==== + // Error + var {h?} = { h?: 1 }; + ~ +!!! error TS1005: ',' expected. + var {i}: string | number = { i: 2 }; + ~~~ +!!! error TS2322: Type '{ i: number; }' is not assignable to type 'string | number'. +!!! error TS2322: Type '{ i: number; }' is not assignable to type 'number'. + ~ +!!! error TS2459: Type 'string | number' has no property 'i' and no string index signature. + var {i1}: string | number| {} = { i1: 2 }; + ~~ +!!! error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. + var { f2: {f21} = { f212: "string" } }: any = undefined; + ~~~ +!!! error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. + var { ...d1 } = { + ~~~ +!!! error TS1180: Property destructuring pattern expected. + a: 1, b: 1, d1: 9, e: 10 + } + var {1} = { 1 }; + ~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1005: ':' expected. + var {"prop"} = { "prop": 1 }; + ~ +!!! error TS1005: ':' expected. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js new file mode 100644 index 00000000000..77288e6a542 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js @@ -0,0 +1,23 @@ +//// [destructuringObjectBindingPatternAndAssignment3.ts] +// Error +var {h?} = { h?: 1 }; +var {i}: string | number = { i: 2 }; +var {i1}: string | number| {} = { i1: 2 }; +var { f2: {f21} = { f212: "string" } }: any = undefined; +var { ...d1 } = { + a: 1, b: 1, d1: 9, e: 10 +} +var {1} = { 1 }; +var {"prop"} = { "prop": 1 }; + +//// [destructuringObjectBindingPatternAndAssignment3.js] +// Error +var h = { h: 1 }.h; +var i = { i: 2 }.i; +var i1 = { i1: 2 }.i1; +var _a = undefined.f2, f21 = (_a === void 0 ? { f212: "string" } : _a).f21; +var d1 = { + a: 1, b: 1, d1: 9, e: 10 +}.d1; +var = { 1: }[1]; +var = { "prop": 1 }["prop"]; diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt new file mode 100644 index 00000000000..269d2b5640d --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt @@ -0,0 +1,124 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(32,4): error TS2345: Argument of type '[string, number, number]' is not assignable to parameter of type '[undefined, null, undefined]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'undefined'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(33,4): error TS2345: Argument of type '[[string], number, [[boolean, boolean]]]' is not assignable to parameter of type '[[undefined], undefined, [[undefined, undefined]]]'. + Types of property '0' are incompatible. + Type '[string]' is not assignable to type '[undefined]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'undefined'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(62,10): error TS2393: Duplicate function implementation. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(63,10): error TS2393: Duplicate function implementation. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts (4 errors) ==== + // A parameter declaration may specify either an identifier or a binding pattern. + // The identifiers specified in parameter declarations and binding patterns + // in a parameter list must be unique within that parameter list. + + // If the declaration includes a type annotation, the parameter is of that type + function a1([a, b, [[c]]]: [number, number, string[][]]) { } + function a2(o: { x: number, a: number }) { } + function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; + function a4({x, a}: { x: number, a: number }) { } + + a1([1, 2, [["world"]]]); + a1([1, 2, [["world"]], 3]); + + // If the declaration includes an initializer expression (which is permitted only + // when the parameter list occurs in conjunction with a function body), + // the parameter type is the widened form (section 3.11) of the type of the initializer expression. + + function b1(z = [undefined, null]) { }; + function b2(z = null, o = { x: 0, y: undefined }) { } + function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + + interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); + } + + function b6([a, z, y] = [undefined, null, undefined]) { } + function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + + b1([1, 2, 3]); // z is widen to the type any[] + b2("string", { x: 200, y: "string" }); + b2("string", { x: 200, y: true }); + b6(["string", 1, 2]); // Shouldn't be an error + ~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[string, number, number]' is not assignable to parameter of type '[undefined, null, undefined]'. +!!! error TS2345: Types of property '0' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'undefined'. + b7([["string"], 1, [[true, false]]]); // Shouldn't be an error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[[string], number, [[boolean, boolean]]]' is not assignable to parameter of type '[[undefined], undefined, [[undefined, undefined]]]'. +!!! error TS2345: Types of property '0' are incompatible. +!!! error TS2345: Type '[string]' is not assignable to type '[undefined]'. +!!! error TS2345: Types of property '0' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'undefined'. + + + // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) + enum Foo { a } + function c0({z: {x, y: {j}}}) { } + function c1({z} = { z: 10 }) { } + function c2({z = 10}) { } + function c3({b}: { b: number|string} = { b: "hello" }) { } + function c5([a, b, [[c]]]) { } + function c6([a, b, [[c=1]]]) { } + + c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } + c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + + c1(); // Implied type is {z:number}? + c1({ z: 1 }) // Implied type is {z:number}? + + c2({}); // Implied type is {z?: number} + c2({z:1}); // Implied type is {z?: number} + + c3({ b: 1 }); // Implied type is { b: number|string }. + + c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] + c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + + // A parameter can be marked optional by following its name or binding pattern with a question mark (?) + // or by including an initializer. + + function d0(x?) { } + ~~ +!!! error TS2393: Duplicate function implementation. + function d0(x = 10) { } + ~~ +!!! error TS2393: Duplicate function implementation. + + interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); + } + + class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } + } + + class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } + } + + + function d5({x, y} = { x: 1, y: 2 }) { } + d5(); // Parameter is optional as its declaration included an initializer + + // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, + // as such annotations would conflict with the already established meaning of colons in object literals. + // Type annotations must instead be written on the top- level parameter declaration + + function e1({x: number}) { } // x has type any NOT number + function e2({x}: { x: number }) { } // x is type number + function e3({x}: { x?: number }) { } // x is an optional with type number + function e4({x: [number,string,any] }) { } // x has type [any, any, any] + function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5.js b/tests/baselines/reference/destructuringParameterDeclaration1ES5.js new file mode 100644 index 00000000000..9a5b4eb8156 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5.js @@ -0,0 +1,226 @@ +//// [destructuringParameterDeclaration1ES5.ts] +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a1([a, b, [[c]]]: [number, number, string[][]]) { } +function a2(o: { x: number, a: number }) { } +function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; +function a4({x, a}: { x: number, a: number }) { } + +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +function b1(z = [undefined, null]) { }; +function b2(z = null, o = { x: 0, y: undefined }) { } +function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + +interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); +} + +function b6([a, z, y] = [undefined, null, undefined]) { } +function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); +b6(["string", 1, 2]); // Shouldn't be an error +b7([["string"], 1, [[true, false]]]); // Shouldn't be an error + + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +enum Foo { a } +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string} = { b: "hello" }) { } +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c=1]]]) { } + +c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } +c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + +c1(); // Implied type is {z:number}? +c1({ z: 1 }) // Implied type is {z:number}? + +c2({}); // Implied type is {z?: number} +c2({z:1}); // Implied type is {z?: number} + +c3({ b: 1 }); // Implied type is { b: number|string }. + +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. + +function d0(x?) { } +function d0(x = 10) { } + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } +} + +class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } +} + + +function d5({x, y} = { x: 1, y: 2 }) { } +d5(); // Parameter is optional as its declaration included an initializer + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e1({x: number}) { } // x has type any NOT number +function e2({x}: { x: number }) { } // x is type number +function e3({x}: { x?: number }) { } // x is an optional with type number +function e4({x: [number,string,any] }) { } // x has type [any, any, any] +function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + + +//// [destructuringParameterDeclaration1ES5.js] +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. +// If the declaration includes a type annotation, the parameter is of that type +function a1(_a) { + var a = _a[0], b = _a[1], c = _a[2][0][0]; +} +function a2(o) { } +function a3(_a) { + var j = _a.j, k = _a.k, _b = _a.l, m = _b.m, n = _b.n, _c = _a.q, a = _c[0], b = _c[1], c = _c[2]; +} +; +function a4(_a) { + var x = _a.x, a = _a.a; +} +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. +function b1(z) { + if (z === void 0) { z = [undefined, null]; } +} +; +function b2(z, o) { + if (z === void 0) { z = null; } + if (o === void 0) { o = { x: 0, y: undefined }; } +} +function b3(_a) { + var _b = (_a === void 0 ? { z: { x: "hi", y: { j: 1 } } } : _a).z, x = _b.x, j = _b.y.j; +} +function b6(_a) { + var _b = _a === void 0 ? [undefined, null, undefined] : _a, a = _b[0], z = _b[1], y = _b[2]; +} +function b7(_a) { + var _b = _a === void 0 ? [[undefined], undefined, [[undefined, undefined]]] : _a, a = _b[0][0], b = _b[1], _c = _b[2][0], c = _c[0], d = _c[1]; +} +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); +b6(["string", 1, 2]); // Shouldn't be an error +b7([["string"], 1, [[true, false]]]); // Shouldn't be an error +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 0] = "a"; +})(Foo || (Foo = {})); +function c0(_a) { + var _b = _a.z, x = _b.x, j = _b.y.j; +} +function c1(_a) { + var z = (_a === void 0 ? { z: 10 } : _a).z; +} +function c2(_a) { + var _b = _a.z, z = _b === void 0 ? 10 : _b; +} +function c3(_a) { + var b = (_a === void 0 ? { b: "hello" } : _a).b; +} +function c5(_a) { + var a = _a[0], b = _a[1], c = _a[2][0][0]; +} +function c6(_a) { + var a = _a[0], b = _a[1], _b = _a[2][0][0], c = _b === void 0 ? 1 : _b; +} +c0({ z: { x: 1, y: { j: "world" } } }); // Implied type is { z: {x: any, y: {j: any}} } +c0({ z: { x: "string", y: { j: true } } }); // Implied type is { z: {x: any, y: {j: any}} } +c1(); // Implied type is {z:number}? +c1({ z: 1 }); // Implied type is {z:number}? +c2({}); // Implied type is {z?: number} +c2({ z: 1 }); // Implied type is {z?: number} +c3({ b: 1 }); // Implied type is { b: number|string }. +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. +function d0(x) { } +function d0(x) { + if (x === void 0) { x = 10; } +} +var C2 = (function () { + function C2() { + } + C2.prototype.d3 = function () { }; + C2.prototype.d4 = function () { }; + C2.prototype.e0 = function (_a) { + var a = _a[0], b = _a[1], c = _a[2]; + }; + return C2; +})(); +var C3 = (function () { + function C3() { + } + C3.prototype.d3 = function (_a) { + var a = _a[0], b = _a[1], c = _a[2]; + }; + C3.prototype.d4 = function (_a) { + var x = _a.x, y = _a.y, z = _a.z; + }; + C3.prototype.e0 = function (_a) { + var a = _a[0], b = _a[1], c = _a[2]; + }; + return C3; +})(); +function d5(_a) { + var _b = _a === void 0 ? { x: 1, y: 2 } : _a, x = _b.x, y = _b.y; +} +d5(); // Parameter is optional as its declaration included an initializer +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration +function e1(_a) { + var number = _a.x; +} // x has type any NOT number +function e2(_a) { + var x = _a.x; +} // x is type number +function e3(_a) { + var x = _a.x; +} // x is an optional with type number +function e4(_a) { + var _b = _a.x, number = _b[0], string = _b[1], any = _b[2]; +} // x has type [any, any, any] +function e5(_a) { + var _b = _a.x, a = _b[0], b = _b[1], c = _b[2]; +} // x has type [any, any, any] diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES6.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration1ES6.errors.txt new file mode 100644 index 00000000000..e900b9be393 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES6.errors.txt @@ -0,0 +1,111 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(96,18): error TS2300: Duplicate identifier 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(96,26): error TS2300: Duplicate identifier 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(96,34): error TS2300: Duplicate identifier 'number'. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts (3 errors) ==== + // Conformance for emitting ES6 + + // A parameter declaration may specify either an identifier or a binding pattern. + // The identifiers specified in parameter declarations and binding patterns + // in a parameter list must be unique within that parameter list. + + // If the declaration includes a type annotation, the parameter is of that type + function a1([a, b, [[c]]]: [number, number, string[][]]) { } + function a2(o: { x: number, a: number }) { } + function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; + function a4({x, a}: { x: number, a: number }) { } + + a1([1, 2, [["world"]]]); + a1([1, 2, [["world"]], 3]); + + + // If the declaration includes an initializer expression (which is permitted only + // when the parameter list occurs in conjunction with a function body), + // the parameter type is the widened form (section 3.11) of the type of the initializer expression. + + function b1(z = [undefined, null]) { }; + function b2(z = null, o = { x: 0, y: undefined }) { } + function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + + interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); + } + + function b6([a, z, y] = [undefined, null, undefined]) { } + function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + + b1([1, 2, 3]); // z is widen to the type any[] + b2("string", { x: 200, y: "string" }); + b2("string", { x: 200, y: true }); + + + // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) + enum Foo { a } + function c0({z: {x, y: {j}}}) { } + function c1({z} = { z: 10 }) { } + function c2({z = 10}) { } + function c3({b}: { b: number|string} = { b: "hello" }) { } + function c5([a, b, [[c]]]) { } + function c6([a, b, [[c=1]]]) { } + + c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } + c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + + c1(); // Implied type is {z:number}? + c1({ z: 1 }) // Implied type is {z:number}? + + c2({}); // Implied type is {z?: number} + c2({z:1}); // Implied type is {z?: number} + + c3({ b: 1 }); // Implied type is { b: number|string }. + + c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] + c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + + + // A parameter can be marked optional by following its name or binding pattern with a question mark (?) + // or by including an initializer. + + interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); + } + + class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } + } + + class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } + } + + function d5({x, y} = { x: 1, y: 2 }) { } + d5(); // Parameter is optional as its declaration included an initializer + + // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, + // as such annotations would conflict with the already established meaning of colons in object literals. + // Type annotations must instead be written on the top- level parameter declaration + + function e1({x: number}) { } // x has type any NOT number + function e2({x}: { x: number }) { } // x is type number + function e3({x}: { x?: number }) { } // x is an optional with type number + function e4({x: [number,string,any] }) { } // x has type [any, any, any] + function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + + function e6({x: [number, number, number]}) { } // error, duplicate identifier; + ~~~~~~ +!!! error TS2300: Duplicate identifier 'number'. + ~~~~~~ +!!! error TS2300: Duplicate identifier 'number'. + ~~~~~~ +!!! error TS2300: Duplicate identifier 'number'. + + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES6.js b/tests/baselines/reference/destructuringParameterDeclaration1ES6.js new file mode 100644 index 00000000000..f5c79c5fe88 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES6.js @@ -0,0 +1,169 @@ +//// [destructuringParameterDeclaration1ES6.ts] +// Conformance for emitting ES6 + +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a1([a, b, [[c]]]: [number, number, string[][]]) { } +function a2(o: { x: number, a: number }) { } +function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; +function a4({x, a}: { x: number, a: number }) { } + +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); + + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +function b1(z = [undefined, null]) { }; +function b2(z = null, o = { x: 0, y: undefined }) { } +function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + +interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); +} + +function b6([a, z, y] = [undefined, null, undefined]) { } +function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); + + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +enum Foo { a } +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string} = { b: "hello" }) { } +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c=1]]]) { } + +c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } +c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + +c1(); // Implied type is {z:number}? +c1({ z: 1 }) // Implied type is {z:number}? + +c2({}); // Implied type is {z?: number} +c2({z:1}); // Implied type is {z?: number} + +c3({ b: 1 }); // Implied type is { b: number|string }. + +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } +} + +class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } +} + +function d5({x, y} = { x: 1, y: 2 }) { } +d5(); // Parameter is optional as its declaration included an initializer + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e1({x: number}) { } // x has type any NOT number +function e2({x}: { x: number }) { } // x is type number +function e3({x}: { x?: number }) { } // x is an optional with type number +function e4({x: [number,string,any] }) { } // x has type [any, any, any] +function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + +function e6({x: [number, number, number]}) { } // error, duplicate identifier; + + + + +//// [destructuringParameterDeclaration1ES6.js] +// Conformance for emitting ES6 +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. +// If the declaration includes a type annotation, the parameter is of that type +function a1([a, b, [[c]]]) { } +function a2(o) { } +function a3({ j, k, l: { m, n }, q: [a, b, c] }) { } +; +function a4({ x, a }) { } +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. +function b1(z = [undefined, null]) { } +; +function b2(z = null, o = { x: 0, y: undefined }) { } +function b3({ z: { x, y: { j } } } = { z: { x: "hi", y: { j: 1 } } }) { } +function b6([a, z, y] = [undefined, null, undefined]) { } +function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 0] = "a"; +})(Foo || (Foo = {})); +function c0({ z: { x, y: { j } } }) { } +function c1({ z } = { z: 10 }) { } +function c2({ z = 10 }) { } +function c3({ b } = { b: "hello" }) { } +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c = 1]]]) { } +c0({ z: { x: 1, y: { j: "world" } } }); // Implied type is { z: {x: any, y: {j: any}} } +c0({ z: { x: "string", y: { j: true } } }); // Implied type is { z: {x: any, y: {j: any}} } +c1(); // Implied type is {z:number}? +c1({ z: 1 }); // Implied type is {z:number}? +c2({}); // Implied type is {z?: number} +c2({ z: 1 }); // Implied type is {z?: number} +c3({ b: 1 }); // Implied type is { b: number|string }. +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] +class C2 { + constructor() { + } + d3() { } + d4() { } + e0([a, b, c]) { } +} +class C3 { + d3([a, b, c]) { } + d4({ x, y, z }) { } + e0([a, b, c]) { } +} +function d5({ x, y } = { x: 1, y: 2 }) { } +d5(); // Parameter is optional as its declaration included an initializer +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration +function e1({ x: number }) { } // x has type any NOT number +function e2({ x }) { } // x is type number +function e3({ x }) { } // x is an optional with type number +function e4({ x: [number, string, any] }) { } // x has type [any, any, any] +function e5({ x: [a, b, c] }) { } // x has type [any, any, any] +function e6({ x: [number, number, number] }) { } // error, duplicate identifier; diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt new file mode 100644 index 00000000000..12f50d6886c --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -0,0 +1,203 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,4): error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. + Types of property '1' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. + Types of property 'pop' are incompatible. + Type '() => string | number | string[][]' is not assignable to type '() => number | string[][]'. + Type 'string | number | string[][]' is not assignable to type 'number | string[][]'. + Type 'string' is not assignable to type 'number | string[][]'. + Type 'string' is not assignable to type 'string[][]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. + Types of property 'x' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,14): error TS2300: Duplicate identifier 'z'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,18): error TS2300: Duplicate identifier 'z'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,4): error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'. + Types of property 'z' are incompatible. + Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(35,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'. + Property 'z' is missing in type '{}'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'. + Types of property 'z' are incompatible. + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. + Types of property 'z' are incompatible. + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. + Types of property 'b' are incompatible. + Type 'boolean' is not assignable to type 'string | number'. + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. + Types of property '2' are incompatible. + Type 'boolean' is not assignable to type '[[any]]'. + Property '0' is missing in type 'Boolean'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. + Types of property '2' are incompatible. + Type '[[string]]' is not assignable to type '[[number]]'. + Types of property '0' are incompatible. + Type '[string]' is not assignable to type '[number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(55,7): error TS2420: Class 'C4' incorrectly implements interface 'F2'. + Types of property 'd4' are incompatible. + Type '({x, y, c}: { x: any; y: any; c: any; }) => void' is not assignable to type '({x, y, z}?: { x: any; y: any; z: any; }) => any'. + Types of parameters '__0' and '__0' are incompatible. + Type '{ x: any; y: any; c: any; }' is not assignable to type '{ x: any; y: any; z: any; }'. + Property 'z' is missing in type '{ x: any; y: any; c: any; }'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(56,8): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,18): error TS2300: Duplicate identifier 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,26): error TS2300: Duplicate identifier 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,34): error TS2300: Duplicate identifier 'number'. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts (22 errors) ==== + // A parameter declaration may specify either an identifier or a binding pattern. + // The identifiers specified in parameter declarations and binding patterns + // in a parameter list must be unique within that parameter list. + + // If the declaration includes a type annotation, the parameter is of that type + function a0([a, b, [[c]]]: [number, number, string[][]]) { } + a0([1, "string", [["world"]]); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. +!!! error TS2345: Types of property '1' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS1005: ',' expected. + a0([1, 2, [["world"]], "string"]); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. +!!! error TS2345: Types of property 'pop' are incompatible. +!!! error TS2345: Type '() => string | number | string[][]' is not assignable to type '() => number | string[][]'. +!!! error TS2345: Type 'string | number | string[][]' is not assignable to type 'number | string[][]'. +!!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'. +!!! error TS2345: Type 'string' is not assignable to type 'string[][]'. + + + // If the declaration includes an initializer expression (which is permitted only + // when the parameter list occurs in conjunction with a function body), + // the parameter type is the widened form (section 3.11) of the type of the initializer expression. + + interface F1 { + b0(z = 10, [[a, b], d, {u}] = [[1, 2], "string", { u: false }]); // Error, no function body + ~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + } + + function b1(z = null, o = { x: 0, y: undefined }) { } + function b2([a, z, y] = [undefined, null, undefined]) { } + function b3([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + + b1("string", { x: "string", y: true }); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. +!!! error TS2345: Types of property 'x' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + + // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) + function c0({z: {x, y: {j}}}) { } + function c1({z} = { z: 10 }) { } + function c2({z = 10}) { } + function c3({b}: { b: number|string } = { b: "hello" }) { } + function c4([z], z: number) { } // Error Duplicate identifier + ~ +!!! error TS2300: Duplicate identifier 'z'. + ~ +!!! error TS2300: Duplicate identifier 'z'. + function c5([a, b, [[c]]]) { } + function c6([a, b, [[c = 1]]]) { } + + c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} } + ~~~~~~~~ +!!! error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'. +!!! error TS2345: Types of property 'z' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. + c1({}); // Error, implied type is {z:number}? + ~~ +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'. +!!! error TS2345: Property 'z' is missing in type '{}'. + c1({ z: true }); // Error, implied type is {z:number}? + ~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'. +!!! error TS2345: Types of property 'z' are incompatible. +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + c2({ z: false }); // Error, implied type is {z?: number} + ~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. +!!! error TS2345: Types of property 'z' are incompatible. +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + c3({ b: true }); // Error, implied type is { b: number|string }. + ~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. +!!! error TS2345: Types of property 'b' are incompatible. +!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'. +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. +!!! error TS2345: Types of property '2' are incompatible. +!!! error TS2345: Type 'boolean' is not assignable to type '[[any]]'. +!!! error TS2345: Property '0' is missing in type 'Boolean'. + c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. +!!! error TS2345: Types of property '2' are incompatible. +!!! error TS2345: Type '[[string]]' is not assignable to type '[[number]]'. +!!! error TS2345: Types of property '0' are incompatible. +!!! error TS2345: Type '[string]' is not assignable to type '[number]'. +!!! error TS2345: Types of property '0' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + + // A parameter can be marked optional by following its name or binding pattern with a question mark (?) + // or by including an initializer. Initializers (including binding property or element initializers) are + // permitted only when the parameter list occurs in conjunction with a function body + + function d1([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature + ~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + function d2({x, y, z}?) { } // Error, binding pattern can't be optional in implementation signature + ~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + + interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); + } + + class C4 implements F2 { + ~~ +!!! error TS2420: Class 'C4' incorrectly implements interface 'F2'. +!!! error TS2420: Types of property 'd4' are incompatible. +!!! error TS2420: Type '({x, y, c}: { x: any; y: any; c: any; }) => void' is not assignable to type '({x, y, z}?: { x: any; y: any; z: any; }) => any'. +!!! error TS2420: Types of parameters '__0' and '__0' are incompatible. +!!! error TS2420: Type '{ x: any; y: any; c: any; }' is not assignable to type '{ x: any; y: any; z: any; }'. +!!! error TS2420: Property 'z' is missing in type '{ x: any; y: any; c: any; }'. + d3([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature + ~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + d4({x, y, c}) { } + e0([a, b, q]) { } + } + + // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, + // as such annotations would conflict with the already established meaning of colons in object literals. + // Type annotations must instead be written on the top- level parameter declaration + + function e0({x: [number, number, number]}) { } // error, duplicate identifier; + ~~~~~~ +!!! error TS2300: Duplicate identifier 'number'. + ~~~~~~ +!!! error TS2300: Duplicate identifier 'number'. + ~~~~~~ +!!! error TS2300: Duplicate identifier 'number'. + + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.js b/tests/baselines/reference/destructuringParameterDeclaration2.js new file mode 100644 index 00000000000..dcb2c87f25b --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration2.js @@ -0,0 +1,149 @@ +//// [destructuringParameterDeclaration2.ts] +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a0([a, b, [[c]]]: [number, number, string[][]]) { } +a0([1, "string", [["world"]]); // Error +a0([1, 2, [["world"]], "string"]); // Error + + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +interface F1 { + b0(z = 10, [[a, b], d, {u}] = [[1, 2], "string", { u: false }]); // Error, no function body +} + +function b1(z = null, o = { x: 0, y: undefined }) { } +function b2([a, z, y] = [undefined, null, undefined]) { } +function b3([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1("string", { x: "string", y: true }); // Error + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string } = { b: "hello" }) { } +function c4([z], z: number) { } // Error Duplicate identifier +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c = 1]]]) { } + +c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} } +c1({}); // Error, implied type is {z:number}? +c1({ z: true }); // Error, implied type is {z:number}? +c2({ z: false }); // Error, implied type is {z?: number} +c3({ b: true }); // Error, implied type is { b: number|string }. +c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] +c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. Initializers (including binding property or element initializers) are +// permitted only when the parameter list occurs in conjunction with a function body + +function d1([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature +function d2({x, y, z}?) { } // Error, binding pattern can't be optional in implementation signature + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C4 implements F2 { + d3([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature + d4({x, y, c}) { } + e0([a, b, q]) { } +} + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e0({x: [number, number, number]}) { } // error, duplicate identifier; + + + + +//// [destructuringParameterDeclaration2.js] +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. +// If the declaration includes a type annotation, the parameter is of that type +function a0(_a) { + var a = _a[0], b = _a[1], c = _a[2][0][0]; +} +a0([1, "string", [["world"]]]); // Error +a0([1, 2, [["world"]], "string"]); // Error +function b1(z, o) { + if (z === void 0) { z = null; } + if (o === void 0) { o = { x: 0, y: undefined }; } +} +function b2(_a) { + var _b = _a === void 0 ? [undefined, null, undefined] : _a, a = _b[0], z = _b[1], y = _b[2]; +} +function b3(_a) { + var _b = _a === void 0 ? [[undefined], undefined, [[undefined, undefined]]] : _a, a = _b[0][0], b = _b[1], _c = _b[2][0], c = _c[0], d = _c[1]; +} +b1("string", { x: "string", y: true }); // Error +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +function c0(_a) { + var _b = _a.z, x = _b.x, j = _b.y.j; +} +function c1(_a) { + var z = (_a === void 0 ? { z: 10 } : _a).z; +} +function c2(_a) { + var _b = _a.z, z = _b === void 0 ? 10 : _b; +} +function c3(_a) { + var b = (_a === void 0 ? { b: "hello" } : _a).b; +} +function c4(_a, z) { + var z = _a[0]; +} // Error Duplicate identifier +function c5(_a) { + var a = _a[0], b = _a[1], c = _a[2][0][0]; +} +function c6(_a) { + var a = _a[0], b = _a[1], _b = _a[2][0][0], c = _b === void 0 ? 1 : _b; +} +c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} } +c1({}); // Error, implied type is {z:number}? +c1({ z: true }); // Error, implied type is {z:number}? +c2({ z: false }); // Error, implied type is {z?: number} +c3({ b: true }); // Error, implied type is { b: number|string }. +c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] +c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. Initializers (including binding property or element initializers) are +// permitted only when the parameter list occurs in conjunction with a function body +function d1(_a) { + var a = _a[0], b = _a[1], c = _a[2]; +} // Error, binding pattern can't be optional in implementation signature +function d2(_a) { + var x = _a.x, y = _a.y, z = _a.z; +} // Error, binding pattern can't be optional in implementation signature +var C4 = (function () { + function C4() { + } + C4.prototype.d3 = function (_a) { + var a = _a[0], b = _a[1], c = _a[2]; + }; // Error, binding pattern can't be optional in implementation signature + C4.prototype.d4 = function (_a) { + var x = _a.x, y = _a.y, c = _a.c; + }; + C4.prototype.e0 = function (_a) { + var a = _a[0], b = _a[1], q = _a[2]; + }; + return C4; +})(); +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration +function e0(_a) { + var _b = _a.x, number = _b[0], number = _b[1], number = _b[2]; +} // error, duplicate identifier; diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.js b/tests/baselines/reference/destructuringParameterDeclaration3ES5.js new file mode 100644 index 00000000000..5dea671ee1a --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.js @@ -0,0 +1,80 @@ +//// [destructuringParameterDeclaration3ES5.ts] + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a1(...x: (number|string)[]) { } +function a2(...a) { } +function a3(...a: Array) { } +function a4(...a: arrayString) { } +function a5(...a: stringOrNumArray) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]: number[]) { } + + +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] + +// Rest parameter with generic +function foo(...a: T[]) { } +foo("hello", 1, 2); +foo("hello", "world"); + +enum E { a, b } +const enum E1 { a, b } +function foo1(...a: T[]) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, E1.a, E.b); + + + + +//// [destructuringParameterDeclaration3ES5.js] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +function a1(...x) { } +function a2(...a) { } +function a3(...a) { } +function a4(...a) { } +function a5(...a) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]) { } +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] +// Rest parameter with generic +function foo(...a) { } +foo("hello", 1, 2); +foo("hello", "world"); +var E; +(function (E) { + E[E["a"] = 0] = "a"; + E[E["b"] = 1] = "b"; +})(E || (E = {})); +function foo1(...a) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, 0 /* a */, E.b); diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols new file mode 100644 index 00000000000..033ad46ece1 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -0,0 +1,145 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts === + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +type someArray = Array | number[]; +>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +type stringOrNumArray = Array; +>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) + +function a1(...x: (number|string)[]) { } +>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES5.ts, 9, 45)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES5.ts, 11, 12)) + +function a2(...a) { } +>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES5.ts, 11, 40)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 12, 12)) + +function a3(...a: Array) { } +>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +function a4(...a: arrayString) { } +>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 14, 12)) +>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) + +function a5(...a: stringOrNumArray) { } +>a5 : Symbol(a5, Decl(destructuringParameterDeclaration3ES5.ts, 14, 34)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 15, 12)) +>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) + +function a9([a, b, [[c]]]) { } +>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES5.ts, 15, 39)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 16, 13)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES5.ts, 16, 15)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES5.ts, 16, 21)) + +function a10([a, b, [[c]], ...x]) { } +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5.ts, 16, 30)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 17, 14)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES5.ts, 17, 16)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES5.ts, 17, 22)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES5.ts, 17, 26)) + +function a11([a, b, c, ...x]: number[]) { } +>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES5.ts, 17, 37)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 18, 14)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES5.ts, 18, 16)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES5.ts, 18, 19)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES5.ts, 18, 22)) + + +var array = [1, 2, 3]; +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES5.ts, 21, 3)) + +var array2 = [true, false, "hello"]; +>array2 : Symbol(array2, Decl(destructuringParameterDeclaration3ES5.ts, 22, 3)) + +a2([...array]); +>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES5.ts, 11, 40)) +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES5.ts, 21, 3)) + +a1(...array); +>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES5.ts, 9, 45)) +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES5.ts, 21, 3)) + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES5.ts, 15, 39)) + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5.ts, 16, 30)) + +a10([1, 2, 3, false, true]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5.ts, 16, 30)) + +a10([1, 2]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5.ts, 16, 30)) + +a11([1, 2]); // Parameter type is number[] +>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES5.ts, 17, 37)) + +// Rest parameter with generic +function foo(...a: T[]) { } +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES5.ts, 31, 12)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5.ts, 34, 13)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 34, 16)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5.ts, 34, 13)) + +foo("hello", 1, 2); +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES5.ts, 31, 12)) + +foo("hello", "world"); +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES5.ts, 31, 12)) + +enum E { a, b } +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES5.ts, 36, 22)) +>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES5.ts, 38, 8)) +>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES5.ts, 38, 11)) + +const enum E1 { a, b } +>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES5.ts, 38, 15)) +>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES5.ts, 39, 15)) +>b : Symbol(E1.b, Decl(destructuringParameterDeclaration3ES5.ts, 39, 18)) + +function foo1(...a: T[]) { } +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES5.ts, 39, 22)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5.ts, 40, 14)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 40, 32)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5.ts, 40, 14)) + +foo1(1, 2, 3, E.a); +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES5.ts, 39, 22)) +>E.a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES5.ts, 38, 8)) +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES5.ts, 36, 22)) +>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES5.ts, 38, 8)) + +foo1(1, 2, 3, E1.a, E.b); +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES5.ts, 39, 22)) +>E1.a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES5.ts, 39, 15)) +>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES5.ts, 38, 15)) +>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES5.ts, 39, 15)) +>E.b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES5.ts, 38, 11)) +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES5.ts, 36, 22)) +>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES5.ts, 38, 11)) + + + diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types new file mode 100644 index 00000000000..64bede3e2de --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types @@ -0,0 +1,206 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts === + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +>arrayString : String[] +>Array : T[] +>String : String + +type someArray = Array | number[]; +>someArray : number[] | String[] +>Array : T[] +>String : String + +type stringOrNumArray = Array; +>stringOrNumArray : (String | Number)[] +>Array : T[] +>String : String +>Number : Number + +function a1(...x: (number|string)[]) { } +>a1 : (...x: (string | number)[]) => void +>x : (string | number)[] + +function a2(...a) { } +>a2 : (...a: any[]) => void +>a : any[] + +function a3(...a: Array) { } +>a3 : (...a: String[]) => void +>a : String[] +>Array : T[] +>String : String + +function a4(...a: arrayString) { } +>a4 : (...a: String[]) => void +>a : String[] +>arrayString : String[] + +function a5(...a: stringOrNumArray) { } +>a5 : (...a: (String | Number)[]) => void +>a : (String | Number)[] +>stringOrNumArray : (String | Number)[] + +function a9([a, b, [[c]]]) { } +>a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void +>a : any +>b : any +>c : any + +function a10([a, b, [[c]], ...x]) { } +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>a : any +>b : any +>c : any +>x : any[] + +function a11([a, b, c, ...x]: number[]) { } +>a11 : ([a, b, c, ...x]: number[]) => void +>a : number +>b : number +>c : number +>x : number[] + + +var array = [1, 2, 3]; +>array : number[] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number + +var array2 = [true, false, "hello"]; +>array2 : (string | boolean)[] +>[true, false, "hello"] : (string | boolean)[] +>true : boolean +>false : boolean +>"hello" : string + +a2([...array]); +>a2([...array]) : void +>a2 : (...a: any[]) => void +>[...array] : number[] +>...array : number +>array : number[] + +a1(...array); +>a1(...array) : void +>a1 : (...x: (string | number)[]) => void +>...array : number +>array : number[] + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +>a9([1, 2, [["string"]], false, true]) : void +>a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void +>[1, 2, [["string"]], false, true] : [number, number, [[string]], boolean, boolean] +>1 : number +>2 : number +>[["string"]] : [[string]] +>["string"] : [string] +>"string" : string +>false : boolean +>true : boolean + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +>a10([1, 2, [["string"]], false, true]) : void +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] +>1 : number +>2 : number +>[["string"]] : string[][] +>["string"] : string[] +>"string" : string +>false : boolean +>true : boolean + +a10([1, 2, 3, false, true]); // Parameter type is any[] +>a10([1, 2, 3, false, true]) : void +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>[1, 2, 3, false, true] : (number | boolean)[] +>1 : number +>2 : number +>3 : number +>false : boolean +>true : boolean + +a10([1, 2]); // Parameter type is any[] +>a10([1, 2]) : void +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>[1, 2] : number[] +>1 : number +>2 : number + +a11([1, 2]); // Parameter type is number[] +>a11([1, 2]) : void +>a11 : ([a, b, c, ...x]: number[]) => void +>[1, 2] : number[] +>1 : number +>2 : number + +// Rest parameter with generic +function foo(...a: T[]) { } +>foo : (...a: T[]) => void +>T : T +>a : T[] +>T : T + +foo("hello", 1, 2); +>foo("hello", 1, 2) : void +>foo : (...a: T[]) => void +>"hello" : string +>1 : number +>2 : number + +foo("hello", "world"); +>foo("hello", "world") : void +>foo : (...a: T[]) => void +>"hello" : string +>"world" : string + +enum E { a, b } +>E : E +>a : E +>b : E + +const enum E1 { a, b } +>E1 : E1 +>a : E1 +>b : E1 + +function foo1(...a: T[]) { } +>foo1 : (...a: T[]) => void +>T : T +>Number : Number +>a : T[] +>T : T + +foo1(1, 2, 3, E.a); +>foo1(1, 2, 3, E.a) : void +>foo1 : (...a: T[]) => void +>1 : number +>2 : number +>3 : number +>E.a : E +>E : typeof E +>a : E + +foo1(1, 2, 3, E1.a, E.b); +>foo1(1, 2, 3, E1.a, E.b) : void +>foo1 : (...a: T[]) => void +>1 : number +>2 : number +>3 : number +>E1.a : E1 +>E1 : typeof E1 +>a : E1 +>E.b : E +>E : typeof E +>b : E + + + diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.js b/tests/baselines/reference/destructuringParameterDeclaration3ES6.js new file mode 100644 index 00000000000..5893168bf93 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.js @@ -0,0 +1,80 @@ +//// [destructuringParameterDeclaration3ES6.ts] + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a1(...x: (number|string)[]) { } +function a2(...a) { } +function a3(...a: Array) { } +function a4(...a: arrayString) { } +function a5(...a: stringOrNumArray) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]: number[]) { } + + +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] + +// Rest parameter with generic +function foo(...a: T[]) { } +foo("hello", 1, 2); +foo("hello", "world"); + +enum E { a, b } +const enum E1 { a, b } +function foo1(...a: T[]) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, E1.a, E.b); + + + + +//// [destructuringParameterDeclaration3ES6.js] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +function a1(...x) { } +function a2(...a) { } +function a3(...a) { } +function a4(...a) { } +function a5(...a) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]) { } +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] +// Rest parameter with generic +function foo(...a) { } +foo("hello", 1, 2); +foo("hello", "world"); +var E; +(function (E) { + E[E["a"] = 0] = "a"; + E[E["b"] = 1] = "b"; +})(E || (E = {})); +function foo1(...a) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, 0 /* a */, E.b); diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols new file mode 100644 index 00000000000..d23b624a023 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -0,0 +1,145 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts === + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +type someArray = Array | number[]; +>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +type stringOrNumArray = Array; +>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) + +function a1(...x: (number|string)[]) { } +>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES6.ts, 9, 45)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES6.ts, 11, 12)) + +function a2(...a) { } +>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES6.ts, 11, 40)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 12, 12)) + +function a3(...a: Array) { } +>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) + +function a4(...a: arrayString) { } +>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 14, 12)) +>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) + +function a5(...a: stringOrNumArray) { } +>a5 : Symbol(a5, Decl(destructuringParameterDeclaration3ES6.ts, 14, 34)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 15, 12)) +>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) + +function a9([a, b, [[c]]]) { } +>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES6.ts, 15, 39)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 16, 13)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES6.ts, 16, 15)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES6.ts, 16, 21)) + +function a10([a, b, [[c]], ...x]) { } +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 17, 14)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES6.ts, 17, 16)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES6.ts, 17, 22)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES6.ts, 17, 26)) + +function a11([a, b, c, ...x]: number[]) { } +>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES6.ts, 17, 37)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 18, 14)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES6.ts, 18, 16)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES6.ts, 18, 19)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES6.ts, 18, 22)) + + +var array = [1, 2, 3]; +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES6.ts, 21, 3)) + +var array2 = [true, false, "hello"]; +>array2 : Symbol(array2, Decl(destructuringParameterDeclaration3ES6.ts, 22, 3)) + +a2([...array]); +>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES6.ts, 11, 40)) +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES6.ts, 21, 3)) + +a1(...array); +>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES6.ts, 9, 45)) +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES6.ts, 21, 3)) + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES6.ts, 15, 39)) + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30)) + +a10([1, 2, 3, false, true]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30)) + +a10([1, 2]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30)) + +a11([1, 2]); // Parameter type is number[] +>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES6.ts, 17, 37)) + +// Rest parameter with generic +function foo(...a: T[]) { } +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES6.ts, 31, 12)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 34, 13)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 34, 16)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 34, 13)) + +foo("hello", 1, 2); +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES6.ts, 31, 12)) + +foo("hello", "world"); +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES6.ts, 31, 12)) + +enum E { a, b } +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES6.ts, 36, 22)) +>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES6.ts, 38, 8)) +>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES6.ts, 38, 11)) + +const enum E1 { a, b } +>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES6.ts, 38, 15)) +>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES6.ts, 39, 15)) +>b : Symbol(E1.b, Decl(destructuringParameterDeclaration3ES6.ts, 39, 18)) + +function foo1(...a: T[]) { } +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES6.ts, 39, 22)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 40, 14)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 40, 32)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 40, 14)) + +foo1(1, 2, 3, E.a); +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES6.ts, 39, 22)) +>E.a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES6.ts, 38, 8)) +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES6.ts, 36, 22)) +>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES6.ts, 38, 8)) + +foo1(1, 2, 3, E1.a, E.b); +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES6.ts, 39, 22)) +>E1.a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES6.ts, 39, 15)) +>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES6.ts, 38, 15)) +>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES6.ts, 39, 15)) +>E.b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES6.ts, 38, 11)) +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES6.ts, 36, 22)) +>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES6.ts, 38, 11)) + + + diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types new file mode 100644 index 00000000000..aea7b2ae15a --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types @@ -0,0 +1,206 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts === + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +>arrayString : String[] +>Array : T[] +>String : String + +type someArray = Array | number[]; +>someArray : number[] | String[] +>Array : T[] +>String : String + +type stringOrNumArray = Array; +>stringOrNumArray : (String | Number)[] +>Array : T[] +>String : String +>Number : Number + +function a1(...x: (number|string)[]) { } +>a1 : (...x: (string | number)[]) => void +>x : (string | number)[] + +function a2(...a) { } +>a2 : (...a: any[]) => void +>a : any[] + +function a3(...a: Array) { } +>a3 : (...a: String[]) => void +>a : String[] +>Array : T[] +>String : String + +function a4(...a: arrayString) { } +>a4 : (...a: String[]) => void +>a : String[] +>arrayString : String[] + +function a5(...a: stringOrNumArray) { } +>a5 : (...a: (String | Number)[]) => void +>a : (String | Number)[] +>stringOrNumArray : (String | Number)[] + +function a9([a, b, [[c]]]) { } +>a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void +>a : any +>b : any +>c : any + +function a10([a, b, [[c]], ...x]) { } +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>a : any +>b : any +>c : any +>x : any[] + +function a11([a, b, c, ...x]: number[]) { } +>a11 : ([a, b, c, ...x]: number[]) => void +>a : number +>b : number +>c : number +>x : number[] + + +var array = [1, 2, 3]; +>array : number[] +>[1, 2, 3] : number[] +>1 : number +>2 : number +>3 : number + +var array2 = [true, false, "hello"]; +>array2 : (string | boolean)[] +>[true, false, "hello"] : (string | boolean)[] +>true : boolean +>false : boolean +>"hello" : string + +a2([...array]); +>a2([...array]) : void +>a2 : (...a: any[]) => void +>[...array] : number[] +>...array : number +>array : number[] + +a1(...array); +>a1(...array) : void +>a1 : (...x: (string | number)[]) => void +>...array : number +>array : number[] + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +>a9([1, 2, [["string"]], false, true]) : void +>a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void +>[1, 2, [["string"]], false, true] : [number, number, [[string]], boolean, boolean] +>1 : number +>2 : number +>[["string"]] : [[string]] +>["string"] : [string] +>"string" : string +>false : boolean +>true : boolean + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +>a10([1, 2, [["string"]], false, true]) : void +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] +>1 : number +>2 : number +>[["string"]] : string[][] +>["string"] : string[] +>"string" : string +>false : boolean +>true : boolean + +a10([1, 2, 3, false, true]); // Parameter type is any[] +>a10([1, 2, 3, false, true]) : void +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>[1, 2, 3, false, true] : (number | boolean)[] +>1 : number +>2 : number +>3 : number +>false : boolean +>true : boolean + +a10([1, 2]); // Parameter type is any[] +>a10([1, 2]) : void +>a10 : ([a, b, [[c]], ...x]: Iterable) => void +>[1, 2] : number[] +>1 : number +>2 : number + +a11([1, 2]); // Parameter type is number[] +>a11([1, 2]) : void +>a11 : ([a, b, c, ...x]: number[]) => void +>[1, 2] : number[] +>1 : number +>2 : number + +// Rest parameter with generic +function foo(...a: T[]) { } +>foo : (...a: T[]) => void +>T : T +>a : T[] +>T : T + +foo("hello", 1, 2); +>foo("hello", 1, 2) : void +>foo : (...a: T[]) => void +>"hello" : string +>1 : number +>2 : number + +foo("hello", "world"); +>foo("hello", "world") : void +>foo : (...a: T[]) => void +>"hello" : string +>"world" : string + +enum E { a, b } +>E : E +>a : E +>b : E + +const enum E1 { a, b } +>E1 : E1 +>a : E1 +>b : E1 + +function foo1(...a: T[]) { } +>foo1 : (...a: T[]) => void +>T : T +>Number : Number +>a : T[] +>T : T + +foo1(1, 2, 3, E.a); +>foo1(1, 2, 3, E.a) : void +>foo1 : (...a: T[]) => void +>1 : number +>2 : number +>3 : number +>E.a : E +>E : typeof E +>a : E + +foo1(1, 2, 3, E1.a, E.b); +>foo1(1, 2, 3, E1.a, E.b) : void +>foo1 : (...a: T[]) => void +>1 : number +>2 : number +>3 : number +>E1.a : E1 +>E1 : typeof E1 +>a : E1 +>E.b : E +>E : typeof E +>b : E + + + diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt new file mode 100644 index 00000000000..707fb005a80 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -0,0 +1,84 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. + Types of property '2' are incompatible. + Type 'string' is not assignable to type '[[any]]'. + Property '0' is missing in type 'String'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. + Property '2' is missing in type '[number, number]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,24): error TS1005: ',' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,22): error TS2304: Cannot find name 'E1'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,28): error TS2304: Cannot find name 'E'. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (10 errors) ==== + // If the parameter is a rest parameter, the parameter type is any[] + // A type annotation for a rest parameter must denote an array type. + + // RestParameter: + // ... Identifier TypeAnnotation(opt) + + type arrayString = Array + type someArray = Array | number[]; + type stringOrNumArray = Array; + + function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + function a1(...x: (number|string)[]) { } + function a2(...a: someArray) { } // Error, rest parameter must be array type + ~~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + function a3(...b?) { } // Error, can't be optional + function a4(...b = [1,2,3]) { } // Error, can't have initializer + function a5([a, b, [[c]]]) { } + function a6([a, b, c, ...x]: number[]) { } + + + a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] + ~~~~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + a1(...array2); // Error parameter type is (number|string)[] + ~~~~~~ +!!! error TS2304: Cannot find name 'array2'. + a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. +!!! error TS2345: Types of property '2' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type '[[any]]'. +!!! error TS2345: Property '0' is missing in type 'String'. + a5([1, 2]); // Error, parameter type is [any, any, [[any]]] + ~~~~~~ +!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. +!!! error TS2345: Property '2' is missing in type '[number, number]'. + a6([1, 2, "string"]); // Error, parameter type is number[] + ~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Type 'string | number' is not assignable to type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + + + var temp = [1, 2, 3]; + class C { + constructor(public ...temp) { } // Error, rest parameter can't have accessibilityModifier + ~~~ +!!! error TS1005: ',' expected. + } + + // Rest parameter with generic + function foo1(...a: T[]) { } + foo1(1, 2, "string", E1.a, E.b); // Error + ~~ +!!! error TS2304: Cannot find name 'E1'. + ~ +!!! error TS2304: Cannot find name 'E'. + + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.js b/tests/baselines/reference/destructuringParameterDeclaration4.js new file mode 100644 index 00000000000..adc5264e1ff --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration4.js @@ -0,0 +1,101 @@ +//// [destructuringParameterDeclaration4.ts] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type +function a1(...x: (number|string)[]) { } +function a2(...a: someArray) { } // Error, rest parameter must be array type +function a3(...b?) { } // Error, can't be optional +function a4(...b = [1,2,3]) { } // Error, can't have initializer +function a5([a, b, [[c]]]) { } +function a6([a, b, c, ...x]: number[]) { } + + +a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] +a1(...array2); // Error parameter type is (number|string)[] +a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] +a5([1, 2]); // Error, parameter type is [any, any, [[any]]] +a6([1, 2, "string"]); // Error, parameter type is number[] + + +var temp = [1, 2, 3]; +class C { + constructor(public ...temp) { } // Error, rest parameter can't have accessibilityModifier +} + +// Rest parameter with generic +function foo1(...a: T[]) { } +foo1(1, 2, "string", E1.a, E.b); // Error + + + + +//// [destructuringParameterDeclaration4.js] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +function a0() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} // Error, rest parameter must be array type +function a1() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +function a2() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i - 0] = arguments[_i]; + } +} // Error, rest parameter must be array type +function a3() { + var b = []; + for (var _i = 0; _i < arguments.length; _i++) { + b[_i - 0] = arguments[_i]; + } +} // Error, can't be optional +function a4() { + var b = []; + for (var _i = 0; _i < arguments.length; _i++) { + b[_i - 0] = arguments[_i]; + } +} // Error, can't have initializer +function a5(_a) { + var a = _a[0], b = _a[1], c = _a[2][0][0]; +} +function a6(_a) { + var a = _a[0], b = _a[1], c = _a[2], x = _a.slice(3); +} +a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] +a1.apply(void 0, array2); // Error parameter type is (number|string)[] +a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] +a5([1, 2]); // Error, parameter type is [any, any, [[any]]] +a6([1, 2, "string"]); // Error, parameter type is number[] +var temp = [1, 2, 3]; +var C = (function () { + function C(public) { + var temp = []; + for (var _i = 1; _i < arguments.length; _i++) { + temp[_i - 1] = arguments[_i]; + } + } // Error, rest parameter can't have accessibilityModifier + return C; +})(); +// Rest parameter with generic +function foo1() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i - 0] = arguments[_i]; + } +} +foo1(1, 2, "string", E1.a, E.b); // Error diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt new file mode 100644 index 00000000000..c60e2b75c37 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt @@ -0,0 +1,79 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,4): error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'. + Types of property 'y' are incompatible. + Type 'Class' is not assignable to type 'D'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(48,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. + Property 'y' is missing in type '{}'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,4): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'. + Types of property 'y' are incompatible. + Type 'number' is not assignable to type 'D'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,4): error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'. + Types of property 'y' are incompatible. + Type 'string' is not assignable to type 'D'. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts (4 errors) ==== + // Parameter Declaration with generic + + interface F { } + class Class implements F { + constructor() { } + } + + class SubClass extends Class { + foo: boolean; + constructor() { super(); } + } + + class D implements F { + foo: boolean + constructor() { } + } + + class SubD extends D { + bar: number + constructor() { + super(); + } + } + + + function d0({x} = { x: new Class() }) { } + function d1({x}: { x: F }) { } + function d2({x}: { x: Class }) { } + function d3({y}: { y: D }) { } + function d4({y} = { y: new D() }) { } + + var obj = new Class(); + d0({ x: 1 }); + d0({ x: {} }); + d0({ x: "string" }); + + d1({ x: new Class() }); + d1({ x: {} }); + d1({ x: "string" }); + + d2({ x: new SubClass() }); + d2({ x: {} }); + + d3({ y: new SubD() }); + d3({ y: new SubClass() }); + // Error + d3({ y: new Class() }); + ~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'. +!!! error TS2345: Types of property 'y' are incompatible. +!!! error TS2345: Type 'Class' is not assignable to type 'D'. + d3({}); + ~~ +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. +!!! error TS2345: Property 'y' is missing in type '{}'. + d3({ y: 1 }); + ~~~~~~~~ +!!! error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'. +!!! error TS2345: Types of property 'y' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'D'. + d3({ y: "world" }); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'. +!!! error TS2345: Types of property 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'D'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.js b/tests/baselines/reference/destructuringParameterDeclaration5.js new file mode 100644 index 00000000000..7540302599c --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration5.js @@ -0,0 +1,115 @@ +//// [destructuringParameterDeclaration5.ts] +// Parameter Declaration with generic + +interface F { } +class Class implements F { + constructor() { } +} + +class SubClass extends Class { + foo: boolean; + constructor() { super(); } +} + +class D implements F { + foo: boolean + constructor() { } +} + +class SubD extends D { + bar: number + constructor() { + super(); + } +} + + +function d0({x} = { x: new Class() }) { } +function d1({x}: { x: F }) { } +function d2({x}: { x: Class }) { } +function d3({y}: { y: D }) { } +function d4({y} = { y: new D() }) { } + +var obj = new Class(); +d0({ x: 1 }); +d0({ x: {} }); +d0({ x: "string" }); + +d1({ x: new Class() }); +d1({ x: {} }); +d1({ x: "string" }); + +d2({ x: new SubClass() }); +d2({ x: {} }); + +d3({ y: new SubD() }); +d3({ y: new SubClass() }); +// Error +d3({ y: new Class() }); +d3({}); +d3({ y: 1 }); +d3({ y: "world" }); + +//// [destructuringParameterDeclaration5.js] +// Parameter Declaration with generic +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; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Class = (function () { + function Class() { + } + return Class; +})(); +var SubClass = (function (_super) { + __extends(SubClass, _super); + function SubClass() { + _super.call(this); + } + return SubClass; +})(Class); +var D = (function () { + function D() { + } + return D; +})(); +var SubD = (function (_super) { + __extends(SubD, _super); + function SubD() { + _super.call(this); + } + return SubD; +})(D); +function d0(_a) { + var x = (_a === void 0 ? { x: new Class() } : _a).x; +} +function d1(_a) { + var x = _a.x; +} +function d2(_a) { + var x = _a.x; +} +function d3(_a) { + var y = _a.y; +} +function d4(_a) { + var y = (_a === void 0 ? { y: new D() } : _a).y; +} +var obj = new Class(); +d0({ x: 1 }); +d0({ x: {} }); +d0({ x: "string" }); +d1({ x: new Class() }); +d1({ x: {} }); +d1({ x: "string" }); +d2({ x: new SubClass() }); +d2({ x: {} }); +d3({ y: new SubD() }); +d3({ y: new SubClass() }); +// Error +d3({ y: new Class() }); +d3({}); +d3({ y: 1 }); +d3({ y: "world" }); diff --git a/tests/baselines/reference/destructuringParameterDeclaration6.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration6.errors.txt new file mode 100644 index 00000000000..15d25ebc60e --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration6.errors.txt @@ -0,0 +1,57 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(7,18): error TS1005: ':' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,14): error TS1181: Array element destructuring pattern expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,19): error TS1005: '(' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,21): error TS1109: Expression expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,24): error TS1005: '(' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,26): error TS2304: Cannot find name 'public'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,32): error TS1005: ';' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(9,33): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(10,16): error TS1003: Identifier expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(10,21): error TS1005: '(' expected. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts(12,13): error TS2370: A rest parameter must be of an array type. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts (11 errors) ==== + // A parameter declaration may specify either an identifier or a binding pattern. + + // Reserved words are not allowed to be used as an identifier in parameter declaration + "use strict" + + // Error + function a({while}) { } + ~ +!!! error TS1005: ':' expected. + function a1({public}) { } + function a4([while, for, public]){ } + ~~~~~ +!!! error TS1181: Array element destructuring pattern expected. + ~ +!!! error TS1005: '(' expected. + ~~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: '(' expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'public'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + function a5(...while) { } + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '(' expected. + function a6(...public) { } + function a7(...a: string) { } + ~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + a({ while: 1 }); + + // No Error + function b1({public: x}) { } + function b2({while: y}) { } + b1({ public: 1 }); + b2({ while: 1 }); + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration6.js b/tests/baselines/reference/destructuringParameterDeclaration6.js new file mode 100644 index 00000000000..f34f2d695ce --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration6.js @@ -0,0 +1,61 @@ +//// [destructuringParameterDeclaration6.ts] +// A parameter declaration may specify either an identifier or a binding pattern. + +// Reserved words are not allowed to be used as an identifier in parameter declaration +"use strict" + +// Error +function a({while}) { } +function a1({public}) { } +function a4([while, for, public]){ } +function a5(...while) { } +function a6(...public) { } +function a7(...a: string) { } +a({ while: 1 }); + +// No Error +function b1({public: x}) { } +function b2({while: y}) { } +b1({ public: 1 }); +b2({ while: 1 }); + + + +//// [destructuringParameterDeclaration6.js] +// A parameter declaration may specify either an identifier or a binding pattern. +// Reserved words are not allowed to be used as an identifier in parameter declaration +"use strict"; +// Error +function a(_a) { + var = _a.while; +} +function a1(_a) { + var public = _a.public; +} +while (, ) + for (, public; ; ) + ; +{ } +while () { } +function a6() { + var public = []; + for (var _i = 0; _i < arguments.length; _i++) { + public[_i - 0] = arguments[_i]; + } +} +function a7() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i - 0] = arguments[_i]; + } +} +a({ while: 1 }); +// No Error +function b1(_a) { + var x = _a.public; +} +function b2(_a) { + var y = _a.while; +} +b1({ public: 1 }); +b2({ while: 1 }); diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.js b/tests/baselines/reference/destructuringVariableDeclaration1ES5.js new file mode 100644 index 00000000000..6d731538d18 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.js @@ -0,0 +1,77 @@ +//// [destructuringVariableDeclaration1ES5.ts] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +var temp = { t1: true, t2: "false" }; +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +var [...c2] = [1,2,3, "string"]; + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +var [d3, d4] = [1, "string", ...temp1]; + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; + + + +//// [destructuringVariableDeclaration1ES5.js] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var _a = { a1: 10, a2: "world" }, a1 = _a.a1, a2 = _a.a2; +var _b = [1, [["hello"]], true], a3 = _b[0], a4 = _b[1][0][0], a5 = _b[2]; +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var _c = { b1: { b11: "world" } }.b1, b11 = (_c === void 0 ? { b11: "string" } : _c).b11; +var temp = { t1: true, t2: "false" }; +var _d = [3, false, { t1: false, t2: "hello" }], _e = _d[0], b2 = _e === void 0 ? 3 : _e, _f = _d[1], b3 = _f === void 0 ? true : _f, _g = _d[2], b4 = _g === void 0 ? temp : _g; +var _h = [undefined, undefined, undefined], _j = _h[0], b5 = _j === void 0 ? 3 : _j, _k = _h[1], b6 = _k === void 0 ? true : _k, _l = _h[2], b7 = _l === void 0 ? temp : _l; +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var c1 = [1, 2, 3].slice(0); +var c2 = [1, 2, 3, "string"].slice(0); +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var _m = [1, "string"], d1 = _m[0], d2 = _m[1]; +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true]; +var _o = [1, "string"].concat(temp1), d3 = _o[0], d4 = _o[1]; +// Combining both forms of destructuring, +var _p = { e: [1, 2, { b1: 4, b4: 0 }] }.e, e1 = _p[0], e2 = _p[1], _q = _p[2], e3 = _q === void 0 ? { b1: 1000, b4: 200 } : _q; +var _r = { f: [1, 2, { f3: 4, f5: 0 }] }.f, f1 = _r[0], f2 = _r[1], _s = _r[2], f4 = _s.f3, f5 = _s.f5; +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var _t = { g: { g1: [1, 2] } }.g.g1, g1 = _t === void 0 ? [undefined, null] : _t; +var _u = { h: { h1: [1, 2] } }.h.h1, h1 = _u === void 0 ? [undefined, null] : _u; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols b/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols new file mode 100644 index 00000000000..2a2f2a358ca --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols @@ -0,0 +1,114 @@ +=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5.ts === +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5.ts, 2, 5)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5.ts, 2, 8)) +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5.ts, 2, 15)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5.ts, 2, 27)) +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5.ts, 2, 44)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5.ts, 2, 52)) + +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; +>a3 : Symbol(a3, Decl(destructuringVariableDeclaration1ES5.ts, 3, 5)) +>a4 : Symbol(a4, Decl(destructuringVariableDeclaration1ES5.ts, 3, 11)) +>a5 : Symbol(a5, Decl(destructuringVariableDeclaration1ES5.ts, 3, 16)) + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 11)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 21)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 50)) + +var temp = { t1: true, t2: "false" }; +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5.ts, 8, 3)) +>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES5.ts, 8, 12)) +>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES5.ts, 8, 22)) + +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +>b2 : Symbol(b2, Decl(destructuringVariableDeclaration1ES5.ts, 9, 5)) +>b3 : Symbol(b3, Decl(destructuringVariableDeclaration1ES5.ts, 9, 12)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 9, 23)) +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5.ts, 8, 3)) +>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES5.ts, 9, 49)) +>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES5.ts, 9, 60)) + +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +>b5 : Symbol(b5, Decl(destructuringVariableDeclaration1ES5.ts, 10, 5)) +>b6 : Symbol(b6, Decl(destructuringVariableDeclaration1ES5.ts, 10, 12)) +>b7 : Symbol(b7, Decl(destructuringVariableDeclaration1ES5.ts, 10, 23)) +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5.ts, 8, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +>c1 : Symbol(c1, Decl(destructuringVariableDeclaration1ES5.ts, 15, 5)) + +var [...c2] = [1,2,3, "string"]; +>c2 : Symbol(c2, Decl(destructuringVariableDeclaration1ES5.ts, 16, 5)) + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] +>d1 : Symbol(d1, Decl(destructuringVariableDeclaration1ES5.ts, 22, 5)) +>d2 : Symbol(d2, Decl(destructuringVariableDeclaration1ES5.ts, 22, 8)) + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES5.ts, 27, 3)) + +var [d3, d4] = [1, "string", ...temp1]; +>d3 : Symbol(d3, Decl(destructuringVariableDeclaration1ES5.ts, 28, 5)) +>d4 : Symbol(d4, Decl(destructuringVariableDeclaration1ES5.ts, 28, 8)) +>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES5.ts, 27, 3)) + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 9)) +>e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES5.ts, 31, 12)) +>e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES5.ts, 31, 16)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 23)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 31, 33)) +>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5.ts, 31, 49)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 61)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 31, 68)) + +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES5.ts, 32, 9)) +>f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES5.ts, 32, 12)) +>f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES5.ts, 32, 18)) +>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5.ts, 32, 26)) +>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41)) +>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5.ts, 32, 53)) +>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5.ts, 32, 60)) + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 9)) +>undefined : Symbol(undefined) +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 41)) +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 59)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 64)) + +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 9)) +>undefined : Symbol(undefined) +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 41)) +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 62)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 67)) + + diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types new file mode 100644 index 00000000000..ef3507f0f8b --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -0,0 +1,200 @@ +=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5.ts === +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +>a1 : number +>a2 : string +>a1 : number +>a2 : string +>{ a1: 10, a2: "world" } : { a1: number; a2: string; } +>a1 : number +>10 : number +>a2 : string +>"world" : string + +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; +>a3 : number +>a4 : string +>a5 : boolean +>[1, [["hello"]], true] : [number, [[string]], boolean] +>1 : number +>[["hello"]] : [[string]] +>["hello"] : [string] +>"hello" : string +>true : boolean + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b1 : any +>b11 : string +>{ b11: "string" } : { b11: string; } +>b11 : string +>"string" : string +>{ b1: { b11: "world" } } : { b1: { b11: string; }; } +>b1 : { b11: string; } +>{ b11: "world" } : { b11: string; } +>b11 : string +>"world" : string + +var temp = { t1: true, t2: "false" }; +>temp : { t1: boolean; t2: string; } +>{ t1: true, t2: "false" } : { t1: boolean; t2: string; } +>t1 : boolean +>true : boolean +>t2 : string +>"false" : string + +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +>b2 : number +>3 : number +>b3 : boolean +>true : boolean +>b4 : { t1: boolean; t2: string; } +>temp : { t1: boolean; t2: string; } +>[3, false, { t1: false, t2: "hello" }] : [number, boolean, { t1: boolean; t2: string; }] +>3 : number +>false : boolean +>{ t1: false, t2: "hello" } : { t1: boolean; t2: string; } +>t1 : boolean +>false : boolean +>t2 : string +>"hello" : string + +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +>b5 : any +>3 : number +>b6 : any +>true : boolean +>b7 : any +>temp : { t1: boolean; t2: string; } +>[undefined, undefined, undefined] : [undefined, undefined, undefined] +>undefined : undefined +>undefined : undefined +>undefined : undefined + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +>c1 : number[] +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +var [...c2] = [1,2,3, "string"]; +>c2 : (string | number)[] +>[1,2,3, "string"] : (string | number)[] +>1 : number +>2 : number +>3 : number +>"string" : string + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] +>d1 : number +>d2 : string +>[1,"string"] : [number, string] +>1 : number +>"string" : string + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +>temp1 : boolean[] +>[true, false, true] : boolean[] +>true : boolean +>false : boolean +>true : boolean + +var [d3, d4] = [1, "string", ...temp1]; +>d3 : string | number | boolean +>d4 : string | number | boolean +>[1, "string", ...temp1] : (string | number | boolean)[] +>1 : number +>"string" : string +>...temp1 : boolean +>temp1 : boolean[] + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e : any +>e1 : number +>e2 : number +>e3 : { b1: number; b4: number; } +>{ b1: 1000, b4: 200 } : { b1: number; b4: number; } +>b1 : number +>1000 : number +>b4 : number +>200 : number +>{ e: [1, 2, { b1: 4, b4: 0 }] } : { e: [number, number, { b1: number; b4: number; }]; } +>e : [number, number, { b1: number; b4: number; }] +>[1, 2, { b1: 4, b4: 0 }] : [number, number, { b1: number; b4: number; }] +>1 : number +>2 : number +>{ b1: 4, b4: 0 } : { b1: number; b4: number; } +>b1 : number +>4 : number +>b4 : number +>0 : number + +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f : any +>f1 : number +>f2 : number +>f3 : any +>f4 : number +>f5 : number +> : undefined +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; } +>f : [number, number, { f3: number; f5: number; }] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }] +>1 : number +>2 : number +>{ f3: 4, f5: 0 } : { f3: number; f5: number; } +>f3 : number +>4 : number +>f5 : number +>0 : number + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g : any +>g1 : any[] +>[undefined, null] : null[] +>undefined : undefined +>null : null +>g : { g1: any[]; } +>g1 : any[] +>{ g: { g1: [1, 2] } } : { g: { g1: number[]; }; } +>g : { g1: number[]; } +>{ g1: [1, 2] } : { g1: number[]; } +>g1 : number[] +>[1, 2] : number[] +>1 : number +>2 : number + +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h : any +>h1 : number[] +>[undefined, null] : null[] +>undefined : undefined +>null : null +>h : { h1: number[]; } +>h1 : number[] +>{ h: { h1: [1, 2] } } : { h: { h1: number[]; }; } +>h : { h1: number[]; } +>{ h1: [1, 2] } : { h1: number[]; } +>h1 : number[] +>[1, 2] : number[] +>1 : number +>2 : number + + diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.js b/tests/baselines/reference/destructuringVariableDeclaration1ES6.js new file mode 100644 index 00000000000..53b888471a1 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.js @@ -0,0 +1,77 @@ +//// [destructuringVariableDeclaration1ES6.ts] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +var temp = { t1: true, t2: "false" }; +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +var [...c2] = [1,2,3, "string"]; + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +var [d3, d4] = [1, "string", ...temp1]; + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; + + + +//// [destructuringVariableDeclaration1ES6.js] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var { a1, a2 } = { a1: 10, a2: "world" }; +var [a3, [[a4]], a5] = [1, [["hello"]], true]; +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +var temp = { t1: true, t2: "false" }; +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1, 2, 3]; +var [...c2] = [1, 2, 3, "string"]; +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1, d2] = [1, "string"]; +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true]; +var [d3, d4] = [1, "string", ...temp1]; +// Combining both forms of destructuring, +var { e: [e1, e2, e3 = { b1: 1000, b4: 200 }] } = { e: [1, 2, { b1: 4, b4: 0 }] }; +var { f: [f1, f2, { f3: f4, f5 }, ,] } = { f: [1, 2, { f3: 4, f5: 0 }] }; +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var { g: { g1 = [undefined, null] } } = { g: { g1: [1, 2] } }; +var { h: { h1 = [undefined, null] } } = { h: { h1: [1, 2] } }; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols b/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols new file mode 100644 index 00000000000..0350ff35251 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols @@ -0,0 +1,114 @@ +=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES6.ts === +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES6.ts, 2, 5)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES6.ts, 2, 8)) +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES6.ts, 2, 15)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES6.ts, 2, 27)) +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES6.ts, 2, 44)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES6.ts, 2, 52)) + +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; +>a3 : Symbol(a3, Decl(destructuringVariableDeclaration1ES6.ts, 3, 5)) +>a4 : Symbol(a4, Decl(destructuringVariableDeclaration1ES6.ts, 3, 11)) +>a5 : Symbol(a5, Decl(destructuringVariableDeclaration1ES6.ts, 3, 16)) + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 11)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 21)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 7, 44)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 50)) + +var temp = { t1: true, t2: "false" }; +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES6.ts, 8, 3)) +>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES6.ts, 8, 12)) +>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES6.ts, 8, 22)) + +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +>b2 : Symbol(b2, Decl(destructuringVariableDeclaration1ES6.ts, 9, 5)) +>b3 : Symbol(b3, Decl(destructuringVariableDeclaration1ES6.ts, 9, 12)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES6.ts, 9, 23)) +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES6.ts, 8, 3)) +>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES6.ts, 9, 49)) +>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES6.ts, 9, 60)) + +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +>b5 : Symbol(b5, Decl(destructuringVariableDeclaration1ES6.ts, 10, 5)) +>b6 : Symbol(b6, Decl(destructuringVariableDeclaration1ES6.ts, 10, 12)) +>b7 : Symbol(b7, Decl(destructuringVariableDeclaration1ES6.ts, 10, 23)) +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES6.ts, 8, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +>c1 : Symbol(c1, Decl(destructuringVariableDeclaration1ES6.ts, 15, 5)) + +var [...c2] = [1,2,3, "string"]; +>c2 : Symbol(c2, Decl(destructuringVariableDeclaration1ES6.ts, 16, 5)) + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] +>d1 : Symbol(d1, Decl(destructuringVariableDeclaration1ES6.ts, 22, 5)) +>d2 : Symbol(d2, Decl(destructuringVariableDeclaration1ES6.ts, 22, 8)) + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES6.ts, 27, 3)) + +var [d3, d4] = [1, "string", ...temp1]; +>d3 : Symbol(d3, Decl(destructuringVariableDeclaration1ES6.ts, 28, 5)) +>d4 : Symbol(d4, Decl(destructuringVariableDeclaration1ES6.ts, 28, 8)) +>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES6.ts, 27, 3)) + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES6.ts, 31, 9)) +>e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES6.ts, 31, 12)) +>e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES6.ts, 31, 16)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 31, 23)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES6.ts, 31, 33)) +>e : Symbol(e, Decl(destructuringVariableDeclaration1ES6.ts, 31, 49)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 31, 61)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES6.ts, 31, 68)) + +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES6.ts, 32, 9)) +>f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES6.ts, 32, 12)) +>f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES6.ts, 32, 18)) +>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES6.ts, 32, 26)) +>f : Symbol(f, Decl(destructuringVariableDeclaration1ES6.ts, 32, 41)) +>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES6.ts, 32, 53)) +>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES6.ts, 32, 60)) + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 9)) +>undefined : Symbol(undefined) +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES6.ts, 37, 36)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 41)) +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES6.ts, 37, 59)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 64)) + +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES6.ts, 38, 9)) +>undefined : Symbol(undefined) +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES6.ts, 38, 36)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES6.ts, 38, 41)) +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES6.ts, 38, 62)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES6.ts, 38, 67)) + + diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types new file mode 100644 index 00000000000..d62574c28f0 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -0,0 +1,200 @@ +=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES6.ts === +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +>a1 : number +>a2 : string +>a1 : number +>a2 : string +>{ a1: 10, a2: "world" } : { a1: number; a2: string; } +>a1 : number +>10 : number +>a2 : string +>"world" : string + +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; +>a3 : number +>a4 : string +>a5 : boolean +>[1, [["hello"]], true] : [number, [[string]], boolean] +>1 : number +>[["hello"]] : [[string]] +>["hello"] : [string] +>"hello" : string +>true : boolean + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b1 : any +>b11 : string +>{ b11: "string" } : { b11: string; } +>b11 : string +>"string" : string +>{ b1: { b11: "world" } } : { b1: { b11: string; }; } +>b1 : { b11: string; } +>{ b11: "world" } : { b11: string; } +>b11 : string +>"world" : string + +var temp = { t1: true, t2: "false" }; +>temp : { t1: boolean; t2: string; } +>{ t1: true, t2: "false" } : { t1: boolean; t2: string; } +>t1 : boolean +>true : boolean +>t2 : string +>"false" : string + +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +>b2 : number +>3 : number +>b3 : boolean +>true : boolean +>b4 : { t1: boolean; t2: string; } +>temp : { t1: boolean; t2: string; } +>[3, false, { t1: false, t2: "hello" }] : [number, boolean, { t1: boolean; t2: string; }] +>3 : number +>false : boolean +>{ t1: false, t2: "hello" } : { t1: boolean; t2: string; } +>t1 : boolean +>false : boolean +>t2 : string +>"hello" : string + +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +>b5 : any +>3 : number +>b6 : any +>true : boolean +>b7 : any +>temp : { t1: boolean; t2: string; } +>[undefined, undefined, undefined] : [undefined, undefined, undefined] +>undefined : undefined +>undefined : undefined +>undefined : undefined + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +>c1 : number[] +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +var [...c2] = [1,2,3, "string"]; +>c2 : (string | number)[] +>[1,2,3, "string"] : (string | number)[] +>1 : number +>2 : number +>3 : number +>"string" : string + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] +>d1 : number +>d2 : string +>[1,"string"] : [number, string] +>1 : number +>"string" : string + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +>temp1 : boolean[] +>[true, false, true] : boolean[] +>true : boolean +>false : boolean +>true : boolean + +var [d3, d4] = [1, "string", ...temp1]; +>d3 : string | number | boolean +>d4 : string | number | boolean +>[1, "string", ...temp1] : (string | number | boolean)[] +>1 : number +>"string" : string +>...temp1 : boolean +>temp1 : boolean[] + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e : any +>e1 : number +>e2 : number +>e3 : { b1: number; b4: number; } +>{ b1: 1000, b4: 200 } : { b1: number; b4: number; } +>b1 : number +>1000 : number +>b4 : number +>200 : number +>{ e: [1, 2, { b1: 4, b4: 0 }] } : { e: [number, number, { b1: number; b4: number; }]; } +>e : [number, number, { b1: number; b4: number; }] +>[1, 2, { b1: 4, b4: 0 }] : [number, number, { b1: number; b4: number; }] +>1 : number +>2 : number +>{ b1: 4, b4: 0 } : { b1: number; b4: number; } +>b1 : number +>4 : number +>b4 : number +>0 : number + +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f : any +>f1 : number +>f2 : number +>f3 : any +>f4 : number +>f5 : number +> : undefined +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; } +>f : [number, number, { f3: number; f5: number; }] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }] +>1 : number +>2 : number +>{ f3: 4, f5: 0 } : { f3: number; f5: number; } +>f3 : number +>4 : number +>f5 : number +>0 : number + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g : any +>g1 : any[] +>[undefined, null] : null[] +>undefined : undefined +>null : null +>g : { g1: any[]; } +>g1 : any[] +>{ g: { g1: [1, 2] } } : { g: { g1: number[]; }; } +>g : { g1: number[]; } +>{ g1: [1, 2] } : { g1: number[]; } +>g1 : number[] +>[1, 2] : number[] +>1 : number +>2 : number + +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h : any +>h1 : number[] +>[undefined, null] : null[] +>undefined : undefined +>null : null +>h : { h1: number[]; } +>h1 : number[] +>{ h: { h1: [1, 2] } } : { h: { h1: number[]; }; } +>h : { h1: number[]; } +>{ h1: [1, 2] } : { h1: number[]; } +>h1 : number[] +>[1, 2] : number[] +>1 : number +>2 : number + + diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt new file mode 100644 index 00000000000..1a655837743 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -0,0 +1,62 @@ +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,5): error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'. + Types of property 'a1' are incompatible. + Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. + Types of property '1' are incompatible. + Type '[[boolean]]' is not assignable to type '[[string]]'. + Types of property '0' are incompatible. + Type '[boolean]' is not assignable to type '[string]'. + Types of property '0' are incompatible. + Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(9,25): error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. + Types of property 't2' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,16): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,24): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(19,10): error TS2322: Type 'string[]' is not assignable to type 'number[]'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (6 errors) ==== + // The type T associated with a destructuring variable declaration is determined as follows: + // If the declaration includes a type annotation, T is that type. + var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error + ~~~~~~~~ +!!! error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'. +!!! error TS2322: Types of property 'a1' are incompatible. +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. +!!! error TS2322: Types of property '1' are incompatible. +!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + + // The type T associated with a destructuring variable declaration is determined as follows: + // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. + var temp = { t1: true, t2: "false" }; + var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error + ~~ +!!! error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. +!!! error TS2322: Types of property 't2' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + // The type T associated with a binding element is determined as follows: + // If the binding element is a rest element, T is an array type with + // an element type E, where E is the type of the numeric index signature of S. + var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }]; // Error + ~~ +!!! error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature. + ~~ +!!! error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature. + + // When a destructuring variable declaration, binding property, or binding element specifies + // an initializer expression, the type of the initializer expression is required to be assignable + // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. + var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error + ~~ +!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.js b/tests/baselines/reference/destructuringVariableDeclaration2.js new file mode 100644 index 00000000000..a4fadd850d7 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration2.js @@ -0,0 +1,38 @@ +//// [destructuringVariableDeclaration2.ts] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var temp = { t1: true, t2: "false" }; +var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }]; // Error + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error + +//// [destructuringVariableDeclaration2.js] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var _a = { a1: true, a2: 1 }, a1 = _a.a1, a2 = _a.a2; // Error +var _b = [1, [[false]], true], a3 = _b[0], a4 = _b[1][0][0], a5 = _b[2]; // Error +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var temp = { t1: true, t2: "false" }; +var _c = [3, false, { t1: false, t2: 5 }], _d = _c[0], b0 = _d === void 0 ? 3 : _d, _e = _c[1], b1 = _e === void 0 ? true : _e, _f = _c[2], b2 = _f === void 0 ? temp : _f; // Error +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var _g = [1, 2, { c3: 4, c5: 0 }], c1 = _g[0], c2 = _g[1], _h = _g[2], c4 = _h.c3, c5 = _h.c5, c6 = _g.slice(4); // Error +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var _j = { d: { d1: [1, 2] } }.d.d1, d1 = _j === void 0 ? ["string", null] : _j; // Error diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt b/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt index b9890e925c4..68ea92f8fb5 100644 --- a/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt @@ -1,15 +1,21 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(4,6): error TS2456: Type alias 'T0' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(5,6): error TS2456: Type alias 'T0_1' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(6,6): error TS2456: Type alias 'T0_2' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(7,6): error TS2456: Type alias 'T0_3' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(11,6): error TS2456: Type alias 'T1' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(14,6): error TS2456: Type alias 'T2' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(16,6): error TS2456: Type alias 'T2_1' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(19,6): error TS2456: Type alias 'T3' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(22,6): error TS2456: Type alias 'T4' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(25,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(26,6): error TS2456: Type alias 'T5' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(29,6): error TS2456: Type alias 'T6' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(30,6): error TS2456: Type alias 'T7' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(31,5): error TS2502: 'yy' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(32,6): error TS2456: Type alias 'T8' circularly references itself. -==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (9 errors) ==== +==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (15 errors) ==== // It is an error for the type specified in a type alias to depend on that type alias // A type alias directly depends on the type it aliases. @@ -17,10 +23,14 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts( ~~ !!! error TS2456: Type alias 'T0' circularly references itself. type T0_1 = T0_2 + ~~~~ +!!! error TS2456: Type alias 'T0_1' circularly references itself. type T0_2 = T0_3 ~~~~ !!! error TS2456: Type alias 'T0_2' circularly references itself. type T0_3 = T0_1 + ~~~~ +!!! error TS2456: Type alias 'T0_3' circularly references itself. // A type reference directly depends on the referenced type and each of the type arguments, if any. interface I {} @@ -49,17 +59,25 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts( // A type query directly depends on the type of the referenced entity. var x: T5[] = [] + ~ +!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. type T5 = typeof x ~~ !!! error TS2456: Type alias 'T5' circularly references itself. class C1 {} type T6 = T7 | number + ~~ +!!! error TS2456: Type alias 'T6' circularly references itself. type T7 = typeof yy ~~ !!! error TS2456: Type alias 'T7' circularly references itself. var yy: [string, T8[]]; + ~~ +!!! error TS2502: 'yy' is referenced directly or indirectly in its own type annotation. type T8 = C + ~~ +!!! error TS2456: Type alias 'T8' circularly references itself. // legal cases type T9 = () => T9 diff --git a/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration1.errors.txt b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration1.errors.txt new file mode 100644 index 00000000000..d210588234d --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration1.errors.txt @@ -0,0 +1,75 @@ +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,13): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,17): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,21): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,27): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(3,14): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(3,17): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(4,14): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(4,19): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(5,14): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(5,17): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(5,22): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(6,14): error TS2300: Duplicate identifier 'd'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(6,20): error TS2300: Duplicate identifier 'd'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,14): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,21): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,27): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,34): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,39): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,48): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(8,14): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(8,20): error TS2300: Duplicate identifier 'f'. + + +==== tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts (21 errors) ==== + + function f0(a, [a, [b]], {b}) { } + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + function f1([a, a]) { } + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'a'. + function f2({b}, {b}) { } + ~ +!!! error TS2300: Duplicate identifier 'b'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + function f3([c,[c],[[c]]]) { } + ~ +!!! error TS2300: Duplicate identifier 'c'. + ~ +!!! error TS2300: Duplicate identifier 'c'. + ~ +!!! error TS2300: Duplicate identifier 'c'. + function f4({d, d:{d}}) { } + ~ +!!! error TS2300: Duplicate identifier 'd'. + ~ +!!! error TS2300: Duplicate identifier 'd'. + function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { } + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + function f6([f, ...f]) { } + ~ +!!! error TS2300: Duplicate identifier 'f'. + ~ +!!! error TS2300: Duplicate identifier 'f'. + function f7(a, func = (a) => { return 1 }) { } // not error \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration1.js b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration1.js new file mode 100644 index 00000000000..0c1eb5f3210 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration1.js @@ -0,0 +1,44 @@ +//// [duplicateIdentifierBindingElementInParameterDeclaration1.ts] + +function f0(a, [a, [b]], {b}) { } +function f1([a, a]) { } +function f2({b}, {b}) { } +function f3([c,[c],[[c]]]) { } +function f4({d, d:{d}}) { } +function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { } +function f6([f, ...f]) { } +function f7(a, func = (a) => { return 1 }) { } // not error + +//// [duplicateIdentifierBindingElementInParameterDeclaration1.js] +function f0(a, _a, _b) { + var a = _a[0], b = _a[1][0]; + var b = _b.b; +} +function f1(_a) { + var a = _a[0], a = _a[1]; +} +function f2(_a, _b) { + var b = _a.b; + var b = _b.b; +} +function f3(_a) { + var c = _a[0], c = _a[1][0], c = _a[2][0][0]; +} +function f4(_a) { + var d = _a.d, d = _a.d.d; +} +function f5(_a, _b, _c) { + var e = _a.e, e = _a.e.e; + var e = _b.e; + var d = _c[0], e = _c[1], e = _c[2][0][0]; + var e = []; + for (var _i = 3; _i < arguments.length; _i++) { + e[_i - 3] = arguments[_i]; + } +} +function f6(_a) { + var f = _a[0], f = _a.slice(1); +} +function f7(a, func) { + if (func === void 0) { func = function (a) { return 1; }; } +} // not error diff --git a/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration2.errors.txt b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration2.errors.txt new file mode 100644 index 00000000000..e3d1dc621f8 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration2.errors.txt @@ -0,0 +1,76 @@ +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,13): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,17): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,21): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,27): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(4,14): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(4,17): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(5,14): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(5,19): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(6,14): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(6,18): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(6,24): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(7,14): error TS2300: Duplicate identifier 'd'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(7,21): error TS2300: Duplicate identifier 'd'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,14): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,21): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,27): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,35): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,40): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,49): error TS2300: Duplicate identifier 'e'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(9,14): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(9,20): error TS2300: Duplicate identifier 'f'. + + +==== tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts (21 errors) ==== + + "use strict" + function f0(a, [a, [b]], {b}) { } + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + function f1([a, a]) { } + ~ +!!! error TS2300: Duplicate identifier 'a'. + ~ +!!! error TS2300: Duplicate identifier 'a'. + function f2({b}, {b}) { } + ~ +!!! error TS2300: Duplicate identifier 'b'. + ~ +!!! error TS2300: Duplicate identifier 'b'. + function f3([c, [c], [[c]]]) { } + ~ +!!! error TS2300: Duplicate identifier 'c'. + ~ +!!! error TS2300: Duplicate identifier 'c'. + ~ +!!! error TS2300: Duplicate identifier 'c'. + function f4({d, d: {d}}) { } + ~ +!!! error TS2300: Duplicate identifier 'd'. + ~ +!!! error TS2300: Duplicate identifier 'd'. + function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { } + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + ~ +!!! error TS2300: Duplicate identifier 'e'. + function f6([f, ...f]) { } + ~ +!!! error TS2300: Duplicate identifier 'f'. + ~ +!!! error TS2300: Duplicate identifier 'f'. + function f7(a, func = (a) => { return 1 }){ } // not error \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration2.js b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration2.js new file mode 100644 index 00000000000..e423b035d9d --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierBindingElementInParameterDeclaration2.js @@ -0,0 +1,46 @@ +//// [duplicateIdentifierBindingElementInParameterDeclaration2.ts] + +"use strict" +function f0(a, [a, [b]], {b}) { } +function f1([a, a]) { } +function f2({b}, {b}) { } +function f3([c, [c], [[c]]]) { } +function f4({d, d: {d}}) { } +function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { } +function f6([f, ...f]) { } +function f7(a, func = (a) => { return 1 }){ } // not error + +//// [duplicateIdentifierBindingElementInParameterDeclaration2.js] +"use strict"; +function f0(a, _a, _b) { + var a = _a[0], b = _a[1][0]; + var b = _b.b; +} +function f1(_a) { + var a = _a[0], a = _a[1]; +} +function f2(_a, _b) { + var b = _a.b; + var b = _b.b; +} +function f3(_a) { + var c = _a[0], c = _a[1][0], c = _a[2][0][0]; +} +function f4(_a) { + var d = _a.d, d = _a.d.d; +} +function f5(_a, _b, _c) { + var e = _a.e, e = _a.e.e; + var e = _b.e; + var d = _c[0], e = _c[1], e = _c[2][0][0]; + var e = []; + for (var _i = 3; _i < arguments.length; _i++) { + e[_i - 3] = arguments[_i]; + } +} +function f6(_a) { + var f = _a[0], f = _a.slice(1); +} +function f7(a, func) { + if (func === void 0) { func = function (a) { return 1; }; } +} // not error diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 623cc4c9690..18e1063f1e6 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index d140c21284c..6885b359416 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index e970b527d56..ae6be6f7951 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index 8612e0896d1..c8bf211897a 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 96f9712635c..cc867dd2c72 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.js b/tests/baselines/reference/emitThisInSuperMethodCall.js index de47b0b95af..9224e156de9 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.js +++ b/tests/baselines/reference/emitThisInSuperMethodCall.js @@ -28,7 +28,7 @@ class RegisteredUser extends User { //// [emitThisInSuperMethodCall.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/emptyFile-declaration.js b/tests/baselines/reference/emptyFile-declaration.js index 83f47258925..f395099d73c 100644 --- a/tests/baselines/reference/emptyFile-declaration.js +++ b/tests/baselines/reference/emptyFile-declaration.js @@ -2,6 +2,6 @@ //// [emptyFile-declaration.js] -//# sourceMappingURL=emptyFile-declaration.js.map + //// [emptyFile-declaration.d.ts] diff --git a/tests/baselines/reference/emptyFile-declaration.js.map b/tests/baselines/reference/emptyFile-declaration.js.map deleted file mode 100644 index 2b96d268327..00000000000 --- a/tests/baselines/reference/emptyFile-declaration.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [emptyFile-declaration.js.map] -{"version":3,"file":"emptyFile-declaration.js","sourceRoot":"","sources":["emptyFile-declaration.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/emptyFile-declaration.sourcemap.txt b/tests/baselines/reference/emptyFile-declaration.sourcemap.txt deleted file mode 100644 index 027af4c7ba0..00000000000 --- a/tests/baselines/reference/emptyFile-declaration.sourcemap.txt +++ /dev/null @@ -1,7 +0,0 @@ -=================================================================== -JsFile: emptyFile-declaration.js -mapUrl: emptyFile-declaration.js.map -sourceRoot: -sources: emptyFile-declaration.ts -=================================================================== ->>>//# sourceMappingURL=emptyFile-declaration.js.map \ No newline at end of file diff --git a/tests/baselines/reference/emptyFile-souremap.js b/tests/baselines/reference/emptyFile-souremap.js index 677037d8689..6de7361731a 100644 --- a/tests/baselines/reference/emptyFile-souremap.js +++ b/tests/baselines/reference/emptyFile-souremap.js @@ -2,6 +2,4 @@ //// [emptyFile-souremap.js] -//# sourceMappingURL=emptyFile-souremap.js.map - -//// [emptyFile-souremap.d.ts] +//# sourceMappingURL=emptyFile-souremap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js index 5bfa3b38e83..f1a0d741a5c 100644 --- a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js +++ b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js @@ -12,7 +12,7 @@ class derived extends base { } //// [errorForwardReferenceForwadingConstructor.js] // Error forward referencing derived class with forwarding constructor -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/errorSuperCalls.js b/tests/baselines/reference/errorSuperCalls.js index 4e0f84656fd..bd692f35fa3 100644 --- a/tests/baselines/reference/errorSuperCalls.js +++ b/tests/baselines/reference/errorSuperCalls.js @@ -75,7 +75,7 @@ class OtherDerived extends OtherBase { //// [errorSuperCalls.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index 26ef99f269d..abf077d2b82 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -129,7 +129,7 @@ var obj = { n: super.wat, p: super.foo() }; //// [errorSuperPropertyAccess.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/errorsInGenericTypeReference.js b/tests/baselines/reference/errorsInGenericTypeReference.js index 03bf31a6a6b..0ba69b601ae 100644 --- a/tests/baselines/reference/errorsInGenericTypeReference.js +++ b/tests/baselines/reference/errorsInGenericTypeReference.js @@ -73,7 +73,7 @@ interface testInterface2 { //// [errorsInGenericTypeReference.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/es3-amd.js b/tests/baselines/reference/es3-amd.js index 4e9fcdf7a9e..03d4a53e9c5 100644 --- a/tests/baselines/reference/es3-amd.js +++ b/tests/baselines/reference/es3-amd.js @@ -22,10 +22,3 @@ var A = (function () { }; return A; })(); -//# sourceMappingURL=es3-amd.js.map - -//// [es3-amd.d.ts] -declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es3-amd.js.map b/tests/baselines/reference/es3-amd.js.map deleted file mode 100644 index a1ccff476c6..00000000000 --- a/tests/baselines/reference/es3-amd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es3-amd.js.map] -{"version":3,"file":"es3-amd.js","sourceRoot":"","sources":["es3-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es3-amd.sourcemap.txt b/tests/baselines/reference/es3-amd.sourcemap.txt deleted file mode 100644 index 86ef55a1f58..00000000000 --- a/tests/baselines/reference/es3-amd.sourcemap.txt +++ /dev/null @@ -1,115 +0,0 @@ -=================================================================== -JsFile: es3-amd.js -mapUrl: es3-amd.js.map -sourceRoot: -sources: es3-amd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es3-amd.js -sourceFile:es3-amd.ts -------------------------------------------------------------------- ->>>var A = (function () { -1 > -2 >^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=es3-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es3-declaration-amd.js b/tests/baselines/reference/es3-declaration-amd.js index 2b4995d8544..12dd009cc0e 100644 --- a/tests/baselines/reference/es3-declaration-amd.js +++ b/tests/baselines/reference/es3-declaration-amd.js @@ -22,7 +22,7 @@ var A = (function () { }; return A; })(); -//# sourceMappingURL=es3-declaration-amd.js.map + //// [es3-declaration-amd.d.ts] declare class A { diff --git a/tests/baselines/reference/es3-declaration-amd.js.map b/tests/baselines/reference/es3-declaration-amd.js.map deleted file mode 100644 index 612763299c9..00000000000 --- a/tests/baselines/reference/es3-declaration-amd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es3-declaration-amd.js.map] -{"version":3,"file":"es3-declaration-amd.js","sourceRoot":"","sources":["es3-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es3-declaration-amd.sourcemap.txt b/tests/baselines/reference/es3-declaration-amd.sourcemap.txt deleted file mode 100644 index 7ad6f48d3ad..00000000000 --- a/tests/baselines/reference/es3-declaration-amd.sourcemap.txt +++ /dev/null @@ -1,115 +0,0 @@ -=================================================================== -JsFile: es3-declaration-amd.js -mapUrl: es3-declaration-amd.js.map -sourceRoot: -sources: es3-declaration-amd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es3-declaration-amd.js -sourceFile:es3-declaration-amd.ts -------------------------------------------------------------------- ->>>var A = (function () { -1 > -2 >^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=es3-declaration-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-amd.js b/tests/baselines/reference/es5-amd.js index cef85a00744..e33fecaed64 100644 --- a/tests/baselines/reference/es5-amd.js +++ b/tests/baselines/reference/es5-amd.js @@ -22,10 +22,3 @@ var A = (function () { }; return A; })(); -//# sourceMappingURL=es5-amd.js.map - -//// [es5-amd.d.ts] -declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es5-amd.js.map b/tests/baselines/reference/es5-amd.js.map deleted file mode 100644 index 6201673cb34..00000000000 --- a/tests/baselines/reference/es5-amd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es5-amd.js.map] -{"version":3,"file":"es5-amd.js","sourceRoot":"","sources":["es5-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-amd.sourcemap.txt b/tests/baselines/reference/es5-amd.sourcemap.txt deleted file mode 100644 index a5902f03982..00000000000 --- a/tests/baselines/reference/es5-amd.sourcemap.txt +++ /dev/null @@ -1,115 +0,0 @@ -=================================================================== -JsFile: es5-amd.js -mapUrl: es5-amd.js.map -sourceRoot: -sources: es5-amd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es5-amd.js -sourceFile:es5-amd.ts -------------------------------------------------------------------- ->>>var A = (function () { -1 > -2 >^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=es5-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-declaration-amd.js b/tests/baselines/reference/es5-declaration-amd.js index d942382ff2e..e180e88d514 100644 --- a/tests/baselines/reference/es5-declaration-amd.js +++ b/tests/baselines/reference/es5-declaration-amd.js @@ -22,7 +22,7 @@ var A = (function () { }; return A; })(); -//# sourceMappingURL=es5-declaration-amd.js.map + //// [es5-declaration-amd.d.ts] declare class A { diff --git a/tests/baselines/reference/es5-declaration-amd.js.map b/tests/baselines/reference/es5-declaration-amd.js.map deleted file mode 100644 index d4dfe8ac244..00000000000 --- a/tests/baselines/reference/es5-declaration-amd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es5-declaration-amd.js.map] -{"version":3,"file":"es5-declaration-amd.js","sourceRoot":"","sources":["es5-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-declaration-amd.sourcemap.txt b/tests/baselines/reference/es5-declaration-amd.sourcemap.txt deleted file mode 100644 index 59b6ba6bb0a..00000000000 --- a/tests/baselines/reference/es5-declaration-amd.sourcemap.txt +++ /dev/null @@ -1,115 +0,0 @@ -=================================================================== -JsFile: es5-declaration-amd.js -mapUrl: es5-declaration-amd.js.map -sourceRoot: -sources: es5-declaration-amd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es5-declaration-amd.js -sourceFile:es5-declaration-amd.ts -------------------------------------------------------------------- ->>>var A = (function () { -1 > -2 >^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=es5-declaration-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd.js b/tests/baselines/reference/es5-umd.js index 0175e8e9fe8..8c68092cbc6 100644 --- a/tests/baselines/reference/es5-umd.js +++ b/tests/baselines/reference/es5-umd.js @@ -23,10 +23,3 @@ var A = (function () { }; return A; })(); -//# sourceMappingURL=es5-umd.js.map - -//// [es5-umd.d.ts] -declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es5-umd.js.map b/tests/baselines/reference/es5-umd.js.map deleted file mode 100644 index 5e29a48796e..00000000000 --- a/tests/baselines/reference/es5-umd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es5-umd.js.map] -{"version":3,"file":"es5-umd.js","sourceRoot":"","sources":["es5-umd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd.sourcemap.txt b/tests/baselines/reference/es5-umd.sourcemap.txt deleted file mode 100644 index bdbdec5fa9e..00000000000 --- a/tests/baselines/reference/es5-umd.sourcemap.txt +++ /dev/null @@ -1,115 +0,0 @@ -=================================================================== -JsFile: es5-umd.js -mapUrl: es5-umd.js.map -sourceRoot: -sources: es5-umd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es5-umd.js -sourceFile:es5-umd.ts -------------------------------------------------------------------- ->>>var A = (function () { -1 > -2 >^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=es5-umd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd2.js b/tests/baselines/reference/es5-umd2.js index cb0265bf92f..4267e7a3331 100644 --- a/tests/baselines/reference/es5-umd2.js +++ b/tests/baselines/reference/es5-umd2.js @@ -33,10 +33,3 @@ export class A })(); exports.A = A; }); -//# sourceMappingURL=es5-umd2.js.map - -//// [es5-umd2.d.ts] -export declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es5-umd2.js.map b/tests/baselines/reference/es5-umd2.js.map deleted file mode 100644 index 13a785b2edc..00000000000 --- a/tests/baselines/reference/es5-umd2.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es5-umd2.js.map] -{"version":3,"file":"es5-umd2.js","sourceRoot":"","sources":["es5-umd2.ts"],"names":["A","A.constructor","A.B"],"mappings":";;;;;;;;IACA;QAEIA;QAGAC,CAACA;QAEMD,aAACA,GAARA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;QACLF,QAACA;IAADA,CAACA,AAXD,IAWC;IAXY,SAAC,IAWb,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd2.sourcemap.txt b/tests/baselines/reference/es5-umd2.sourcemap.txt deleted file mode 100644 index bfadd9615f3..00000000000 --- a/tests/baselines/reference/es5-umd2.sourcemap.txt +++ /dev/null @@ -1,149 +0,0 @@ -=================================================================== -JsFile: es5-umd2.js -mapUrl: es5-umd2.js.map -sourceRoot: -sources: es5-umd2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es5-umd2.js -sourceFile:es5-umd2.ts -------------------------------------------------------------------- ->>>(function (deps, factory) { ->>> if (typeof module === 'object' && typeof module.exports === 'object') { ->>> var v = factory(require, exports); if (v !== undefined) module.exports = v; ->>> } ->>> else if (typeof define === 'function' && define.amd) { ->>> define(deps, factory); ->>> } ->>>})(["require", "exports"], function (require, exports) { ->>> var A = (function () { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^ -2 > ^^-> -1->export class A - >{ - > -1->Emitted(10, 9) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(11, 9) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(11, 10) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(12, 9) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(12, 22) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(12, 25) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(13, 13) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(13, 19) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(13, 20) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(13, 22) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(13, 23) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(14, 9) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(14, 10) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(15, 9) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(15, 17) Source(13, 2) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(16, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(16, 6) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(16, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(16, 10) Source(13, 2) + SourceIndex(0) ---- ->>> exports.A = A; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > A -3 > - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -4 > -1->Emitted(17, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(17, 14) Source(2, 15) + SourceIndex(0) -3 >Emitted(17, 18) Source(13, 2) + SourceIndex(0) -4 >Emitted(17, 19) Source(13, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=es5-umd2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd3.js b/tests/baselines/reference/es5-umd3.js index 2d18e2eecc3..3abb92f816f 100644 --- a/tests/baselines/reference/es5-umd3.js +++ b/tests/baselines/reference/es5-umd3.js @@ -33,10 +33,3 @@ export default class A })(); exports.default = A; }); -//# sourceMappingURL=es5-umd3.js.map - -//// [es5-umd3.d.ts] -export default class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es5-umd3.js.map b/tests/baselines/reference/es5-umd3.js.map deleted file mode 100644 index 8b955f11936..00000000000 --- a/tests/baselines/reference/es5-umd3.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es5-umd3.js.map] -{"version":3,"file":"es5-umd3.js","sourceRoot":"","sources":["es5-umd3.ts"],"names":["A","A.constructor","A.B"],"mappings":";;;;;;;;IACA;QAEIA;QAGAC,CAACA;QAEMD,aAACA,GAARA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;QACLF,QAACA;IAADA,CAACA,AAXD,IAWC;IAXD,mBAWC,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd3.sourcemap.txt b/tests/baselines/reference/es5-umd3.sourcemap.txt deleted file mode 100644 index afb879ac713..00000000000 --- a/tests/baselines/reference/es5-umd3.sourcemap.txt +++ /dev/null @@ -1,146 +0,0 @@ -=================================================================== -JsFile: es5-umd3.js -mapUrl: es5-umd3.js.map -sourceRoot: -sources: es5-umd3.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es5-umd3.js -sourceFile:es5-umd3.ts -------------------------------------------------------------------- ->>>(function (deps, factory) { ->>> if (typeof module === 'object' && typeof module.exports === 'object') { ->>> var v = factory(require, exports); if (v !== undefined) module.exports = v; ->>> } ->>> else if (typeof define === 'function' && define.amd) { ->>> define(deps, factory); ->>> } ->>>})(["require", "exports"], function (require, exports) { ->>> var A = (function () { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^ -2 > ^^-> -1->export default class A - >{ - > -1->Emitted(10, 9) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(11, 9) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(11, 10) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(12, 9) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(12, 22) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(12, 25) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(13, 13) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(13, 19) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(13, 20) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(13, 22) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(13, 23) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(14, 9) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(14, 10) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(15, 9) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(15, 17) Source(13, 2) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export default class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(16, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(16, 6) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(16, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(16, 10) Source(13, 2) + SourceIndex(0) ---- ->>> exports.default = A; -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^ -1-> -2 > export default class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -3 > -1->Emitted(17, 5) Source(2, 1) + SourceIndex(0) -2 >Emitted(17, 24) Source(13, 2) + SourceIndex(0) -3 >Emitted(17, 25) Source(13, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=es5-umd3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd4.js b/tests/baselines/reference/es5-umd4.js index 85683f8f3c2..058ad545f42 100644 --- a/tests/baselines/reference/es5-umd4.js +++ b/tests/baselines/reference/es5-umd4.js @@ -35,11 +35,3 @@ export = A; })(); return A; }); -//# sourceMappingURL=es5-umd4.js.map - -//// [es5-umd4.d.ts] -declare class A { - constructor(); - B(): number; -} -export = A; diff --git a/tests/baselines/reference/es5-umd4.js.map b/tests/baselines/reference/es5-umd4.js.map deleted file mode 100644 index 0a47d679ed9..00000000000 --- a/tests/baselines/reference/es5-umd4.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es5-umd4.js.map] -{"version":3,"file":"es5-umd4.js","sourceRoot":"","sources":["es5-umd4.ts"],"names":["A","A.constructor","A.B"],"mappings":";;;;;;;;IACA;QAEIA;QAGAC,CAACA;QAEMD,aAACA,GAARA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;QACLF,QAACA;IAADA,CAACA,AAXD,IAWC;IAEU,AAAX,OAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd4.sourcemap.txt b/tests/baselines/reference/es5-umd4.sourcemap.txt deleted file mode 100644 index 9afd8effecf..00000000000 --- a/tests/baselines/reference/es5-umd4.sourcemap.txt +++ /dev/null @@ -1,143 +0,0 @@ -=================================================================== -JsFile: es5-umd4.js -mapUrl: es5-umd4.js.map -sourceRoot: -sources: es5-umd4.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es5-umd4.js -sourceFile:es5-umd4.ts -------------------------------------------------------------------- ->>>(function (deps, factory) { ->>> if (typeof module === 'object' && typeof module.exports === 'object') { ->>> var v = factory(require, exports); if (v !== undefined) module.exports = v; ->>> } ->>> else if (typeof define === 'function' && define.amd) { ->>> define(deps, factory); ->>> } ->>>})(["require", "exports"], function (require, exports) { ->>> var A = (function () { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(10, 9) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(11, 9) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(11, 10) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> A.prototype.B = function () { -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -1-> - > - > public -2 > B -3 > -1->Emitted(12, 9) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(12, 22) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(12, 25) Source(9, 5) + SourceIndex(0) name (A) ---- ->>> return 42; -1 >^^^^^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1 >public B() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1 >Emitted(13, 13) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(13, 19) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(13, 20) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(13, 22) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(13, 23) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> }; -1 >^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(14, 9) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(14, 10) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>> return A; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(15, 9) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(15, 17) Source(13, 2) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^-> -1 > -2 > } -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(16, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(16, 6) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(16, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(16, 10) Source(13, 2) + SourceIndex(0) ---- ->>> return A; -1->^^^^ -2 > -3 > ^^^^^^^ -4 > ^ -5 > ^ -1-> - > - >export = A; -2 > -3 > export = -4 > A -5 > ; -1->Emitted(17, 5) Source(15, 12) + SourceIndex(0) -2 >Emitted(17, 5) Source(15, 1) + SourceIndex(0) -3 >Emitted(17, 12) Source(15, 10) + SourceIndex(0) -4 >Emitted(17, 13) Source(15, 11) + SourceIndex(0) -5 >Emitted(17, 14) Source(15, 12) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=es5-umd4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.js b/tests/baselines/reference/es6-amd.js index 74f3037303e..b09f074e59f 100644 --- a/tests/baselines/reference/es6-amd.js +++ b/tests/baselines/reference/es6-amd.js @@ -21,10 +21,3 @@ class A { return 42; } } -//# sourceMappingURL=es6-amd.js.map - -//// [es6-amd.d.ts] -declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es6-amd.js.map b/tests/baselines/reference/es6-amd.js.map deleted file mode 100644 index fe234f8424b..00000000000 --- a/tests/baselines/reference/es6-amd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es6-amd.js.map] -{"version":3,"file":"es6-amd.js","sourceRoot":"","sources":["es6-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.sourcemap.txt b/tests/baselines/reference/es6-amd.sourcemap.txt deleted file mode 100644 index 1ab547073c6..00000000000 --- a/tests/baselines/reference/es6-amd.sourcemap.txt +++ /dev/null @@ -1,91 +0,0 @@ -=================================================================== -JsFile: es6-amd.js -mapUrl: es6-amd.js.map -sourceRoot: -sources: es6-amd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es6-amd.js -sourceFile:es6-amd.ts -------------------------------------------------------------------- ->>>class A { -1 > -2 >^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> constructor() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> B() { -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^-> -1-> - > - > public -2 > B -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) ---- ->>> return 42; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1->() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> } -1 >^^^^ -2 > ^ -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>//# sourceMappingURL=es6-amd.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) ---- \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.js b/tests/baselines/reference/es6-declaration-amd.js index aeba23e0b6e..b1f54086969 100644 --- a/tests/baselines/reference/es6-declaration-amd.js +++ b/tests/baselines/reference/es6-declaration-amd.js @@ -21,7 +21,7 @@ class A { return 42; } } -//# sourceMappingURL=es6-declaration-amd.js.map + //// [es6-declaration-amd.d.ts] declare class A { diff --git a/tests/baselines/reference/es6-declaration-amd.js.map b/tests/baselines/reference/es6-declaration-amd.js.map deleted file mode 100644 index ca1899e03f5..00000000000 --- a/tests/baselines/reference/es6-declaration-amd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es6-declaration-amd.js.map] -{"version":3,"file":"es6-declaration-amd.js","sourceRoot":"","sources":["es6-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt deleted file mode 100644 index 9061bc1ed7c..00000000000 --- a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt +++ /dev/null @@ -1,91 +0,0 @@ -=================================================================== -JsFile: es6-declaration-amd.js -mapUrl: es6-declaration-amd.js.map -sourceRoot: -sources: es6-declaration-amd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es6-declaration-amd.js -sourceFile:es6-declaration-amd.ts -------------------------------------------------------------------- ->>>class A { -1 > -2 >^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> constructor() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> B() { -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^-> -1-> - > - > public -2 > B -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) ---- ->>> return 42; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1->() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> } -1 >^^^^ -2 > ^ -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>//# sourceMappingURL=es6-declaration-amd.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) ---- \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd.js b/tests/baselines/reference/es6-umd.js index 74cd671f5ef..af8159eeb3e 100644 --- a/tests/baselines/reference/es6-umd.js +++ b/tests/baselines/reference/es6-umd.js @@ -21,10 +21,3 @@ class A { return 42; } } -//# sourceMappingURL=es6-umd.js.map - -//// [es6-umd.d.ts] -declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es6-umd.js.map b/tests/baselines/reference/es6-umd.js.map deleted file mode 100644 index a5e82f7ccfd..00000000000 --- a/tests/baselines/reference/es6-umd.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es6-umd.js.map] -{"version":3,"file":"es6-umd.js","sourceRoot":"","sources":["es6-umd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd.sourcemap.txt b/tests/baselines/reference/es6-umd.sourcemap.txt deleted file mode 100644 index bb8281ce741..00000000000 --- a/tests/baselines/reference/es6-umd.sourcemap.txt +++ /dev/null @@ -1,91 +0,0 @@ -=================================================================== -JsFile: es6-umd.js -mapUrl: es6-umd.js.map -sourceRoot: -sources: es6-umd.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es6-umd.js -sourceFile:es6-umd.ts -------------------------------------------------------------------- ->>>class A { -1 > -2 >^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> constructor() { -1->^^^^ -2 > ^^-> -1->class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> B() { -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^-> -1-> - > - > public -2 > B -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) ---- ->>> return 42; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1->() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> } -1 >^^^^ -2 > ^ -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>//# sourceMappingURL=es6-umd.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) ---- \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.js b/tests/baselines/reference/es6-umd2.js index b12d35aacf8..416932d89bc 100644 --- a/tests/baselines/reference/es6-umd2.js +++ b/tests/baselines/reference/es6-umd2.js @@ -21,10 +21,3 @@ export class A { return 42; } } -//# sourceMappingURL=es6-umd2.js.map - -//// [es6-umd2.d.ts] -export declare class A { - constructor(); - B(): number; -} diff --git a/tests/baselines/reference/es6-umd2.js.map b/tests/baselines/reference/es6-umd2.js.map deleted file mode 100644 index 81f3d85a6cd..00000000000 --- a/tests/baselines/reference/es6-umd2.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [es6-umd2.js.map] -{"version":3,"file":"es6-umd2.js","sourceRoot":"","sources":["es6-umd2.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.sourcemap.txt b/tests/baselines/reference/es6-umd2.sourcemap.txt deleted file mode 100644 index d032aa3d6c7..00000000000 --- a/tests/baselines/reference/es6-umd2.sourcemap.txt +++ /dev/null @@ -1,91 +0,0 @@ -=================================================================== -JsFile: es6-umd2.js -mapUrl: es6-umd2.js.map -sourceRoot: -sources: es6-umd2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/es6-umd2.js -sourceFile:es6-umd2.ts -------------------------------------------------------------------- ->>>export class A { -1 > -2 >^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) ---- ->>> constructor() { -1->^^^^ -2 > ^^-> -1->export class A - >{ - > -1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^-> -1->constructor () - > { - > - > -2 > } -1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) -2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) ---- ->>> B() { -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^-> -1-> - > - > public -2 > B -1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) ---- ->>> return 42; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -1->() - > { - > -2 > return -3 > -4 > 42 -5 > ; -1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) -2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) -3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) -4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) -5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) ---- ->>> } -1 >^^^^ -2 > ^ -1 > - > -2 > } -1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) -2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>//# sourceMappingURL=es6-umd2.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) ---- \ No newline at end of file diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.js b/tests/baselines/reference/es6ClassSuperCodegenBug.js index c5d668c2f3d..a374778ef45 100644 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.js +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.js @@ -14,7 +14,7 @@ class B extends A { //// [es6ClassSuperCodegenBug.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js index 08c184a0df2..bf65840e31c 100644 --- a/tests/baselines/reference/es6ClassTest.js +++ b/tests/baselines/reference/es6ClassTest.js @@ -85,7 +85,7 @@ declare module AmbientMod { //// [es6ClassTest.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/es6ClassTest2.js b/tests/baselines/reference/es6ClassTest2.js index f23be04fd17..40f1c15c8f1 100644 --- a/tests/baselines/reference/es6ClassTest2.js +++ b/tests/baselines/reference/es6ClassTest2.js @@ -159,7 +159,7 @@ var ccwc = new ChildClassWithoutConstructor(1, "s"); //// [es6ClassTest2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/es6ClassTest7.js b/tests/baselines/reference/es6ClassTest7.js index 728b4d0a404..c4f7e83b9a2 100644 --- a/tests/baselines/reference/es6ClassTest7.js +++ b/tests/baselines/reference/es6ClassTest7.js @@ -9,7 +9,7 @@ class Bar extends M.Foo { //// [es6ClassTest7.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.js b/tests/baselines/reference/exportAssignmentOfGenericType1.js index 0b8c4f2596c..983c328cd98 100644 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.js +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.js @@ -23,7 +23,7 @@ define(["require", "exports"], function (require, exports) { return T; }); //// [exportAssignmentOfGenericType1_1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/exportDeclarationInInternalModule.js b/tests/baselines/reference/exportDeclarationInInternalModule.js index 97011f2425f..9894f1fb194 100644 --- a/tests/baselines/reference/exportDeclarationInInternalModule.js +++ b/tests/baselines/reference/exportDeclarationInInternalModule.js @@ -19,7 +19,7 @@ var a: Bbb.SomeType; //// [exportDeclarationInInternalModule.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/exportDefaultVariable.js b/tests/baselines/reference/exportDefaultVariable.js new file mode 100644 index 00000000000..beb8bb84a80 --- /dev/null +++ b/tests/baselines/reference/exportDefaultVariable.js @@ -0,0 +1,12 @@ +//// [exportDefaultVariable.ts] +// Regression test for #3018 + +declare var io: any; + +declare module 'module' { + export default io; +} + + +//// [exportDefaultVariable.js] +// Regression test for #3018 diff --git a/tests/baselines/reference/exportDefaultVariable.symbols b/tests/baselines/reference/exportDefaultVariable.symbols new file mode 100644 index 00000000000..cd7ebed926c --- /dev/null +++ b/tests/baselines/reference/exportDefaultVariable.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/exportDefaultVariable.ts === +// Regression test for #3018 + +declare var io: any; +>io : Symbol(io, Decl(exportDefaultVariable.ts, 2, 11)) + +declare module 'module' { + export default io; +>io : Symbol(default, Decl(exportDefaultVariable.ts, 2, 11)) +} + diff --git a/tests/baselines/reference/exportDefaultVariable.types b/tests/baselines/reference/exportDefaultVariable.types new file mode 100644 index 00000000000..a61c64b4685 --- /dev/null +++ b/tests/baselines/reference/exportDefaultVariable.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/exportDefaultVariable.ts === +// Regression test for #3018 + +declare var io: any; +>io : any + +declare module 'module' { + export default io; +>io : any +} + diff --git a/tests/baselines/reference/extBaseClass1.js b/tests/baselines/reference/extBaseClass1.js index 7997944ee7a..9e7421b906c 100644 --- a/tests/baselines/reference/extBaseClass1.js +++ b/tests/baselines/reference/extBaseClass1.js @@ -20,7 +20,7 @@ module N { //// [extBaseClass1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extBaseClass2.js b/tests/baselines/reference/extBaseClass2.js index eff97549010..e5a717bca80 100644 --- a/tests/baselines/reference/extBaseClass2.js +++ b/tests/baselines/reference/extBaseClass2.js @@ -11,7 +11,7 @@ module M { //// [extBaseClass2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType.js b/tests/baselines/reference/extendAndImplementTheSameBaseType.js index 23c9127175e..c69315dbd61 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType.js @@ -14,7 +14,7 @@ d.baz(); d.foo; //// [extendAndImplementTheSameBaseType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js index 234cc59ff70..06ea74880c2 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js @@ -17,7 +17,7 @@ var r3: string = d.bar(); var r4: number = d.bar(); //// [extendAndImplementTheSameBaseType2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js index 5034fd96691..7598d771bac 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js @@ -4,7 +4,7 @@ class derived extends base { } class base { constructor (public n: number) { } } //// [extendBaseClassBeforeItsDeclared.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendNonClassSymbol1.js b/tests/baselines/reference/extendNonClassSymbol1.js index 26f0c776dd8..59da2d7ca2b 100644 --- a/tests/baselines/reference/extendNonClassSymbol1.js +++ b/tests/baselines/reference/extendNonClassSymbol1.js @@ -4,7 +4,7 @@ var x = A; class C extends x { } // error, could not find symbol xs //// [extendNonClassSymbol1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendNonClassSymbol2.js b/tests/baselines/reference/extendNonClassSymbol2.js index 4cb7b1787df..830994e3d26 100644 --- a/tests/baselines/reference/extendNonClassSymbol2.js +++ b/tests/baselines/reference/extendNonClassSymbol2.js @@ -6,7 +6,7 @@ var x = new Foo(); // legal, considered a constructor function class C extends Foo {} // error, could not find symbol Foo //// [extendNonClassSymbol2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js index 09280cd224a..0bf86390b74 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js @@ -40,7 +40,7 @@ var Model = (function () { })(); exports.Model = Model; //// [extendingClassFromAliasAndUsageInIndexer_moduleA.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -56,7 +56,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [extendingClassFromAliasAndUsageInIndexer_moduleB.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendsClauseAlreadySeen.js b/tests/baselines/reference/extendsClauseAlreadySeen.js index 820a6910962..3e7151b8e0d 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen.js @@ -7,7 +7,7 @@ class D extends C extends C { } //// [extendsClauseAlreadySeen.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/extendsClauseAlreadySeen2.js b/tests/baselines/reference/extendsClauseAlreadySeen2.js index ad88446c4c4..9ee428c36ed 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen2.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen2.js @@ -7,7 +7,7 @@ class D extends C extends C { } //// [extendsClauseAlreadySeen2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/for-inStatements.js b/tests/baselines/reference/for-inStatements.js index 3db07d878bf..749c7b47b34 100644 --- a/tests/baselines/reference/for-inStatements.js +++ b/tests/baselines/reference/for-inStatements.js @@ -81,7 +81,7 @@ for (var x in Color.Blue) { } //// [for-inStatements.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/for-inStatementsInvalid.js b/tests/baselines/reference/for-inStatementsInvalid.js index 6d42a550a01..e1806272790 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.js +++ b/tests/baselines/reference/for-inStatementsInvalid.js @@ -64,7 +64,7 @@ for (var x in i[42]) { } //// [for-inStatementsInvalid.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index c9d3c4d254c..833ea1d6875 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1423, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1423, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 180766144c8..2c08338ce73 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -23,7 +23,7 @@ class StringIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 5dd58d671a7..6be3c83964a 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -28,7 +28,7 @@ class FooIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 50c191a7ac0..97200f93f35 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -28,7 +28,7 @@ class FooIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 0fbef87af15..bbe3504294c 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -28,7 +28,7 @@ class FooIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 9714f615a79..4f15b541356 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -29,7 +29,7 @@ class FooIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 328cb41ad29..0f409605e28 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -28,7 +28,7 @@ class FooIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 1a0b660fc1e..44cc83143af 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -11,7 +11,7 @@ class StringIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return x; diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index a2c21c95146..0218a8b9995 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -17,7 +17,7 @@ class StringIterator { } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index e03b580551d..82918a19986 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -8,6 +8,6 @@ class StringIterator { [Symbol.iterator]: any; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 9d6b912bd94..e4324b05779 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -11,7 +11,7 @@ class StringIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/for-of33.errors.txt b/tests/baselines/reference/for-of33.errors.txt index 1c631042d7d..cd2d48566ab 100644 --- a/tests/baselines/reference/for-of33.errors.txt +++ b/tests/baselines/reference/for-of33.errors.txt @@ -1,13 +1,16 @@ tests/cases/conformance/es6/for-ofStatements/for-of33.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. +tests/cases/conformance/es6/for-ofStatements/for-of33.ts(4,5): error TS7023: '[Symbol.iterator]' 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. -==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (1 errors) ==== +==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (2 errors) ==== for (var v of new StringIterator) { } ~ !!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. class StringIterator { [Symbol.iterator]() { + ~~~~~~~~~~~~~~~~~ +!!! error TS7023: '[Symbol.iterator]' 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. return v; } } \ No newline at end of file diff --git a/tests/baselines/reference/for-of34.errors.txt b/tests/baselines/reference/for-of34.errors.txt index 994302db88b..a4f55ed29ba 100644 --- a/tests/baselines/reference/for-of34.errors.txt +++ b/tests/baselines/reference/for-of34.errors.txt @@ -1,13 +1,16 @@ tests/cases/conformance/es6/for-ofStatements/for-of34.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. +tests/cases/conformance/es6/for-ofStatements/for-of34.ts(4,5): error TS7023: 'next' 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. -==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (1 errors) ==== +==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (2 errors) ==== for (var v of new StringIterator) { } ~ !!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. class StringIterator { next() { + ~~~~ +!!! error TS7023: 'next' 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. return v; } diff --git a/tests/baselines/reference/for-of35.errors.txt b/tests/baselines/reference/for-of35.errors.txt index f83b6d2ec3c..65529752b9b 100644 --- a/tests/baselines/reference/for-of35.errors.txt +++ b/tests/baselines/reference/for-of35.errors.txt @@ -1,13 +1,16 @@ tests/cases/conformance/es6/for-ofStatements/for-of35.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. +tests/cases/conformance/es6/for-ofStatements/for-of35.ts(4,5): error TS7023: 'next' 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. -==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (1 errors) ==== +==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (2 errors) ==== for (var v of new StringIterator) { } ~ !!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. class StringIterator { next() { + ~~~~ +!!! error TS7023: 'next' 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. return { done: true, value: v diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 86841971be7..93f6c4f7dd6 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index 5ee81f2eb15..fab42d91724 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index a9c0b3fbc30..1cd3538f987 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index e01aad51d54..9c6afa04adb 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index e86ee110362..9fda4cb4e0a 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index 9076f63300e..c176e1aca0c 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index 60e87b25587..27aed0777ba 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js index 2282136be3a..b00e8acef14 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js @@ -54,7 +54,7 @@ for(var m: typeof M;;){} for( var m = M.A;;){} //// [forStatementsMultipleInvalidDecl.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/functionExpressionContextualTyping1.js b/tests/baselines/reference/functionExpressionContextualTyping1.js new file mode 100644 index 00000000000..8d60572b30f --- /dev/null +++ b/tests/baselines/reference/functionExpressionContextualTyping1.js @@ -0,0 +1,120 @@ +//// [functionExpressionContextualTyping1.ts] +// When a function expression with no type parameters and no parameter type annotations +// is contextually typed (section 4.19) by a type T and a contextual signature S can be extracted from T + +enum E { red, blue } + +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. + +var a0: (n: number, s: string) => number = (num, str) => { + num.toExponential(); + return 0; +} + +class Class { + foo() { } +} + +var a1: (c: Class) => number = (a1) => { + a1.foo(); + return 1; +} + +// A contextual signature S is extracted from a function type T as follows: +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, +// then S is a signature with the same parameters and a union of the return types. +var b1: ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string); +b1 = (k, h) => { }; +var b2: typeof a0 | ((n: number, s: string) => string); +b2 = (foo, bar) => { return foo + 1; } +b2 = (foo, bar) => { return "hello"; } +var b3: (name: string, num: number, boo: boolean) => void; +b3 = (name, number) => { }; + +var b4: (n: E) => string = (number = 1) => { return "hello"; }; +var b5: (n: {}) => string = (number = "string") => { return "hello"; }; + +// A contextual signature S is extracted from a function type T as follows: +// Otherwise, no contextual signature can be extracted from T and S is undefined. +var b6: ((s: string, w: boolean) => void) | ((n: number) => number); +var b7: ((s: string, w: boolean) => void) | ((s: string, w: number) => string); +b6 = (k) => { k.toLowerCase() }; +b6 = (i) => { + i.toExponential(); + return i; +}; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +b7 = (j, m) => { }; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) + +class C { + constructor() { + var k: ((j: T, k: U) => (T|U)[]) | ((j: number,k :U) => number[]) = (j, k) => { + return [j, k]; + } // Per spec, no contextual signature can be extracted in this case. + } +} + +//// [functionExpressionContextualTyping1.js] +// When a function expression with no type parameters and no parameter type annotations +// is contextually typed (section 4.19) by a type T and a contextual signature S can be extracted from T +var E; +(function (E) { + E[E["red"] = 0] = "red"; + E[E["blue"] = 1] = "blue"; +})(E || (E = {})); +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. +var a0 = function (num, str) { + num.toExponential(); + return 0; +}; +var Class = (function () { + function Class() { + } + Class.prototype.foo = function () { }; + return Class; +})(); +var a1 = function (a1) { + a1.foo(); + return 1; +}; +// A contextual signature S is extracted from a function type T as follows: +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, +// then S is a signature with the same parameters and a union of the return types. +var b1; +b1 = function (k, h) { }; +var b2; +b2 = function (foo, bar) { return foo + 1; }; +b2 = function (foo, bar) { return "hello"; }; +var b3; +b3 = function (name, number) { }; +var b4 = function (number) { + if (number === void 0) { number = 1; } + return "hello"; +}; +var b5 = function (number) { + if (number === void 0) { number = "string"; } + return "hello"; +}; +// A contextual signature S is extracted from a function type T as follows: +// Otherwise, no contextual signature can be extracted from T and S is undefined. +var b6; +var b7; +b6 = function (k) { k.toLowerCase(); }; +b6 = function (i) { + i.toExponential(); + return i; +}; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +b7 = function (j, m) { }; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +var C = (function () { + function C() { + var k = function (j, k) { + return [j, k]; + }; // Per spec, no contextual signature can be extracted in this case. + } + return C; +})(); diff --git a/tests/baselines/reference/functionExpressionContextualTyping1.symbols b/tests/baselines/reference/functionExpressionContextualTyping1.symbols new file mode 100644 index 00000000000..6182e4bb9a8 --- /dev/null +++ b/tests/baselines/reference/functionExpressionContextualTyping1.symbols @@ -0,0 +1,169 @@ +=== tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping1.ts === +// When a function expression with no type parameters and no parameter type annotations +// is contextually typed (section 4.19) by a type T and a contextual signature S can be extracted from T + +enum E { red, blue } +>E : Symbol(E, Decl(functionExpressionContextualTyping1.ts, 0, 0)) +>red : Symbol(E.red, Decl(functionExpressionContextualTyping1.ts, 3, 8)) +>blue : Symbol(E.blue, Decl(functionExpressionContextualTyping1.ts, 3, 13)) + +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. + +var a0: (n: number, s: string) => number = (num, str) => { +>a0 : Symbol(a0, Decl(functionExpressionContextualTyping1.ts, 8, 3)) +>n : Symbol(n, Decl(functionExpressionContextualTyping1.ts, 8, 9)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 8, 19)) +>num : Symbol(num, Decl(functionExpressionContextualTyping1.ts, 8, 44)) +>str : Symbol(str, Decl(functionExpressionContextualTyping1.ts, 8, 48)) + + num.toExponential(); +>num.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, 469, 45)) +>num : Symbol(num, Decl(functionExpressionContextualTyping1.ts, 8, 44)) +>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, 469, 45)) + + return 0; +} + +class Class { +>Class : Symbol(Class, Decl(functionExpressionContextualTyping1.ts, 11, 1)) +>T : Symbol(T, Decl(functionExpressionContextualTyping1.ts, 13, 12)) + + foo() { } +>foo : Symbol(foo, Decl(functionExpressionContextualTyping1.ts, 13, 16)) +} + +var a1: (c: Class) => number = (a1) => { +>a1 : Symbol(a1, Decl(functionExpressionContextualTyping1.ts, 17, 3)) +>c : Symbol(c, Decl(functionExpressionContextualTyping1.ts, 17, 9)) +>Class : Symbol(Class, Decl(functionExpressionContextualTyping1.ts, 11, 1)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) +>a1 : Symbol(a1, Decl(functionExpressionContextualTyping1.ts, 17, 40)) + + a1.foo(); +>a1.foo : Symbol(Class.foo, Decl(functionExpressionContextualTyping1.ts, 13, 16)) +>a1 : Symbol(a1, Decl(functionExpressionContextualTyping1.ts, 17, 40)) +>foo : Symbol(Class.foo, Decl(functionExpressionContextualTyping1.ts, 13, 16)) + + return 1; +} + +// A contextual signature S is extracted from a function type T as follows: +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, +// then S is a signature with the same parameters and a union of the return types. +var b1: ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string); +>b1 : Symbol(b1, Decl(functionExpressionContextualTyping1.ts, 27, 3)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 27, 10)) +>w : Symbol(w, Decl(functionExpressionContextualTyping1.ts, 27, 20)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 27, 46)) +>w : Symbol(w, Decl(functionExpressionContextualTyping1.ts, 27, 56)) + +b1 = (k, h) => { }; +>b1 : Symbol(b1, Decl(functionExpressionContextualTyping1.ts, 27, 3)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 28, 6)) +>h : Symbol(h, Decl(functionExpressionContextualTyping1.ts, 28, 8)) + +var b2: typeof a0 | ((n: number, s: string) => string); +>b2 : Symbol(b2, Decl(functionExpressionContextualTyping1.ts, 29, 3)) +>a0 : Symbol(a0, Decl(functionExpressionContextualTyping1.ts, 8, 3)) +>n : Symbol(n, Decl(functionExpressionContextualTyping1.ts, 29, 22)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 29, 32)) + +b2 = (foo, bar) => { return foo + 1; } +>b2 : Symbol(b2, Decl(functionExpressionContextualTyping1.ts, 29, 3)) +>foo : Symbol(foo, Decl(functionExpressionContextualTyping1.ts, 30, 6)) +>bar : Symbol(bar, Decl(functionExpressionContextualTyping1.ts, 30, 10)) +>foo : Symbol(foo, Decl(functionExpressionContextualTyping1.ts, 30, 6)) + +b2 = (foo, bar) => { return "hello"; } +>b2 : Symbol(b2, Decl(functionExpressionContextualTyping1.ts, 29, 3)) +>foo : Symbol(foo, Decl(functionExpressionContextualTyping1.ts, 31, 6)) +>bar : Symbol(bar, Decl(functionExpressionContextualTyping1.ts, 31, 10)) + +var b3: (name: string, num: number, boo: boolean) => void; +>b3 : Symbol(b3, Decl(functionExpressionContextualTyping1.ts, 32, 3)) +>name : Symbol(name, Decl(functionExpressionContextualTyping1.ts, 32, 9)) +>num : Symbol(num, Decl(functionExpressionContextualTyping1.ts, 32, 22)) +>boo : Symbol(boo, Decl(functionExpressionContextualTyping1.ts, 32, 35)) + +b3 = (name, number) => { }; +>b3 : Symbol(b3, Decl(functionExpressionContextualTyping1.ts, 32, 3)) +>name : Symbol(name, Decl(functionExpressionContextualTyping1.ts, 33, 6)) +>number : Symbol(number, Decl(functionExpressionContextualTyping1.ts, 33, 11)) + +var b4: (n: E) => string = (number = 1) => { return "hello"; }; +>b4 : Symbol(b4, Decl(functionExpressionContextualTyping1.ts, 35, 3)) +>n : Symbol(n, Decl(functionExpressionContextualTyping1.ts, 35, 9)) +>E : Symbol(E, Decl(functionExpressionContextualTyping1.ts, 0, 0)) +>number : Symbol(number, Decl(functionExpressionContextualTyping1.ts, 35, 28)) + +var b5: (n: {}) => string = (number = "string") => { return "hello"; }; +>b5 : Symbol(b5, Decl(functionExpressionContextualTyping1.ts, 36, 3)) +>n : Symbol(n, Decl(functionExpressionContextualTyping1.ts, 36, 9)) +>number : Symbol(number, Decl(functionExpressionContextualTyping1.ts, 36, 29)) + +// A contextual signature S is extracted from a function type T as follows: +// Otherwise, no contextual signature can be extracted from T and S is undefined. +var b6: ((s: string, w: boolean) => void) | ((n: number) => number); +>b6 : Symbol(b6, Decl(functionExpressionContextualTyping1.ts, 40, 3)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 40, 10)) +>w : Symbol(w, Decl(functionExpressionContextualTyping1.ts, 40, 20)) +>n : Symbol(n, Decl(functionExpressionContextualTyping1.ts, 40, 46)) + +var b7: ((s: string, w: boolean) => void) | ((s: string, w: number) => string); +>b7 : Symbol(b7, Decl(functionExpressionContextualTyping1.ts, 41, 3)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 41, 10)) +>w : Symbol(w, Decl(functionExpressionContextualTyping1.ts, 41, 20)) +>s : Symbol(s, Decl(functionExpressionContextualTyping1.ts, 41, 46)) +>w : Symbol(w, Decl(functionExpressionContextualTyping1.ts, 41, 56)) + +b6 = (k) => { k.toLowerCase() }; +>b6 : Symbol(b6, Decl(functionExpressionContextualTyping1.ts, 40, 3)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 42, 6)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 42, 6)) + +b6 = (i) => { +>b6 : Symbol(b6, Decl(functionExpressionContextualTyping1.ts, 40, 3)) +>i : Symbol(i, Decl(functionExpressionContextualTyping1.ts, 43, 6)) + + i.toExponential(); +>i : Symbol(i, Decl(functionExpressionContextualTyping1.ts, 43, 6)) + + return i; +>i : Symbol(i, Decl(functionExpressionContextualTyping1.ts, 43, 6)) + +}; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +b7 = (j, m) => { }; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +>b7 : Symbol(b7, Decl(functionExpressionContextualTyping1.ts, 41, 3)) +>j : Symbol(j, Decl(functionExpressionContextualTyping1.ts, 47, 6)) +>m : Symbol(m, Decl(functionExpressionContextualTyping1.ts, 47, 8)) + +class C { +>C : Symbol(C, Decl(functionExpressionContextualTyping1.ts, 47, 19)) +>T : Symbol(T, Decl(functionExpressionContextualTyping1.ts, 49, 8)) +>U : Symbol(U, Decl(functionExpressionContextualTyping1.ts, 49, 10)) + + constructor() { + var k: ((j: T, k: U) => (T|U)[]) | ((j: number,k :U) => number[]) = (j, k) => { +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 51, 11)) +>j : Symbol(j, Decl(functionExpressionContextualTyping1.ts, 51, 17)) +>T : Symbol(T, Decl(functionExpressionContextualTyping1.ts, 49, 8)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 51, 22)) +>U : Symbol(U, Decl(functionExpressionContextualTyping1.ts, 49, 10)) +>T : Symbol(T, Decl(functionExpressionContextualTyping1.ts, 49, 8)) +>U : Symbol(U, Decl(functionExpressionContextualTyping1.ts, 49, 10)) +>j : Symbol(j, Decl(functionExpressionContextualTyping1.ts, 51, 45)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 51, 55)) +>U : Symbol(U, Decl(functionExpressionContextualTyping1.ts, 49, 10)) +>j : Symbol(j, Decl(functionExpressionContextualTyping1.ts, 51, 77)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 51, 79)) + + return [j, k]; +>j : Symbol(j, Decl(functionExpressionContextualTyping1.ts, 51, 77)) +>k : Symbol(k, Decl(functionExpressionContextualTyping1.ts, 51, 79)) + + } // Per spec, no contextual signature can be extracted in this case. + } +} diff --git a/tests/baselines/reference/functionExpressionContextualTyping1.types b/tests/baselines/reference/functionExpressionContextualTyping1.types new file mode 100644 index 00000000000..61d16bf6a4f --- /dev/null +++ b/tests/baselines/reference/functionExpressionContextualTyping1.types @@ -0,0 +1,206 @@ +=== tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping1.ts === +// When a function expression with no type parameters and no parameter type annotations +// is contextually typed (section 4.19) by a type T and a contextual signature S can be extracted from T + +enum E { red, blue } +>E : E +>red : E +>blue : E + +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. + +var a0: (n: number, s: string) => number = (num, str) => { +>a0 : (n: number, s: string) => number +>n : number +>s : string +>(num, str) => { num.toExponential(); return 0;} : (num: number, str: string) => number +>num : number +>str : string + + num.toExponential(); +>num.toExponential() : string +>num.toExponential : (fractionDigits?: number) => string +>num : number +>toExponential : (fractionDigits?: number) => string + + return 0; +>0 : number +} + +class Class { +>Class : Class +>T : T + + foo() { } +>foo : () => void +} + +var a1: (c: Class) => number = (a1) => { +>a1 : (c: Class) => number +>c : Class +>Class : Class +>Number : Number +>(a1) => { a1.foo(); return 1;} : (a1: Class) => number +>a1 : Class + + a1.foo(); +>a1.foo() : void +>a1.foo : () => void +>a1 : Class +>foo : () => void + + return 1; +>1 : number +} + +// A contextual signature S is extracted from a function type T as follows: +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, +// then S is a signature with the same parameters and a union of the return types. +var b1: ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string); +>b1 : ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string) +>s : string +>w : boolean +>s : string +>w : boolean + +b1 = (k, h) => { }; +>b1 = (k, h) => { } : (k: string, h: boolean) => void +>b1 : ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string) +>(k, h) => { } : (k: string, h: boolean) => void +>k : string +>h : boolean + +var b2: typeof a0 | ((n: number, s: string) => string); +>b2 : ((n: number, s: string) => number) | ((n: number, s: string) => string) +>a0 : (n: number, s: string) => number +>n : number +>s : string + +b2 = (foo, bar) => { return foo + 1; } +>b2 = (foo, bar) => { return foo + 1; } : (foo: number, bar: string) => number +>b2 : ((n: number, s: string) => number) | ((n: number, s: string) => string) +>(foo, bar) => { return foo + 1; } : (foo: number, bar: string) => number +>foo : number +>bar : string +>foo + 1 : number +>foo : number +>1 : number + +b2 = (foo, bar) => { return "hello"; } +>b2 = (foo, bar) => { return "hello"; } : (foo: number, bar: string) => string +>b2 : ((n: number, s: string) => number) | ((n: number, s: string) => string) +>(foo, bar) => { return "hello"; } : (foo: number, bar: string) => string +>foo : number +>bar : string +>"hello" : string + +var b3: (name: string, num: number, boo: boolean) => void; +>b3 : (name: string, num: number, boo: boolean) => void +>name : string +>num : number +>boo : boolean + +b3 = (name, number) => { }; +>b3 = (name, number) => { } : (name: string, number: number) => void +>b3 : (name: string, num: number, boo: boolean) => void +>(name, number) => { } : (name: string, number: number) => void +>name : string +>number : number + +var b4: (n: E) => string = (number = 1) => { return "hello"; }; +>b4 : (n: E) => string +>n : E +>E : E +>(number = 1) => { return "hello"; } : (number?: E) => string +>number : E +>1 : number +>"hello" : string + +var b5: (n: {}) => string = (number = "string") => { return "hello"; }; +>b5 : (n: {}) => string +>n : {} +>(number = "string") => { return "hello"; } : (number?: {}) => string +>number : {} +>"string" : string +>"hello" : string + +// A contextual signature S is extracted from a function type T as follows: +// Otherwise, no contextual signature can be extracted from T and S is undefined. +var b6: ((s: string, w: boolean) => void) | ((n: number) => number); +>b6 : ((s: string, w: boolean) => void) | ((n: number) => number) +>s : string +>w : boolean +>n : number + +var b7: ((s: string, w: boolean) => void) | ((s: string, w: number) => string); +>b7 : ((s: string, w: boolean) => void) | ((s: string, w: number) => string) +>s : string +>w : boolean +>s : string +>w : number + +b6 = (k) => { k.toLowerCase() }; +>b6 = (k) => { k.toLowerCase() } : (k: any) => void +>b6 : ((s: string, w: boolean) => void) | ((n: number) => number) +>(k) => { k.toLowerCase() } : (k: any) => void +>k : any +>k.toLowerCase() : any +>k.toLowerCase : any +>k : any +>toLowerCase : any + +b6 = (i) => { +>b6 = (i) => { i.toExponential(); return i;} : (i: any) => any +>b6 : ((s: string, w: boolean) => void) | ((n: number) => number) +>(i) => { i.toExponential(); return i;} : (i: any) => any +>i : any + + i.toExponential(); +>i.toExponential() : any +>i.toExponential : any +>i : any +>toExponential : any + + return i; +>i : any + +}; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +b7 = (j, m) => { }; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +>b7 = (j, m) => { } : (j: any, m: any) => void +>b7 : ((s: string, w: boolean) => void) | ((s: string, w: number) => string) +>(j, m) => { } : (j: any, m: any) => void +>j : any +>m : any + +class C { +>C : C +>T : T +>U : U + + constructor() { + var k: ((j: T, k: U) => (T|U)[]) | ((j: number,k :U) => number[]) = (j, k) => { +>k : ((j: T, k: U) => (T | U)[]) | ((j: number, k: U) => number[]) +>j : T +>T : T +>k : U +>U : U +>T : T +>U : U +>j : number +>k : U +>U : U +>(j, k) => { return [j, k]; } : (j: any, k: any) => any[] +>j : any +>k : any + + return [j, k]; +>[j, k] : any[] +>j : any +>k : any + + } // Per spec, no contextual signature can be extracted in this case. + } +} diff --git a/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt b/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt new file mode 100644 index 00000000000..6a3a7998f09 --- /dev/null +++ b/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts(11,1): error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. + Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => string'. + Type 'boolean' is not assignable to type 'string'. + + +==== tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts (1 errors) ==== + // A contextual signature S is extracted from a function type T as follows: + // If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. + // If T is a union type, let U be the set of element types in T that have call signatures. + // If each type in U has exactly one call signature and that call signature is non- generic, + // and if all of the signatures are identical ignoring return types, then S is a signature + // with the same parameters and a union of the return types. + // Otherwise, no contextual signature can be extracted from T and S is undefined. + + var a0: (n: number, s: string) => number + var a1: typeof a0 | ((n: number, s: string) => string); + a1 = (foo, bar) => { return true; } // Error + ~~ +!!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. +!!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => string'. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/functionExpressionContextualTyping2.js b/tests/baselines/reference/functionExpressionContextualTyping2.js new file mode 100644 index 00000000000..dae30a79036 --- /dev/null +++ b/tests/baselines/reference/functionExpressionContextualTyping2.js @@ -0,0 +1,24 @@ +//// [functionExpressionContextualTyping2.ts] +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, then S is a signature +// with the same parameters and a union of the return types. +// Otherwise, no contextual signature can be extracted from T and S is undefined. + +var a0: (n: number, s: string) => number +var a1: typeof a0 | ((n: number, s: string) => string); +a1 = (foo, bar) => { return true; } // Error + +//// [functionExpressionContextualTyping2.js] +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, then S is a signature +// with the same parameters and a union of the return types. +// Otherwise, no contextual signature can be extracted from T and S is undefined. +var a0; +var a1; +a1 = function (foo, bar) { return true; }; // Error diff --git a/tests/baselines/reference/functionImplementationErrors.js b/tests/baselines/reference/functionImplementationErrors.js index 5eaf9027335..6c1daffdaf1 100644 --- a/tests/baselines/reference/functionImplementationErrors.js +++ b/tests/baselines/reference/functionImplementationErrors.js @@ -74,7 +74,7 @@ var f13 = () => { //// [functionImplementationErrors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/functionImplementations.js b/tests/baselines/reference/functionImplementations.js index c478f892fd5..0370c4c0027 100644 --- a/tests/baselines/reference/functionImplementations.js +++ b/tests/baselines/reference/functionImplementations.js @@ -157,7 +157,7 @@ var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherC } //// [functionImplementations.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs.js b/tests/baselines/reference/functionSubtypingOfVarArgs.js index c527ca9696a..b0168975677 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs.js @@ -15,7 +15,7 @@ class StringEvent extends EventBase { // should work //// [functionSubtypingOfVarArgs.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.js b/tests/baselines/reference/functionSubtypingOfVarArgs2.js index e11c03404a9..7efd35cc2d2 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.js @@ -15,7 +15,7 @@ class StringEvent extends EventBase { //// [functionSubtypingOfVarArgs2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index a88929669fd..3c2c704ddb0 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -355,7 +355,7 @@ var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; retur var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); //// [generatedContextualTyping.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.js b/tests/baselines/reference/genericBaseClassLiteralProperty.js index bde7fa69302..5e365531461 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.js @@ -13,7 +13,7 @@ class SubClass extends BaseClass { } //// [genericBaseClassLiteralProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.js b/tests/baselines/reference/genericBaseClassLiteralProperty2.js index f558f424302..8a19d857bb6 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.js @@ -16,7 +16,7 @@ class DataView2 extends BaseCollection2 { //// [genericBaseClassLiteralProperty2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js index be6ef0e4124..f00468dcbc5 100644 --- a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js +++ b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js @@ -109,7 +109,7 @@ var r11 = i.foo8(); // Base //// [genericCallWithConstraintsTypeArgumentInference.js] // Basic type inference with generic calls and constraints, no errors expected -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js index 3a72feff979..910e3860b49 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js @@ -33,7 +33,7 @@ var i: I; var r4 = f2(i); // Base => Derived //// [genericCallWithObjectTypeArgs2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js index c1f0945ba10..9cb2425f9d0 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js @@ -41,7 +41,7 @@ var r7 = f3(null, x => x); // any //// [genericCallWithObjectTypeArgsAndConstraints2.js] // Generic call with constraints infering type parameter from object member properties // No errors expected -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js index b9c722f80be..3c5a4c24b53 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js @@ -39,7 +39,7 @@ var r6 = f3(x => x, null); //// [genericCallWithObjectTypeArgsAndConstraints3.js] // Generic call with constraints infering type parameter from object member properties -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js index e63c7a98272..16abb2683e7 100644 --- a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js +++ b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js @@ -24,7 +24,7 @@ module M { } //// [genericCallbacksAndClassHierarchy.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js index 489ecd0f059..22bb975e7d7 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js @@ -6,7 +6,7 @@ class C { } //// [genericClassInheritsConstructorFromNonGenericClass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js index 4f26e35d1b0..43d1e53a615 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js @@ -76,7 +76,7 @@ class ViewModel implements Contract { //// [genericClassPropertyInheritanceSpecialization.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericClassStaticMethod.js b/tests/baselines/reference/genericClassStaticMethod.js index 71dafd8ee8b..23e1874c0ed 100644 --- a/tests/baselines/reference/genericClassStaticMethod.js +++ b/tests/baselines/reference/genericClassStaticMethod.js @@ -11,7 +11,7 @@ class Bar extends Foo { //// [genericClassStaticMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericClasses3.js b/tests/baselines/reference/genericClasses3.js index 621142c2e9a..373052d78e3 100644 --- a/tests/baselines/reference/genericClasses3.js +++ b/tests/baselines/reference/genericClasses3.js @@ -18,7 +18,7 @@ var z = v2.b; //// [genericClasses3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js index e2babf511b4..561c24cd50e 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js @@ -27,7 +27,7 @@ module EndGate.Tweening { } //// [genericConstraintOnExtendedBuiltinTypes.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js index ccbbf9d11a6..2420e082e3d 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js @@ -26,7 +26,7 @@ module EndGate.Tweening { } //// [genericConstraintOnExtendedBuiltinTypes2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js index 7f639415490..69ae509bf54 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js @@ -13,7 +13,7 @@ x = y; // error //// [genericDerivedTypeWithSpecializedBase.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js index 4b28d4b7f1c..1c4f27b5ebe 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js @@ -13,7 +13,7 @@ x = y; // error //// [genericDerivedTypeWithSpecializedBase2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericPrototypeProperty2.js b/tests/baselines/reference/genericPrototypeProperty2.js index 9a48ef679dc..b91b345481e 100644 --- a/tests/baselines/reference/genericPrototypeProperty2.js +++ b/tests/baselines/reference/genericPrototypeProperty2.js @@ -16,7 +16,7 @@ class MyEventWrapper extends BaseEventWrapper { } //// [genericPrototypeProperty2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericPrototypeProperty3.js b/tests/baselines/reference/genericPrototypeProperty3.js index 522b3a11e1b..de093886ea4 100644 --- a/tests/baselines/reference/genericPrototypeProperty3.js +++ b/tests/baselines/reference/genericPrototypeProperty3.js @@ -15,7 +15,7 @@ class MyEventWrapper extends BaseEventWrapper { } //// [genericPrototypeProperty3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js index 4d5c6810f75..b73239626d0 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js @@ -27,7 +27,7 @@ module TypeScript2 { //// [genericRecursiveImplicitConstructorErrors2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js index e01c9045345..0d4a3315acd 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js @@ -31,7 +31,7 @@ module TypeScript { //// [genericRecursiveImplicitConstructorErrors3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericTypeAssertions2.js b/tests/baselines/reference/genericTypeAssertions2.js index 3c904c7a30e..a3b88f599b9 100644 --- a/tests/baselines/reference/genericTypeAssertions2.js +++ b/tests/baselines/reference/genericTypeAssertions2.js @@ -14,7 +14,7 @@ var r4: A = >new A(); var r5: A = >[]; // error //// [genericTypeAssertions2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericTypeAssertions4.js b/tests/baselines/reference/genericTypeAssertions4.js index a607fb07428..95ca5482b2e 100644 --- a/tests/baselines/reference/genericTypeAssertions4.js +++ b/tests/baselines/reference/genericTypeAssertions4.js @@ -26,7 +26,7 @@ function foo2(x: T) { } //// [genericTypeAssertions4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericTypeAssertions6.js b/tests/baselines/reference/genericTypeAssertions6.js index d6061d8cf0a..d19da506680 100644 --- a/tests/baselines/reference/genericTypeAssertions6.js +++ b/tests/baselines/reference/genericTypeAssertions6.js @@ -25,7 +25,7 @@ var b: B; var c: A = >b; //// [genericTypeAssertions6.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js index 4be1cce27a9..5ec0a25af3d 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js @@ -40,7 +40,7 @@ var k = null; //// [genericTypeReferenceWithoutTypeArgument.js] // it is an error to use a generic type without type arguments // all of these are errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js index 803d499705a..2f36a74de76 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js @@ -40,7 +40,7 @@ var k = null; //// [genericTypeReferenceWithoutTypeArgument2.js] // it is an error to use a generic type without type arguments // all of these are errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js index fdd2e470a55..8142cd86407 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js @@ -15,7 +15,7 @@ export class ListItem extends CollectionItem { //// [genericWithIndexerOfTypeParameterType2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/getEmitOutputOut.baseline b/tests/baselines/reference/getEmitOutputOut.baseline new file mode 100644 index 00000000000..9508b6d5570 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputOut.baseline @@ -0,0 +1,12 @@ +EmitSkipped: false +FileName : out.js +/// +var foo; +(function (foo) { + var bar; + (function (bar) { + var baz1 = bar.Baz.prototype; // Should emit as bar.Baz.prototype + })(bar = foo.bar || (foo.bar = {})); +})(foo || (foo = {})); +var x; + diff --git a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt new file mode 100644 index 00000000000..5b076b078c5 --- /dev/null +++ b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,16): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts (1 errors) ==== + // In the body of a get accessor with no return type annotation, + // if a matching set accessor exists and that set accessor has a parameter type annotation, + // return expressions are contextually typed by the type given in the set accessor's parameter type annotation. + + class C { + set X(x: number) { } + get X() { + return "string"; // Error; get contextual type by set accessor parameter type annotation + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + } + + set Y(y) { } + get Y() { + return true; + } + + set W(w) { } + get W(): boolean { + return true; + } + + set Z(z: number) { } + get Z() { + return 1; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/getSetAccessorContextualTyping.js b/tests/baselines/reference/getSetAccessorContextualTyping.js new file mode 100644 index 00000000000..d1415e1d4e7 --- /dev/null +++ b/tests/baselines/reference/getSetAccessorContextualTyping.js @@ -0,0 +1,68 @@ +//// [getSetAccessorContextualTyping.ts] +// In the body of a get accessor with no return type annotation, +// if a matching set accessor exists and that set accessor has a parameter type annotation, +// return expressions are contextually typed by the type given in the set accessor's parameter type annotation. + +class C { + set X(x: number) { } + get X() { + return "string"; // Error; get contextual type by set accessor parameter type annotation + } + + set Y(y) { } + get Y() { + return true; + } + + set W(w) { } + get W(): boolean { + return true; + } + + set Z(z: number) { } + get Z() { + return 1; + } +} + +//// [getSetAccessorContextualTyping.js] +// In the body of a get accessor with no return type annotation, +// if a matching set accessor exists and that set accessor has a parameter type annotation, +// return expressions are contextually typed by the type given in the set accessor's parameter type annotation. +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + get: function () { + return "string"; // Error; get contextual type by set accessor parameter type annotation + }, + set: function (x) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "Y", { + get: function () { + return true; + }, + set: function (y) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "W", { + get: function () { + return true; + }, + set: function (w) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "Z", { + get: function () { + return 1; + }, + set: function (z) { }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.js b/tests/baselines/reference/heterogeneousArrayLiterals.js index 4ac929305c0..26d1b09a6fc 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.js +++ b/tests/baselines/reference/heterogeneousArrayLiterals.js @@ -133,7 +133,7 @@ function foo4(t: T, u: U) { //// [heterogeneousArrayLiterals.js] // type of an array is the best common type of its elements (plus its contextual type if it exists) -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/ifDoWhileStatements.js b/tests/baselines/reference/ifDoWhileStatements.js index 793094584bf..d389f705707 100644 --- a/tests/baselines/reference/ifDoWhileStatements.js +++ b/tests/baselines/reference/ifDoWhileStatements.js @@ -163,7 +163,7 @@ do { }while(fn) //// [ifDoWhileStatements.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.js b/tests/baselines/reference/illegalSuperCallsInConstructor.js index 0bdcebed9c5..57a382fe625 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.js +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.js @@ -21,7 +21,7 @@ class Derived extends Base { } //// [illegalSuperCallsInConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/implementClausePrecedingExtends.js b/tests/baselines/reference/implementClausePrecedingExtends.js index e8f0b96f485..7501c231dc8 100644 --- a/tests/baselines/reference/implementClausePrecedingExtends.js +++ b/tests/baselines/reference/implementClausePrecedingExtends.js @@ -3,7 +3,7 @@ class C { foo: number } class D implements C extends C { } //// [implementClausePrecedingExtends.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js index 767851fd16d..3d80d344850 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js @@ -86,7 +86,7 @@ module M2 { } //// [implementingAnInterfaceExtendingClassWithPrivates2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js index 1a79496bd12..1fa40bf7aa2 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js @@ -42,7 +42,7 @@ class Bar8 extends Foo implements I { //// [implementingAnInterfaceExtendingClassWithProtecteds.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt index 18292c635e6..8d0aaf04c03 100644 --- a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt +++ b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt @@ -1,31 +1,35 @@ -tests/cases/compiler/implicitAnyFromCircularInference.ts(3,5): error TS7021: 'a' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. -tests/cases/compiler/implicitAnyFromCircularInference.ts(7,5): error TS7021: 'c' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. -tests/cases/compiler/implicitAnyFromCircularInference.ts(10,5): error TS7021: 'd' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(3,5): error TS2502: 'a' is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(6,5): error TS2502: 'b' is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(7,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(10,5): error TS2502: 'd' is referenced directly or indirectly in its own type annotation. tests/cases/compiler/implicitAnyFromCircularInference.ts(15,10): error TS7023: 'g' 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. tests/cases/compiler/implicitAnyFromCircularInference.ts(18,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(26,10): error TS7023: 'h' 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. +tests/cases/compiler/implicitAnyFromCircularInference.ts(28,14): error TS7023: 'foo' 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. tests/cases/compiler/implicitAnyFromCircularInference.ts(41,5): error TS7022: 's' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x' 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. -==== tests/cases/compiler/implicitAnyFromCircularInference.ts (9 errors) ==== +==== tests/cases/compiler/implicitAnyFromCircularInference.ts (11 errors) ==== // Error expected var a: typeof a; ~ -!!! error TS7021: 'a' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +!!! error TS2502: 'a' is referenced directly or indirectly in its own type annotation. // Error expected on b or c var b: typeof c; + ~ +!!! error TS2502: 'b' is referenced directly or indirectly in its own type annotation. var c: typeof b; ~ -!!! error TS7021: 'c' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation. // Error expected var d: Array; ~ -!!! error TS7021: 'd' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +!!! error TS2502: 'd' is referenced directly or indirectly in its own type annotation. function f() { return f; } @@ -52,6 +56,8 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x !!! error TS7023: 'h' 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. return foo(); function foo() { + ~~~ +!!! error TS7023: 'foo' 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. return h() || "hello"; } } diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index 8114e88ca4b..24f7e0477d6 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -19,7 +19,7 @@ var Greeter = (function () { })(); exports.Greeter = Greeter; //// [importAsBaseClass_1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/importShadowsGlobalName.js b/tests/baselines/reference/importShadowsGlobalName.js index 0f673097dc2..6db46eb41b1 100644 --- a/tests/baselines/reference/importShadowsGlobalName.js +++ b/tests/baselines/reference/importShadowsGlobalName.js @@ -20,7 +20,7 @@ define(["require", "exports"], function (require, exports) { return Foo; }); //// [Bar.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/importUsedInExtendsList1.js b/tests/baselines/reference/importUsedInExtendsList1.js index 3c9f296d2c2..3e07ee084f3 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.js +++ b/tests/baselines/reference/importUsedInExtendsList1.js @@ -19,7 +19,7 @@ var Super = (function () { })(); exports.Super = Super; //// [importUsedInExtendsList1_1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/importedModuleAddToGlobal.errors.txt b/tests/baselines/reference/importedModuleAddToGlobal.errors.txt index 8948c67f78b..aed680b89aa 100644 --- a/tests/baselines/reference/importedModuleAddToGlobal.errors.txt +++ b/tests/baselines/reference/importedModuleAddToGlobal.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2304: Cannot find name 'b'. +tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2503: Cannot find namespace 'b'. ==== tests/cases/compiler/importedModuleAddToGlobal.ts (1 errors) ==== @@ -18,5 +18,5 @@ tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2304: Cannot f import a = A; function hello(): b.B { return null; } ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2503: Cannot find namespace 'b'. } \ No newline at end of file diff --git a/tests/baselines/reference/indexerConstraints2.js b/tests/baselines/reference/indexerConstraints2.js index df5dbf22f35..7d3966688db 100644 --- a/tests/baselines/reference/indexerConstraints2.js +++ b/tests/baselines/reference/indexerConstraints2.js @@ -29,7 +29,7 @@ class K extends J { } //// [indexerConstraints2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/indirectSelfReference.js b/tests/baselines/reference/indirectSelfReference.js index eb5503c4db9..3652d2962d0 100644 --- a/tests/baselines/reference/indirectSelfReference.js +++ b/tests/baselines/reference/indirectSelfReference.js @@ -3,7 +3,7 @@ class a extends b{ } class b extends a{ } //// [indirectSelfReference.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.js b/tests/baselines/reference/indirectSelfReferenceGeneric.js index eb861bcf294..079a37dc201 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.js +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.js @@ -3,7 +3,7 @@ class a extends b { } class b extends a { } //// [indirectSelfReferenceGeneric.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js index cc80c0b43ce..71390b03c83 100644 --- a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js +++ b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js @@ -25,7 +25,7 @@ o(A); //// [infinitelyExpandingTypesNonGenericBase.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.js b/tests/baselines/reference/inheritFromGenericTypeParameter.js index 8611563af69..ccf445a26bf 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.js +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.js @@ -3,7 +3,7 @@ class C extends T { } interface I extends T { } //// [inheritFromGenericTypeParameter.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js index b201108a7e2..850741c3666 100644 --- a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js +++ b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js @@ -11,7 +11,7 @@ interface A extends C, C2 { // ok } //// [inheritSameNamePrivatePropertiesFromSameOrigin.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritance.js b/tests/baselines/reference/inheritance.js index f7a274b1990..f2b5be9335e 100644 --- a/tests/baselines/reference/inheritance.js +++ b/tests/baselines/reference/inheritance.js @@ -35,7 +35,7 @@ class Baad extends Good { //// [inheritance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritance1.js b/tests/baselines/reference/inheritance1.js index f00a46922bf..e0d4fa974c5 100644 --- a/tests/baselines/reference/inheritance1.js +++ b/tests/baselines/reference/inheritance1.js @@ -62,7 +62,7 @@ l1 = sc; l1 = c; //// [inheritance1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js index 4544df2dcf2..0f016233ef3 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js @@ -11,7 +11,7 @@ class C extends B { //// [inheritanceGrandParentPrivateMemberCollision.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js index df6e5943173..596982a4794 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js @@ -11,7 +11,7 @@ class C extends B { //// [inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js index 682a8ab4402..ec8ae03b3e3 100644 --- a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js @@ -11,7 +11,7 @@ class C extends B { //// [inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js index d1eb53c4ec7..2da2bcbe6fe 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js @@ -18,7 +18,7 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js index d234eb89582..8b58a7f2b35 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js @@ -15,7 +15,7 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js index b307f3bfedb..1864e62b237 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js @@ -13,7 +13,7 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js index e05ed9633cc..0b24db92a35 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js @@ -15,7 +15,7 @@ class b extends a { } //// [inheritanceMemberFuncOverridingAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js index 747a56b3b3b..bf1186a5cde 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js @@ -12,7 +12,7 @@ class b extends a { } //// [inheritanceMemberFuncOverridingMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js index 1f33f0dfb07..2ecf7edb0e8 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js @@ -10,7 +10,7 @@ class b extends a { } //// [inheritanceMemberFuncOverridingProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js index 7d92b494416..512ca023dee 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js @@ -14,7 +14,7 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js index cf0f4b0b58c..975727031e3 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js @@ -10,7 +10,7 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js index 8cfd68eb30d..b924932e0b4 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js @@ -8,7 +8,7 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js index 7c1eb291327..d62c62410b7 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js @@ -8,7 +8,7 @@ var b3 = new B(); // error, could not select overload for 'new' expression //// [inheritanceOfGenericConstructorMethod1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js index 0db872e52dd..c54f8b4d317 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js @@ -15,7 +15,7 @@ var n3 = new N.D2(); // no error, D2 //// [inheritanceOfGenericConstructorMethod2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js index f7ed912d030..120efc11e27 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js @@ -18,7 +18,7 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js index dbef001740e..7200f37f94b 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js @@ -15,7 +15,7 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js index 3536ca8accb..2fd5e18dab9 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js @@ -13,7 +13,7 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js index b3cc7d3461e..812ac57bfe4 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js @@ -15,7 +15,7 @@ class b extends a { } //// [inheritanceStaticFuncOverridingAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js index bb77561153e..224c0326a87 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js @@ -12,7 +12,7 @@ class b extends a { } //// [inheritanceStaticFuncOverridingAccessorOfFuncType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js index e05a5b245cd..375f07fd905 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js @@ -12,7 +12,7 @@ class b extends a { } //// [inheritanceStaticFuncOverridingMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js index cc8f081f1c6..c4d3f7ca420 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js @@ -10,7 +10,7 @@ class b extends a { } //// [inheritanceStaticFuncOverridingProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js index 3eb016b1e09..f9513f68585 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js @@ -10,7 +10,7 @@ class b extends a { } //// [inheritanceStaticFuncOverridingPropertyOfFuncType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js index 3585fbc3532..f64615e8a7c 100644 --- a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js +++ b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js @@ -10,7 +10,7 @@ class b extends a { } //// [inheritanceStaticFunctionOverridingInstanceProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticMembersCompatible.js b/tests/baselines/reference/inheritanceStaticMembersCompatible.js index 5fe4a2d002d..f1e288c57f5 100644 --- a/tests/baselines/reference/inheritanceStaticMembersCompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersCompatible.js @@ -8,7 +8,7 @@ class b extends a { } //// [inheritanceStaticMembersCompatible.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js index 48b54dd47d3..66ad8612538 100644 --- a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js @@ -8,7 +8,7 @@ class b extends a { } //// [inheritanceStaticMembersIncompatible.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js index da3a42eafe1..310f2127e7e 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js @@ -12,7 +12,7 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingAccessor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js index db25abeafd9..3e8a444d772 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js @@ -10,7 +10,7 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js index f75becd518c..088cfa9b1f9 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js @@ -8,7 +8,7 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingProperty.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams.js b/tests/baselines/reference/inheritedConstructorWithRestParams.js index b924fe25db9..45f4fe72535 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams.js @@ -15,7 +15,7 @@ new Derived("", 3); new Derived(3); //// [inheritedConstructorWithRestParams.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams2.js b/tests/baselines/reference/inheritedConstructorWithRestParams2.js index 2c59c91dde7..eeb0413d1ec 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams2.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams2.js @@ -35,7 +35,7 @@ new Derived("", 3, "", 3); new Derived("", 3, "", ""); //// [inheritedConstructorWithRestParams2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/inheritedModuleMembersForClodule.js b/tests/baselines/reference/inheritedModuleMembersForClodule.js index 0c9bcd81905..75a2f13fed7 100644 --- a/tests/baselines/reference/inheritedModuleMembersForClodule.js +++ b/tests/baselines/reference/inheritedModuleMembersForClodule.js @@ -22,7 +22,7 @@ class E extends D { //// [inheritedModuleMembersForClodule.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js index 7ab3b4a0aa3..9e8e6d26b31 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js @@ -43,7 +43,7 @@ module Generic { } //// [instancePropertiesInheritedIntoClassType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/instanceSubtypeCheck2.js b/tests/baselines/reference/instanceSubtypeCheck2.js index f2b709194b3..e02a2b2afad 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.js +++ b/tests/baselines/reference/instanceSubtypeCheck2.js @@ -8,7 +8,7 @@ class C2 extends C1 { } //// [instanceSubtypeCheck2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/instantiatedReturnTypeContravariance.js b/tests/baselines/reference/instantiatedReturnTypeContravariance.js index 6b84c40d8fd..678f324797f 100644 --- a/tests/baselines/reference/instantiatedReturnTypeContravariance.js +++ b/tests/baselines/reference/instantiatedReturnTypeContravariance.js @@ -31,7 +31,7 @@ return null; //// [instantiatedReturnTypeContravariance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/interfaceExtendsClass1.js b/tests/baselines/reference/interfaceExtendsClass1.js index d376f2dca98..5e72b36ef30 100644 --- a/tests/baselines/reference/interfaceExtendsClass1.js +++ b/tests/baselines/reference/interfaceExtendsClass1.js @@ -19,7 +19,7 @@ class Location { //// [interfaceExtendsClass1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js index 521a71199ad..dac502b9ca3 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js @@ -28,7 +28,7 @@ c = d; d = c; // error //// [interfaceExtendsClassWithPrivate1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js index c177f2e7a90..c6a11c1d3ab 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js @@ -24,7 +24,7 @@ class D2 extends C implements I { // error } //// [interfaceExtendsClassWithPrivate2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/interfaceImplementation8.js b/tests/baselines/reference/interfaceImplementation8.js index e6848b5baf9..64b4c453829 100644 --- a/tests/baselines/reference/interfaceImplementation8.js +++ b/tests/baselines/reference/interfaceImplementation8.js @@ -41,7 +41,7 @@ class C8 extends C7 implements i2{ //// [interfaceImplementation8.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt index 7794fb027d7..fb29c829947 100644 --- a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt +++ b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(5,12): error TS2304: Cannot find name 'V'. -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(11,12): error TS2304: Cannot find name 'C'. -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(17,12): error TS2304: Cannot find name 'E'. -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2304: Cannot find name 'I'. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(5,12): error TS2503: Cannot find namespace 'V'. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(11,12): error TS2503: Cannot find namespace 'C'. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(17,12): error TS2503: Cannot find namespace 'E'. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2503: Cannot find namespace 'I'. ==== tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts (4 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import v = V; ~ -!!! error TS2304: Cannot find name 'V'. +!!! error TS2503: Cannot find namespace 'V'. class C { name: string; @@ -19,7 +19,7 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import c = C; ~ -!!! error TS2304: Cannot find name 'C'. +!!! error TS2503: Cannot find namespace 'C'. enum E { Red, Blue @@ -27,7 +27,7 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import e = E; ~ -!!! error TS2304: Cannot find name 'E'. +!!! error TS2503: Cannot find namespace 'E'. interface I { id: number; @@ -35,5 +35,5 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import i = I; ~ -!!! error TS2304: Cannot find name 'I'. +!!! error TS2503: Cannot find namespace 'I'. \ No newline at end of file diff --git a/tests/baselines/reference/invalidInstantiatedModule.errors.txt b/tests/baselines/reference/invalidInstantiatedModule.errors.txt index 8bd7e6492c0..540f22f5951 100644 --- a/tests/baselines/reference/invalidInstantiatedModule.errors.txt +++ b/tests/baselines/reference/invalidInstantiatedModule.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(2,18): error TS2300: Duplicate identifier 'Point'. tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(3,16): error TS2300: Duplicate identifier 'Point'. -tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2304: Cannot find name 'm'. +tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2503: Cannot find namespace 'm'. ==== tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts (3 errors) ==== @@ -21,7 +21,7 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedMo var m = M2; var p: m.Point; // Error ~ -!!! error TS2304: Cannot find name 'm'. +!!! error TS2503: Cannot find namespace 'm'. \ No newline at end of file diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js index 077d7ddbcdc..4b3ab1b6d88 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js @@ -80,7 +80,7 @@ module YYY4 { //// [invalidModuleWithStatementsOfEveryKind.js] // All of these should be an error -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.js b/tests/baselines/reference/invalidMultipleVariableDeclarations.js index 824bee92227..31d0e44c918 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.js +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.js @@ -54,7 +54,7 @@ var m: typeof M; var m = M.A; //// [invalidMultipleVariableDeclarations.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/invalidReturnStatements.js b/tests/baselines/reference/invalidReturnStatements.js index d637158780a..50977334f4c 100644 --- a/tests/baselines/reference/invalidReturnStatements.js +++ b/tests/baselines/reference/invalidReturnStatements.js @@ -21,7 +21,7 @@ function fn11(): D { return new C(); } //// [invalidReturnStatements.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index ae0acb823a0..c6025123179 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -23,7 +23,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 38a9b18e2d1..07b1fb52af8 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -37,7 +37,7 @@ class FooIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 118bea4d0b4..001cb99b486 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -37,7 +37,7 @@ class FooIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index 832d8ecf69c..7085fd224f4 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -36,7 +36,7 @@ class FooIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 0f4e7682235..09a6984cb3c 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -23,7 +23,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 32907a90b20..4ee65a10825 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -38,7 +38,7 @@ class FooIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index d291c3b128b..0f50713b43d 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1867, 1), Decl(lib.d.ts, 1889, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 473262707b0..aa5ce5783a0 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -38,7 +38,7 @@ class FooIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 7e188f1c94e..01cfba0f09e 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -33,7 +33,7 @@ class FooIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index 90b025ddbb0..76d94dc2923 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index c535fe5426f..f53e8266baa 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -22,7 +22,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index 7df50594c22..b128803aa50 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1633, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1663, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index 48f2f853db8..db8da1bac9d 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -23,7 +23,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; @@ -49,7 +49,7 @@ class NumberIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index b55f8e415ff..bdc200c25ec 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -22,7 +22,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index a1cba88d942..c49ea74dc23 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -22,7 +22,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index c9b8bba1090..e7fbdac2264 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -27,7 +27,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index fbc31e96020..54ac770c5df 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -29,7 +29,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 66a8fc2f667..8b24ba5d1b7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -32,7 +32,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; @@ -58,7 +58,7 @@ class StringIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 121c10ec977..d43a7f9b4fc 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -26,7 +26,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 5e88a2be8a1..9d86858eb8e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -27,7 +27,7 @@ class SymbolIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; @@ -53,7 +53,7 @@ class StringIterator { [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) return this; diff --git a/tests/baselines/reference/lambdaArgCrash.js b/tests/baselines/reference/lambdaArgCrash.js index d3de40dcb0b..0f71ae803d6 100644 --- a/tests/baselines/reference/lambdaArgCrash.js +++ b/tests/baselines/reference/lambdaArgCrash.js @@ -35,7 +35,7 @@ class ItemSetEvent extends Event { //// [lambdaArgCrash.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/lift.js b/tests/baselines/reference/lift.js index 33f8200530b..eaaf94e7024 100644 --- a/tests/baselines/reference/lift.js +++ b/tests/baselines/reference/lift.js @@ -18,7 +18,7 @@ class C extends B { //// [lift.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/m7Bugs.js b/tests/baselines/reference/m7Bugs.js index bd5a0f24c61..72829316fb8 100644 --- a/tests/baselines/reference/m7Bugs.js +++ b/tests/baselines/reference/m7Bugs.js @@ -27,7 +27,7 @@ var y3: C1 = {}; //// [m7Bugs.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js index e9f16103535..389bbfa63dd 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js @@ -32,7 +32,7 @@ var r = a.x; // error var r2 = a.w; // error //// [mergedInterfacesWithInheritedPrivates2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js index a58a62de267..d088aab3d3c 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js @@ -39,7 +39,7 @@ module M { } //// [mergedInterfacesWithInheritedPrivates3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/missingDecoratorType.js b/tests/baselines/reference/missingDecoratorType.js index 974c884ecd1..4460abdc798 100644 --- a/tests/baselines/reference/missingDecoratorType.js +++ b/tests/baselines/reference/missingDecoratorType.js @@ -22,7 +22,7 @@ class C { //// [a.js] //// [b.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); diff --git a/tests/baselines/reference/moduleAsBaseType.js b/tests/baselines/reference/moduleAsBaseType.js index 2537611ddbc..c2246be8795 100644 --- a/tests/baselines/reference/moduleAsBaseType.js +++ b/tests/baselines/reference/moduleAsBaseType.js @@ -5,7 +5,7 @@ interface I extends M { } class C2 implements M { } //// [moduleAsBaseType.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js index 62518b7ae01..e8e08eed26c 100644 --- a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js +++ b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js @@ -15,7 +15,7 @@ class Test1 extends C1 { define(["require", "exports"], function (require, exports) { }); //// [moduleImportedForTypeArgumentPosition_1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js index 8ce4cb693f7..6c0f625f986 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js @@ -59,7 +59,7 @@ module Y { //// [moduleWithStatementsOfEveryKind.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt index c85e7584139..14b7769d22f 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(1,1): error TS1108: A 'return' statement can only be used within a function body. tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(2,18): error TS2304: Cannot find name 'Role'. -tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(4,26): error TS2304: Cannot find name 'ng'. +tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(4,26): error TS2503: Cannot find namespace 'ng'. ==== tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts (3 errors) ==== @@ -13,5 +13,5 @@ tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(4,26): er this.roleService.add(role) .then((data: ng.IHttpPromiseCallbackArg) => data.data)); ~~ -!!! error TS2304: Cannot find name 'ng'. +!!! error TS2503: Cannot find namespace 'ng'. \ No newline at end of file diff --git a/tests/baselines/reference/multipleInheritance.js b/tests/baselines/reference/multipleInheritance.js index 269d5c2ea19..ea4a7156df9 100644 --- a/tests/baselines/reference/multipleInheritance.js +++ b/tests/baselines/reference/multipleInheritance.js @@ -39,7 +39,7 @@ class Baad extends Good { //// [multipleInheritance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js index 76fd13aa320..9b3d6f31291 100644 --- a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js +++ b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js @@ -11,7 +11,7 @@ var test = new foo(); //// [mutuallyRecursiveGenericBaseTypes2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/narrowTypeByInstanceof.js b/tests/baselines/reference/narrowTypeByInstanceof.js new file mode 100644 index 00000000000..11f55089bda --- /dev/null +++ b/tests/baselines/reference/narrowTypeByInstanceof.js @@ -0,0 +1,53 @@ +//// [narrowTypeByInstanceof.ts] + class Match { + public range(): any { + return undefined; + } + } + + class FileMatch { + public resource(): any { + return undefined; + } + } + +type FileMatchOrMatch = FileMatch | Match; + + +let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; + +if (elementA instanceof FileMatch && elementB instanceof FileMatch) { + let a = elementA.resource().path; + let b = elementB.resource().path; +} else if (elementA instanceof Match && elementB instanceof Match) { + let a = elementA.range(); + let b = elementB.range(); +} + + +//// [narrowTypeByInstanceof.js] +var Match = (function () { + function Match() { + } + Match.prototype.range = function () { + return undefined; + }; + return Match; +})(); +var FileMatch = (function () { + function FileMatch() { + } + FileMatch.prototype.resource = function () { + return undefined; + }; + return FileMatch; +})(); +var elementA, elementB; +if (elementA instanceof FileMatch && elementB instanceof FileMatch) { + var a = elementA.resource().path; + var b = elementB.resource().path; +} +else if (elementA instanceof Match && elementB instanceof Match) { + var a = elementA.range(); + var b = elementB.range(); +} diff --git a/tests/baselines/reference/narrowTypeByInstanceof.symbols b/tests/baselines/reference/narrowTypeByInstanceof.symbols new file mode 100644 index 00000000000..3e620fd105c --- /dev/null +++ b/tests/baselines/reference/narrowTypeByInstanceof.symbols @@ -0,0 +1,72 @@ +=== tests/cases/compiler/narrowTypeByInstanceof.ts === + class Match { +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) + + public range(): any { +>range : Symbol(range, Decl(narrowTypeByInstanceof.ts, 0, 17)) + + return undefined; +>undefined : Symbol(undefined) + } + } + + class FileMatch { +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) + + public resource(): any { +>resource : Symbol(resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) + + return undefined; +>undefined : Symbol(undefined) + } + } + +type FileMatchOrMatch = FileMatch | Match; +>FileMatchOrMatch : Symbol(FileMatchOrMatch, Decl(narrowTypeByInstanceof.ts, 10, 5)) +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) + + +let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) +>FileMatchOrMatch : Symbol(FileMatchOrMatch, Decl(narrowTypeByInstanceof.ts, 10, 5)) +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) +>FileMatchOrMatch : Symbol(FileMatchOrMatch, Decl(narrowTypeByInstanceof.ts, 10, 5)) + +if (elementA instanceof FileMatch && elementB instanceof FileMatch) { +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) + + let a = elementA.resource().path; +>a : Symbol(a, Decl(narrowTypeByInstanceof.ts, 18, 7)) +>elementA.resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) +>resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) + + let b = elementB.resource().path; +>b : Symbol(b, Decl(narrowTypeByInstanceof.ts, 19, 7)) +>elementB.resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) +>resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) + +} else if (elementA instanceof Match && elementB instanceof Match) { +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) + + let a = elementA.range(); +>a : Symbol(a, Decl(narrowTypeByInstanceof.ts, 21, 7)) +>elementA.range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) +>range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) + + let b = elementB.range(); +>b : Symbol(b, Decl(narrowTypeByInstanceof.ts, 22, 7)) +>elementB.range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) +>range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) +} + diff --git a/tests/baselines/reference/narrowTypeByInstanceof.types b/tests/baselines/reference/narrowTypeByInstanceof.types new file mode 100644 index 00000000000..b98b1e4d234 --- /dev/null +++ b/tests/baselines/reference/narrowTypeByInstanceof.types @@ -0,0 +1,86 @@ +=== tests/cases/compiler/narrowTypeByInstanceof.ts === + class Match { +>Match : Match + + public range(): any { +>range : () => any + + return undefined; +>undefined : undefined + } + } + + class FileMatch { +>FileMatch : FileMatch + + public resource(): any { +>resource : () => any + + return undefined; +>undefined : undefined + } + } + +type FileMatchOrMatch = FileMatch | Match; +>FileMatchOrMatch : Match | FileMatch +>FileMatch : FileMatch +>Match : Match + + +let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; +>elementA : Match | FileMatch +>FileMatchOrMatch : Match | FileMatch +>elementB : Match | FileMatch +>FileMatchOrMatch : Match | FileMatch + +if (elementA instanceof FileMatch && elementB instanceof FileMatch) { +>elementA instanceof FileMatch && elementB instanceof FileMatch : boolean +>elementA instanceof FileMatch : boolean +>elementA : Match | FileMatch +>FileMatch : typeof FileMatch +>elementB instanceof FileMatch : boolean +>elementB : Match | FileMatch +>FileMatch : typeof FileMatch + + let a = elementA.resource().path; +>a : any +>elementA.resource().path : any +>elementA.resource() : any +>elementA.resource : () => any +>elementA : FileMatch +>resource : () => any +>path : any + + let b = elementB.resource().path; +>b : any +>elementB.resource().path : any +>elementB.resource() : any +>elementB.resource : () => any +>elementB : FileMatch +>resource : () => any +>path : any + +} else if (elementA instanceof Match && elementB instanceof Match) { +>elementA instanceof Match && elementB instanceof Match : boolean +>elementA instanceof Match : boolean +>elementA : Match | FileMatch +>Match : typeof Match +>elementB instanceof Match : boolean +>elementB : Match | FileMatch +>Match : typeof Match + + let a = elementA.range(); +>a : any +>elementA.range() : any +>elementA.range : () => any +>elementA : Match +>range : () => any + + let b = elementB.range(); +>b : any +>elementB.range() : any +>elementB.range : () => any +>elementB : Match +>range : () => any +} + diff --git a/tests/baselines/reference/newLineFlagWithCRLF.js b/tests/baselines/reference/newLineFlagWithCRLF.js new file mode 100644 index 00000000000..9aaaea41fad --- /dev/null +++ b/tests/baselines/reference/newLineFlagWithCRLF.js @@ -0,0 +1,9 @@ +//// [newLineFlagWithCRLF.ts] +var x=1; +x=2; + + + +//// [newLineFlagWithCRLF.js] +var x = 1; +x = 2; diff --git a/tests/baselines/reference/newLineFlagWithCRLF.symbols b/tests/baselines/reference/newLineFlagWithCRLF.symbols new file mode 100644 index 00000000000..0bf676067e4 --- /dev/null +++ b/tests/baselines/reference/newLineFlagWithCRLF.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/newLineFlagWithCRLF.ts === +var x=1; +>x : Symbol(x, Decl(newLineFlagWithCRLF.ts, 0, 3)) + +x=2; +>x : Symbol(x, Decl(newLineFlagWithCRLF.ts, 0, 3)) + + diff --git a/tests/baselines/reference/newLineFlagWithCRLF.types b/tests/baselines/reference/newLineFlagWithCRLF.types new file mode 100644 index 00000000000..4898d2495b2 --- /dev/null +++ b/tests/baselines/reference/newLineFlagWithCRLF.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/newLineFlagWithCRLF.ts === +var x=1; +>x : number +>1 : number + +x=2; +>x=2 : number +>x : number +>2 : number + + diff --git a/tests/baselines/reference/newLineFlagWithLF.js b/tests/baselines/reference/newLineFlagWithLF.js new file mode 100644 index 00000000000..f516cb9b7fc --- /dev/null +++ b/tests/baselines/reference/newLineFlagWithLF.js @@ -0,0 +1,9 @@ +//// [newLineFlagWithLF.ts] +var x=1; +x=2; + + + +//// [newLineFlagWithLF.js] +var x = 1; +x = 2; diff --git a/tests/baselines/reference/newLineFlagWithLF.symbols b/tests/baselines/reference/newLineFlagWithLF.symbols new file mode 100644 index 00000000000..a8964eebd14 --- /dev/null +++ b/tests/baselines/reference/newLineFlagWithLF.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/newLineFlagWithLF.ts === +var x=1; +>x : Symbol(x, Decl(newLineFlagWithLF.ts, 0, 3)) + +x=2; +>x : Symbol(x, Decl(newLineFlagWithLF.ts, 0, 3)) + + diff --git a/tests/baselines/reference/newLineFlagWithLF.types b/tests/baselines/reference/newLineFlagWithLF.types new file mode 100644 index 00000000000..bfdf6072e0e --- /dev/null +++ b/tests/baselines/reference/newLineFlagWithLF.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/newLineFlagWithLF.ts === +var x=1; +>x : number +>1 : number + +x=2; +>x=2 : number +>x : number +>2 : number + + diff --git a/tests/baselines/reference/noEmitHelpers.js b/tests/baselines/reference/noEmitHelpers.js new file mode 100644 index 00000000000..bfe5a4f4445 --- /dev/null +++ b/tests/baselines/reference/noEmitHelpers.js @@ -0,0 +1,19 @@ +//// [noEmitHelpers.ts] + +class A { } +class B extends A { } + + +//// [noEmitHelpers.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); diff --git a/tests/baselines/reference/noEmitHelpers.symbols b/tests/baselines/reference/noEmitHelpers.symbols new file mode 100644 index 00000000000..654f1a6cad5 --- /dev/null +++ b/tests/baselines/reference/noEmitHelpers.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/noEmitHelpers.ts === + +class A { } +>A : Symbol(A, Decl(noEmitHelpers.ts, 0, 0)) + +class B extends A { } +>B : Symbol(B, Decl(noEmitHelpers.ts, 1, 11)) +>A : Symbol(A, Decl(noEmitHelpers.ts, 0, 0)) + diff --git a/tests/baselines/reference/noEmitHelpers.types b/tests/baselines/reference/noEmitHelpers.types new file mode 100644 index 00000000000..01c5d5acb3d --- /dev/null +++ b/tests/baselines/reference/noEmitHelpers.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/noEmitHelpers.ts === + +class A { } +>A : A + +class B extends A { } +>B : B +>A : A + diff --git a/tests/baselines/reference/noEmitHelpers2.js b/tests/baselines/reference/noEmitHelpers2.js new file mode 100644 index 00000000000..1bd42377679 --- /dev/null +++ b/tests/baselines/reference/noEmitHelpers2.js @@ -0,0 +1,22 @@ +//// [noEmitHelpers2.ts] + +function decorator() { } + +@decorator +class A { + constructor(a: number, @decorator b: string) { + } +} + +//// [noEmitHelpers2.js] +function decorator() { } +var A = (function () { + function A(a, b) { + } + A = __decorate([ + decorator, + __param(1, decorator), + __metadata('design:paramtypes', [Number, String]) + ], A); + return A; +})(); diff --git a/tests/baselines/reference/noEmitHelpers2.symbols b/tests/baselines/reference/noEmitHelpers2.symbols new file mode 100644 index 00000000000..3a3e3ec94c7 --- /dev/null +++ b/tests/baselines/reference/noEmitHelpers2.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/noEmitHelpers2.ts === + +function decorator() { } +>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0)) + +@decorator +>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0)) + +class A { +>A : Symbol(A, Decl(noEmitHelpers2.ts, 1, 24)) + + constructor(a: number, @decorator b: string) { +>a : Symbol(a, Decl(noEmitHelpers2.ts, 5, 16)) +>decorator : Symbol(decorator, Decl(noEmitHelpers2.ts, 0, 0)) +>b : Symbol(b, Decl(noEmitHelpers2.ts, 5, 26)) + } +} diff --git a/tests/baselines/reference/noEmitHelpers2.types b/tests/baselines/reference/noEmitHelpers2.types new file mode 100644 index 00000000000..2a5b5413a7e --- /dev/null +++ b/tests/baselines/reference/noEmitHelpers2.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/noEmitHelpers2.ts === + +function decorator() { } +>decorator : () => void + +@decorator +>decorator : () => void + +class A { +>A : A + + constructor(a: number, @decorator b: string) { +>a : number +>decorator : () => void +>b : string + } +} diff --git a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js index 560c8c3cbd7..b687162c154 100644 --- a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js +++ b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js @@ -6,7 +6,7 @@ class Foo { class Bar extends Foo { } // Valid //// [nonGenericClassExtendingGenericClassWithAny.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js index 0474abef393..fe1e4768672 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js @@ -47,7 +47,7 @@ var b: { [x: number]: A } = { //// [numericIndexerConstrainsPropertyDeclarations2.js] // String indexer providing a constraint of a user defined type -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/numericIndexerConstraint3.js b/tests/baselines/reference/numericIndexerConstraint3.js index 4f4fd826c25..724db29f557 100644 --- a/tests/baselines/reference/numericIndexerConstraint3.js +++ b/tests/baselines/reference/numericIndexerConstraint3.js @@ -13,7 +13,7 @@ class C { } //// [numericIndexerConstraint3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/numericIndexerConstraint4.js b/tests/baselines/reference/numericIndexerConstraint4.js index 531c450e7e1..404a9394bf7 100644 --- a/tests/baselines/reference/numericIndexerConstraint4.js +++ b/tests/baselines/reference/numericIndexerConstraint4.js @@ -12,7 +12,7 @@ var x: { } = { data: new B() } //// [numericIndexerConstraint4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/numericIndexerTyping2.js b/tests/baselines/reference/numericIndexerTyping2.js index 424f56b6214..c5e91e9dfc0 100644 --- a/tests/baselines/reference/numericIndexerTyping2.js +++ b/tests/baselines/reference/numericIndexerTyping2.js @@ -13,7 +13,7 @@ var i2: I2; var r2: string = i2[1]; // error: numeric indexer returns the type of the string indexere //// [numericIndexerTyping2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.js b/tests/baselines/reference/objectCreationOfElementAccessExpression.js index f3c5760ae63..45d56a1d716 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.js +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.js @@ -56,7 +56,7 @@ var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Co //// [objectCreationOfElementAccessExpression.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectLiteralContextualTyping.js b/tests/baselines/reference/objectLiteralContextualTyping.js index 48686042754..52a2db3d0c8 100644 --- a/tests/baselines/reference/objectLiteralContextualTyping.js +++ b/tests/baselines/reference/objectLiteralContextualTyping.js @@ -1,5 +1,8 @@ //// [objectLiteralContextualTyping.ts] -// Tests related to #1774 +// In a contextually typed object literal, each property value expression is contextually typed by +// the type of the property with a matching name in the contextual type, if any, or otherwise +// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise +// the string index type of the contextual type, if any. interface Item { name: string; @@ -28,7 +31,10 @@ var b: {}; //// [objectLiteralContextualTyping.js] -// Tests related to #1774 +// In a contextually typed object literal, each property value expression is contextually typed by +// the type of the property with a matching name in the contextual type, if any, or otherwise +// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise +// the string index type of the contextual type, if any. var x = foo({ name: "Sprocket" }); var x; var y = foo({ name: "Sprocket", description: "Bumpy wheel" }); diff --git a/tests/baselines/reference/objectLiteralContextualTyping.symbols b/tests/baselines/reference/objectLiteralContextualTyping.symbols index 6e8f2e5f333..23a468eac3f 100644 --- a/tests/baselines/reference/objectLiteralContextualTyping.symbols +++ b/tests/baselines/reference/objectLiteralContextualTyping.symbols @@ -1,71 +1,74 @@ === tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts === -// Tests related to #1774 +// In a contextually typed object literal, each property value expression is contextually typed by +// the type of the property with a matching name in the contextual type, if any, or otherwise +// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise +// the string index type of the contextual type, if any. interface Item { >Item : Symbol(Item, Decl(objectLiteralContextualTyping.ts, 0, 0)) name: string; ->name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 2, 16)) +>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 5, 16)) description?: string; ->description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 3, 17)) +>description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 6, 17)) } declare function foo(item: Item): string; ->foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41)) ->item : Symbol(item, Decl(objectLiteralContextualTyping.ts, 7, 21)) +>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 8, 1), Decl(objectLiteralContextualTyping.ts, 10, 41)) +>item : Symbol(item, Decl(objectLiteralContextualTyping.ts, 10, 21)) >Item : Symbol(Item, Decl(objectLiteralContextualTyping.ts, 0, 0)) declare function foo(item: any): number; ->foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41)) ->item : Symbol(item, Decl(objectLiteralContextualTyping.ts, 8, 21)) +>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 8, 1), Decl(objectLiteralContextualTyping.ts, 10, 41)) +>item : Symbol(item, Decl(objectLiteralContextualTyping.ts, 11, 21)) var x = foo({ name: "Sprocket" }); ->x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 10, 3), Decl(objectLiteralContextualTyping.ts, 11, 3)) ->foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41)) ->name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 10, 13)) +>x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 13, 3), Decl(objectLiteralContextualTyping.ts, 14, 3)) +>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 8, 1), Decl(objectLiteralContextualTyping.ts, 10, 41)) +>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 13, 13)) var x: string; ->x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 10, 3), Decl(objectLiteralContextualTyping.ts, 11, 3)) +>x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 13, 3), Decl(objectLiteralContextualTyping.ts, 14, 3)) var y = foo({ name: "Sprocket", description: "Bumpy wheel" }); ->y : Symbol(y, Decl(objectLiteralContextualTyping.ts, 13, 3), Decl(objectLiteralContextualTyping.ts, 14, 3)) ->foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41)) ->name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 13, 13)) ->description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 13, 31)) - -var y: string; ->y : Symbol(y, Decl(objectLiteralContextualTyping.ts, 13, 3), Decl(objectLiteralContextualTyping.ts, 14, 3)) - -var z = foo({ name: "Sprocket", description: false }); ->z : Symbol(z, Decl(objectLiteralContextualTyping.ts, 16, 3), Decl(objectLiteralContextualTyping.ts, 17, 3)) ->foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41)) +>y : Symbol(y, Decl(objectLiteralContextualTyping.ts, 16, 3), Decl(objectLiteralContextualTyping.ts, 17, 3)) +>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 8, 1), Decl(objectLiteralContextualTyping.ts, 10, 41)) >name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 16, 13)) >description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 16, 31)) +var y: string; +>y : Symbol(y, Decl(objectLiteralContextualTyping.ts, 16, 3), Decl(objectLiteralContextualTyping.ts, 17, 3)) + +var z = foo({ name: "Sprocket", description: false }); +>z : Symbol(z, Decl(objectLiteralContextualTyping.ts, 19, 3), Decl(objectLiteralContextualTyping.ts, 20, 3)) +>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 8, 1), Decl(objectLiteralContextualTyping.ts, 10, 41)) +>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 19, 13)) +>description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 19, 31)) + var z: number; ->z : Symbol(z, Decl(objectLiteralContextualTyping.ts, 16, 3), Decl(objectLiteralContextualTyping.ts, 17, 3)) +>z : Symbol(z, Decl(objectLiteralContextualTyping.ts, 19, 3), Decl(objectLiteralContextualTyping.ts, 20, 3)) var w = foo({ a: 10 }); ->w : Symbol(w, Decl(objectLiteralContextualTyping.ts, 19, 3), Decl(objectLiteralContextualTyping.ts, 20, 3)) ->foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41)) ->a : Symbol(a, Decl(objectLiteralContextualTyping.ts, 19, 13)) +>w : Symbol(w, Decl(objectLiteralContextualTyping.ts, 22, 3), Decl(objectLiteralContextualTyping.ts, 23, 3)) +>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 8, 1), Decl(objectLiteralContextualTyping.ts, 10, 41)) +>a : Symbol(a, Decl(objectLiteralContextualTyping.ts, 22, 13)) var w: number; ->w : Symbol(w, Decl(objectLiteralContextualTyping.ts, 19, 3), Decl(objectLiteralContextualTyping.ts, 20, 3)) +>w : Symbol(w, Decl(objectLiteralContextualTyping.ts, 22, 3), Decl(objectLiteralContextualTyping.ts, 23, 3)) declare function bar(param: { x?: T }): T; ->bar : Symbol(bar, Decl(objectLiteralContextualTyping.ts, 20, 14)) ->T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 22, 21)) ->param : Symbol(param, Decl(objectLiteralContextualTyping.ts, 22, 24)) ->x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 22, 32)) ->T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 22, 21)) ->T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 22, 21)) +>bar : Symbol(bar, Decl(objectLiteralContextualTyping.ts, 23, 14)) +>T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 25, 21)) +>param : Symbol(param, Decl(objectLiteralContextualTyping.ts, 25, 24)) +>x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 25, 32)) +>T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 25, 21)) +>T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 25, 21)) var b = bar({}); ->b : Symbol(b, Decl(objectLiteralContextualTyping.ts, 24, 3), Decl(objectLiteralContextualTyping.ts, 25, 3)) ->bar : Symbol(bar, Decl(objectLiteralContextualTyping.ts, 20, 14)) +>b : Symbol(b, Decl(objectLiteralContextualTyping.ts, 27, 3), Decl(objectLiteralContextualTyping.ts, 28, 3)) +>bar : Symbol(bar, Decl(objectLiteralContextualTyping.ts, 23, 14)) var b: {}; ->b : Symbol(b, Decl(objectLiteralContextualTyping.ts, 24, 3), Decl(objectLiteralContextualTyping.ts, 25, 3)) +>b : Symbol(b, Decl(objectLiteralContextualTyping.ts, 27, 3), Decl(objectLiteralContextualTyping.ts, 28, 3)) diff --git a/tests/baselines/reference/objectLiteralContextualTyping.types b/tests/baselines/reference/objectLiteralContextualTyping.types index 7668b01d32c..8100b7a5446 100644 --- a/tests/baselines/reference/objectLiteralContextualTyping.types +++ b/tests/baselines/reference/objectLiteralContextualTyping.types @@ -1,5 +1,8 @@ === tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts === -// Tests related to #1774 +// In a contextually typed object literal, each property value expression is contextually typed by +// the type of the property with a matching name in the contextual type, if any, or otherwise +// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise +// the string index type of the contextual type, if any. interface Item { >Item : Item diff --git a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js index 16268c1331c..339f6b23f6a 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js +++ b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js @@ -55,7 +55,7 @@ var b: { var r4: void = b.valueOf(); //// [objectTypeHidingMembersOfExtendedObject.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js index 1dc6505456a..8f6d1706e40 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js @@ -124,7 +124,7 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers1.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js index e2fd1b99bfa..8f5b6449a88 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js @@ -127,7 +127,7 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers2.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js index 11d64efc9d5..2fc8c0c946d 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js @@ -124,7 +124,7 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers3.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates.js b/tests/baselines/reference/objectTypesIdentityWithPrivates.js index 5c8a0afed72..a68eba8c6a2 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates.js @@ -122,7 +122,7 @@ function foo16(x: any) { } //// [objectTypesIdentityWithPrivates.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js index 36c3e67c70e..92aac37ecdb 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js @@ -40,7 +40,7 @@ function foo6(x: any): any { } //// [objectTypesIdentityWithPrivates2.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js index 7c8dac97250..c202f684895 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js @@ -26,7 +26,7 @@ var c3: C3; c3; // Should fail (private x originates in the same declaration, but different types) //// [objectTypesIdentityWithPrivates3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js index 37c5537aa4b..98693b4e6ee 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js @@ -124,7 +124,7 @@ function foo16(x: any) { } //// [objectTypesIdentityWithStringIndexers.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js index e90dc8598e4..7e9abbad7e6 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js @@ -127,7 +127,7 @@ function foo16(x: any) { } //// [objectTypesIdentityWithStringIndexers2.js] // object types are identical structurally -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/optionalConstructorArgInSuper.js b/tests/baselines/reference/optionalConstructorArgInSuper.js index 5204d7f8307..2ac23c39be5 100644 --- a/tests/baselines/reference/optionalConstructorArgInSuper.js +++ b/tests/baselines/reference/optionalConstructorArgInSuper.js @@ -11,7 +11,7 @@ d2.foo(); //// [optionalConstructorArgInSuper.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/optionalParamArgsTest.js b/tests/baselines/reference/optionalParamArgsTest.js index 5598f8d0872..7538397566a 100644 --- a/tests/baselines/reference/optionalParamArgsTest.js +++ b/tests/baselines/reference/optionalParamArgsTest.js @@ -126,7 +126,7 @@ fnOpt2(1, [2, 3], [1], true); //// [optionalParamArgsTest.js] // Optional parameter and default argument tests -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/optionalParamInOverride.js b/tests/baselines/reference/optionalParamInOverride.js index cfdfce368d0..aa76f41644c 100644 --- a/tests/baselines/reference/optionalParamInOverride.js +++ b/tests/baselines/reference/optionalParamInOverride.js @@ -8,7 +8,7 @@ class Y extends Z { //// [optionalParamInOverride.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overload1.js b/tests/baselines/reference/overload1.js index c7134966cec..b308c0e8d83 100644 --- a/tests/baselines/reference/overload1.js +++ b/tests/baselines/reference/overload1.js @@ -40,7 +40,7 @@ var v=x.g; //// [overload1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks1.js b/tests/baselines/reference/overloadOnConstConstraintChecks1.js index eb613586118..4588bef017b 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks1.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks1.js @@ -23,7 +23,7 @@ class D implements MyDoc { } //// [overloadOnConstConstraintChecks1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks2.js b/tests/baselines/reference/overloadOnConstConstraintChecks2.js index 25759d0a839..709f7808ac1 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks2.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks2.js @@ -12,7 +12,7 @@ function foo(name: any): A { } //// [overloadOnConstConstraintChecks2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks3.js b/tests/baselines/reference/overloadOnConstConstraintChecks3.js index 5980c852f41..7104c441938 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks3.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks3.js @@ -13,7 +13,7 @@ function foo(name: any): A { //// [overloadOnConstConstraintChecks3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks4.js b/tests/baselines/reference/overloadOnConstConstraintChecks4.js index b2ae1125750..4483b42a941 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks4.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks4.js @@ -14,7 +14,7 @@ function foo(name: any): Z { //// [overloadOnConstConstraintChecks4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js index cf9bc526b51..efcad011ab5 100644 --- a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js +++ b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js @@ -12,7 +12,7 @@ function foo(name: "DIV"): Derived2 { foo("HI"); //// [overloadOnConstantsInvalidOverload1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadResolution.js b/tests/baselines/reference/overloadResolution.js index 1ee5e077c08..d234ea4a69a 100644 --- a/tests/baselines/reference/overloadResolution.js +++ b/tests/baselines/reference/overloadResolution.js @@ -95,7 +95,7 @@ var s = fn5((n) => n.substr(0)); //// [overloadResolution.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadResolutionClassConstructors.js b/tests/baselines/reference/overloadResolutionClassConstructors.js index 2571a0e02db..fc7dbd9cebe 100644 --- a/tests/baselines/reference/overloadResolutionClassConstructors.js +++ b/tests/baselines/reference/overloadResolutionClassConstructors.js @@ -102,7 +102,7 @@ new fn5((n) => n.blah); // Error //// [overloadResolutionClassConstructors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadResolutionConstructors.js b/tests/baselines/reference/overloadResolutionConstructors.js index 9e10215b1cb..b3c2b2ef764 100644 --- a/tests/baselines/reference/overloadResolutionConstructors.js +++ b/tests/baselines/reference/overloadResolutionConstructors.js @@ -103,7 +103,7 @@ var s = new fn5((n) => n.substr(0)); //// [overloadResolutionConstructors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadingOnConstants1.js b/tests/baselines/reference/overloadingOnConstants1.js index 7ebeeb2890f..4274841d60f 100644 --- a/tests/baselines/reference/overloadingOnConstants1.js +++ b/tests/baselines/reference/overloadingOnConstants1.js @@ -26,7 +26,7 @@ var htmlDivElement2: Derived1 = d2.createElement("div"); var htmlSpanElement2: Derived1 = d2.createElement("span"); //// [overloadingOnConstants1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overloadingOnConstants2.js b/tests/baselines/reference/overloadingOnConstants2.js index 4a3f49d1b06..2414ec4eab2 100644 --- a/tests/baselines/reference/overloadingOnConstants2.js +++ b/tests/baselines/reference/overloadingOnConstants2.js @@ -28,7 +28,7 @@ var e: E = bar("bye", []); // E var f: C = bar("um", []); // C //// [overloadingOnConstants2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/overridingPrivateStaticMembers.js b/tests/baselines/reference/overridingPrivateStaticMembers.js index 2174f9e298b..56ecfec66c0 100644 --- a/tests/baselines/reference/overridingPrivateStaticMembers.js +++ b/tests/baselines/reference/overridingPrivateStaticMembers.js @@ -8,7 +8,7 @@ class Derived2 extends Base2 { } //// [overridingPrivateStaticMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parseErrorInHeritageClause1.js b/tests/baselines/reference/parseErrorInHeritageClause1.js index d08a4920171..66facdeadf0 100644 --- a/tests/baselines/reference/parseErrorInHeritageClause1.js +++ b/tests/baselines/reference/parseErrorInHeritageClause1.js @@ -3,7 +3,7 @@ class C extends A # { } //// [parseErrorInHeritageClause1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parser509630.js b/tests/baselines/reference/parser509630.js index 0d5a96884f3..20e00ea01ed 100644 --- a/tests/baselines/reference/parser509630.js +++ b/tests/baselines/reference/parser509630.js @@ -7,7 +7,7 @@ class Any extends Type { //// [parser509630.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parser519458.errors.txt b/tests/baselines/reference/parser519458.errors.txt index e618e38723f..66dae596b81 100644 --- a/tests/baselines/reference/parser519458.errors.txt +++ b/tests/baselines/reference/parser519458.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser519458.ts(1,15): error TS2304: Cannot find name 'module'. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser519458.ts(1,15): error TS2503: Cannot find namespace 'module'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser519458.ts(1,21): error TS1005: ';' expected. -==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser519458.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser519458.ts (3 errors) ==== import rect = module("rect"); var bar = new rect.Rect(); ~~~~~~ !!! error TS2304: Cannot find name 'module'. + ~~~~~~ +!!! error TS2503: Cannot find namespace 'module'. ~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserAstSpans1.js b/tests/baselines/reference/parserAstSpans1.js index 64c8f5c0612..ec88d11b0c9 100644 --- a/tests/baselines/reference/parserAstSpans1.js +++ b/tests/baselines/reference/parserAstSpans1.js @@ -220,7 +220,7 @@ class c6 extends c5 { } //// [parserAstSpans1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserClassDeclaration1.js b/tests/baselines/reference/parserClassDeclaration1.js index 1e4fc0d5bcf..9ef865adb75 100644 --- a/tests/baselines/reference/parserClassDeclaration1.js +++ b/tests/baselines/reference/parserClassDeclaration1.js @@ -3,7 +3,7 @@ class C extends A extends B { } //// [parserClassDeclaration1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserClassDeclaration3.js b/tests/baselines/reference/parserClassDeclaration3.js index 99d34bedaed..644c4fcb54a 100644 --- a/tests/baselines/reference/parserClassDeclaration3.js +++ b/tests/baselines/reference/parserClassDeclaration3.js @@ -3,7 +3,7 @@ class C implements A extends B { } //// [parserClassDeclaration3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserClassDeclaration4.js b/tests/baselines/reference/parserClassDeclaration4.js index 3552c74f184..d7cd9ca6cac 100644 --- a/tests/baselines/reference/parserClassDeclaration4.js +++ b/tests/baselines/reference/parserClassDeclaration4.js @@ -3,7 +3,7 @@ class C extends A implements B extends C { } //// [parserClassDeclaration4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserClassDeclaration5.js b/tests/baselines/reference/parserClassDeclaration5.js index 6a7846fd036..4f75eb96668 100644 --- a/tests/baselines/reference/parserClassDeclaration5.js +++ b/tests/baselines/reference/parserClassDeclaration5.js @@ -3,7 +3,7 @@ class C extends A implements B implements C { } //// [parserClassDeclaration5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserClassDeclaration6.js b/tests/baselines/reference/parserClassDeclaration6.js index 24e55a48344..a653a7e4042 100644 --- a/tests/baselines/reference/parserClassDeclaration6.js +++ b/tests/baselines/reference/parserClassDeclaration6.js @@ -3,7 +3,7 @@ class C extends A, B { } //// [parserClassDeclaration6.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js index babceb0f752..43ebfa2bb0e 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js @@ -3,7 +3,7 @@ class C extends A, { } //// [parserErrorRecovery_ExtendsOrImplementsClause2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js index 5c0e793173a..732508b8d85 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js @@ -3,7 +3,7 @@ class C extends A implements { } //// [parserErrorRecovery_ExtendsOrImplementsClause4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js index 40dbcf61820..58f4f4631dc 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js @@ -3,7 +3,7 @@ class C extends A, implements B, { } //// [parserErrorRecovery_ExtendsOrImplementsClause5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt b/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt index 8b9304d9165..75652c829ee 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt +++ b/tests/baselines/reference/parserGenericsInTypeContexts1.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(1,33): error TS2304: Cannot find name 'B'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(4,9): error TS2315: Type 'C' is not generic. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(5,9): error TS2304: Cannot find name 'D'. -tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(6,9): error TS2304: Cannot find name 'E'. -tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(7,9): error TS2304: Cannot find name 'G'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(6,9): error TS2503: Cannot find namespace 'E'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(7,9): error TS2503: Cannot find namespace 'G'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(8,9): error TS2304: Cannot find name 'K'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(11,16): error TS2304: Cannot find name 'E'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(14,16): error TS2304: Cannot find name 'F'. @@ -26,10 +26,10 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts !!! error TS2304: Cannot find name 'D'. var v3: E.F; ~ -!!! error TS2304: Cannot find name 'E'. +!!! error TS2503: Cannot find namespace 'E'. var v3: G.H.I; ~ -!!! error TS2304: Cannot find name 'G'. +!!! error TS2503: Cannot find namespace 'G'. var v6: K[]; ~ !!! error TS2304: Cannot find name 'K'. diff --git a/tests/baselines/reference/parserGenericsInTypeContexts1.js b/tests/baselines/reference/parserGenericsInTypeContexts1.js index a8f6729b3d1..5c2369e61c7 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts1.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts1.js @@ -18,7 +18,7 @@ function f2(): F { //// [parserGenericsInTypeContexts1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt b/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt index 0ef716d1804..c365f461b7c 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt +++ b/tests/baselines/reference/parserGenericsInTypeContexts2.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(1,45): error TS2304: Cannot find name 'B'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(4,9): error TS2315: Type 'C' is not generic. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(5,9): error TS2304: Cannot find name 'D'. -tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(6,9): error TS2304: Cannot find name 'E'. -tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(7,9): error TS2304: Cannot find name 'G'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(6,9): error TS2503: Cannot find namespace 'E'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(7,9): error TS2503: Cannot find namespace 'G'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(8,9): error TS2304: Cannot find name 'K'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(11,16): error TS2304: Cannot find name 'E'. tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(14,16): error TS2304: Cannot find name 'F'. @@ -26,10 +26,10 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts !!! error TS2304: Cannot find name 'D'. var v3: E.F, Y>>; ~ -!!! error TS2304: Cannot find name 'E'. +!!! error TS2503: Cannot find namespace 'E'. var v4: G.H.I, Y>>; ~ -!!! error TS2304: Cannot find name 'G'. +!!! error TS2503: Cannot find namespace 'G'. var v6: K, Y>>[]; ~ !!! error TS2304: Cannot find name 'K'. diff --git a/tests/baselines/reference/parserGenericsInTypeContexts2.js b/tests/baselines/reference/parserGenericsInTypeContexts2.js index 9735d7cab3c..487038e1959 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts2.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts2.js @@ -18,7 +18,7 @@ function f2(): F, Y>> { //// [parserGenericsInTypeContexts2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserImportDeclaration1.errors.txt b/tests/baselines/reference/parserImportDeclaration1.errors.txt index ec3397cd196..099474d3d41 100644 --- a/tests/baselines/reference/parserImportDeclaration1.errors.txt +++ b/tests/baselines/reference/parserImportDeclaration1.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/parserImportDeclaration1.ts(1,21): error TS2304: Cannot find name 'TypeScriptServices'. +tests/cases/conformance/parser/ecmascript5/parserImportDeclaration1.ts(1,21): error TS2503: Cannot find namespace 'TypeScriptServices'. ==== tests/cases/conformance/parser/ecmascript5/parserImportDeclaration1.ts (1 errors) ==== import TypeScript = TypeScriptServices.TypeScript; ~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScriptServices'. \ No newline at end of file +!!! error TS2503: Cannot find namespace 'TypeScriptServices'. \ No newline at end of file diff --git a/tests/baselines/reference/parserRealSource10.js b/tests/baselines/reference/parserRealSource10.js index 2ddc7a8dce2..4c241abba0e 100644 --- a/tests/baselines/reference/parserRealSource10.js +++ b/tests/baselines/reference/parserRealSource10.js @@ -458,7 +458,7 @@ module TypeScript { //// [parserRealSource10.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserRealSource11.js b/tests/baselines/reference/parserRealSource11.js index 72fec692184..c6a08062820 100644 --- a/tests/baselines/reference/parserRealSource11.js +++ b/tests/baselines/reference/parserRealSource11.js @@ -2367,7 +2367,7 @@ module TypeScript { //// [parserRealSource11.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 4d7a9b669e4..54d674ea0a8 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -4,6 +4,6 @@ interface I { [Symbol.iterator]: string; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index ff110a6fe03..51fdb40efd4 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index b75a737af0a..11b6d8de94f 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index 122a46180d2..b2ffc2c89d2 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index f6049c352e9..e896ebbd2a2 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 6f8a8d820be..1859c954ba4 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index abcffb9a1fd..a91a8227ae4 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index 4b2adf9c750..dee98ed1e77 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index cca16d768e6..cffbded17e6 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt b/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt index 569c960404c..7eed3dbe026 100644 --- a/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt +++ b/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2304: Cannot find name 'TypeModule1'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2503: Cannot find namespace 'TypeModule1'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,8): error TS1005: '=' expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,8): error TS2304: Cannot find name 'TypeModule2'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,20): error TS1005: ',' expected. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNam ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (4 errors) ==== var x: TypeModule1. ~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeModule1'. +!!! error TS2503: Cannot find namespace 'TypeModule1'. module TypeModule2 { ~~~~~~~~~~~ !!! error TS1005: '=' expected. diff --git a/tests/baselines/reference/parserVariableDeclaration3.errors.txt b/tests/baselines/reference/parserVariableDeclaration3.errors.txt index bb4e5eceaf6..a2130449f4b 100644 --- a/tests/baselines/reference/parserVariableDeclaration3.errors.txt +++ b/tests/baselines/reference/parserVariableDeclaration3.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts(2,23): error TS2304: Cannot find name 'Harness'. tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts(3,22): error TS2304: Cannot find name 'Harness'. -tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts(4,21): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts(4,21): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration3.ts(4,55): error TS2304: Cannot find name 'TypeScript'. @@ -14,7 +14,7 @@ tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDe !!! error TS2304: Cannot find name 'Harness'. , compiler = new TypeScript.TypeScriptCompiler(outerr) ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. , code; diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index 2452cd76a18..66afa3d010f 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -13,25 +13,25 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(351,17): e tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,17): error TS2304: Cannot find name 'errorHandlerStack'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,35): error TS2304: Cannot find name 'errorHandlerStack'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(691,50): error TS2304: Cannot find name 'ITextWriter'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(716,47): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(716,47): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(721,62): error TS2304: Cannot find name 'ITextWriter'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(724,29): error TS2304: Cannot find name 'ITextWriter'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(754,53): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(764,56): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(764,56): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(765,37): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(767,47): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,13): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,42): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(781,23): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(781,23): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(794,49): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(795,49): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,53): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,89): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,115): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,115): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,145): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(988,43): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(999,40): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1041,43): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(999,40): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1041,43): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1044,26): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1045,26): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1046,26): error TS2304: Cannot find name 'TypeScript'. @@ -44,69 +44,69 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1052,26): tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1053,26): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1055,26): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1058,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1059,34): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1059,34): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1061,26): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1064,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1065,34): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1065,34): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1067,26): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1070,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1071,34): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1071,34): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1073,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1074,34): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1074,34): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1076,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1077,34): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1077,34): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1079,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1080,35): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1080,74): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1107,173): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1176,132): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1080,35): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1080,74): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1107,173): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1176,132): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1193,29): error TS2304: Cannot find name 'WScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1256,126): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1257,25): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1263,31): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1256,126): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1257,25): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1263,31): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1280,45): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1286,124): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1286,209): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1294,142): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1294,227): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1286,124): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1286,209): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1294,142): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1294,227): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1302,43): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1304,39): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1307,38): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1311,45): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1321,21): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1340,38): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1344,165): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1345,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1426,25): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1340,38): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1344,165): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1345,26): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1426,25): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1430,9): error TS1128: Declaration or statement expected. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1430,17): error TS2304: Cannot find name 'optionRegex'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1440,29): error TS2304: Cannot find name 'optionRegex'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1461,23): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1461,23): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1466,36): error TS2304: Cannot find name 'optionRegex'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1484,21): error TS2304: Cannot find name 'optionRegex'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1548,57): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1548,57): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1571,32): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1582,59): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1582,59): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1591,24): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1600,24): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1604,42): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1605,21): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1705,38): error TS2304: Cannot find name 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1604,42): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1605,21): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1705,38): error TS2503: Cannot find namespace 'Services'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1706,26): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1713,62): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1713,87): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1713,62): error TS2503: Cannot find namespace 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1713,87): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1714,30): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1724,34): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1739,20): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1746,80): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1746,80): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1750,26): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1758,84): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1769,51): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1784,39): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1784,61): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1785,25): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,38): error TS2304: Cannot find name 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,68): error TS2304: Cannot find name 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1758,84): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1769,51): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1784,39): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1784,61): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1785,25): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,38): error TS2503: Cannot find namespace 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,68): error TS2503: Cannot find namespace 'Services'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): error TS2304: Cannot find name 'Diff'. @@ -858,7 +858,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /** Mimics having multiple files, later concatenated to a single file. */ export class EmitterIOHost implements TypeScript.EmitterIOHost { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. private fileCollection = {}; @@ -914,7 +914,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export function makeDefaultCompilerForTest(c?: TypeScript.TypeScriptCompiler) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var compiler = c || new TypeScript.TypeScriptCompiler(stderr); ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. @@ -941,7 +941,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): var compiler: TypeScript.TypeScriptCompiler; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. recreate(); // pullUpdateUnit is sufficient if an existing unit is updated, if a new unit is added we need to do a full typecheck @@ -1157,7 +1157,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. var entries = new TypeScript.ScopeTraversal(compiler).getScopeEntries(enclosingScopeContext); @@ -1175,7 +1175,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): for (var m = 0; m < compiler.scripts.members.length; m++) { var script2 = compiler.scripts.members[m]; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. if (script2.locationInfo.filename !== 'lib.d.ts') { if (targetPosition > -1) { var tyInfo = compiler.pullGetTypeInfoAtPosition(targetPosition, script2); @@ -1219,7 +1219,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): private getTypeInfoName(ast : TypeScript.AST) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var name = ''; switch (ast.nodeType) { case TypeScript.NodeType.Name: // Type Name? @@ -1263,7 +1263,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): !!! error TS2304: Cannot find name 'TypeScript'. name = (ast).text; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. break; case TypeScript.NodeType.QString: ~~~~~~~~~~ @@ -1275,7 +1275,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): !!! error TS2304: Cannot find name 'TypeScript'. name = (ast).text; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. break; case TypeScript.NodeType.Return: ~~~~~~~~~~ @@ -1287,30 +1287,30 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): !!! error TS2304: Cannot find name 'TypeScript'. name = (ast).name.actualText; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. break; case TypeScript.NodeType.ModuleDeclaration: ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. name = (ast).name.actualText; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. break; case TypeScript.NodeType.ClassDeclaration: ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. name = (ast).name.actualText; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. break; case TypeScript.NodeType.FuncDecl: ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. name = !(ast).name ? "" : (ast).name.actualText; // name == null for lambdas ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. break; default: // TODO: is there a reason to mess with all the special cases above and not just do this (ie take whatever property is there and works?) @@ -1339,7 +1339,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): */ export function generateDeclFile(code: string, verifyNoDeclFile: boolean, unitName?: string, compilationContext?: Harness.Compiler.CompilationContext, references?: TypeScript.IFileReference[]): string { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. reset(); compiler.settings.generateDeclarationFiles = true; @@ -1410,7 +1410,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /** @param fileResults an array of strings for the filename and an ITextWriter with its code */ constructor(public fileResults: { filename: string; file: WriterAggregator; }[], errorLines: string[], public scripts: TypeScript.Script[]) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var lines = []; fileResults.forEach(v => lines = lines.concat(v.file.lines)); this.code = lines.join("\n") @@ -1494,10 +1494,10 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export function addUnit(code: string, unitName?: string, isResident?: boolean, isDeclareFile?: boolean, references?: TypeScript.IFileReference[]) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var script: TypeScript.Script = null; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var uName = unitName || '0' + (isDeclareFile ? '.d.ts' : '.ts'); for (var i = 0; i < compiler.units.length; i++) { @@ -1505,7 +1505,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): updateUnit(code, uName); script = compiler.scripts.members[i]; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. } } if (!script) { @@ -1532,9 +1532,9 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export function compileFile(path: string, callback: (res: CompilerResult) => void , settingsCallback?: (settings?: TypeScript.CompilationSettings) => void , context?: CompilationContext, references?: TypeScript.IFileReference[]) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. path = switchToForwardSlashes(path); var filename = path.match(/[^\/]*$/)[0]; var code = readFile(path); @@ -1544,9 +1544,9 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export function compileUnit(code: string, filename: string, callback: (res: CompilerResult) => void , settingsCallback?: (settings?: TypeScript.CompilationSettings) => void , context?: CompilationContext, references?: TypeScript.IFileReference[]) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. // not recursive function clone/* */(source: any, target: any) { for (var prop in source) { @@ -1604,16 +1604,16 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export function emit(ioHost: TypeScript.EmitterIOHost, usePullEmitter?: boolean) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. compiler.emit(ioHost, usePullEmitter); } export function compileString(code: string, unitName: string, callback: (res: Compiler.CompilerResult) => void , context?: CompilationContext, references?: TypeScript.IFileReference[]) { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var scripts: TypeScript.Script[] = []; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. reset(); @@ -1696,7 +1696,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): originalFilePath: string; references: TypeScript.IFileReference[]; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. } // Regex for parsing options in the format "@Alpha: Value of any sort" @@ -1739,7 +1739,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): var currentFileName = null; var refs: TypeScript.IFileReference[] = []; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. for (var i = 0; i < lines.length; i++) { var line = lines[i]; @@ -1832,7 +1832,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): public version: number; public editRanges: { length: number; editRange: TypeScript.ScriptEditRange; }[] = []; ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. constructor(public name: string, public content: string, public isResident: boolean, public maxScriptVersions: number) { this.version = 1; @@ -1870,7 +1870,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): public getEditRangeSinceVersion(version: number): TypeScript.ScriptEditRange { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. if (this.version == version) { // No edits! return null; @@ -1898,10 +1898,10 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export class TypeScriptLS implements Services.ILanguageServiceShimHost { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. private ls: Services.ILanguageServiceShim = null; ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. public scripts: ScriptInfo[] = []; public maxScriptVersions = 100; @@ -2003,7 +2003,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): */ public getLanguageService(): Services.ILanguageServiceShim { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. var ls = new Services.TypeScriptServicesFactory().createLanguageServiceShim(this); ~~~~~~~~ !!! error TS2304: Cannot find name 'Services'. @@ -2015,9 +2015,9 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /** Parse file given its source text */ public parseSourceText(fileName: string, sourceText: TypeScript.ISourceText): TypeScript.Script { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var parser = new TypeScript.Parser(); ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. @@ -2058,7 +2058,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): */ public positionToZeroBasedLineCol(fileName: string, position: number): TypeScript.ILineCol { ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. var script = this.ls.languageService.getScriptAST(fileName); assert.notNull(script); @@ -2074,7 +2074,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /** Verify that applying edits to sourceFileName result in the content of the file baselineFileName */ public checkEdits(sourceFileName: string, baselineFileName: string, edits: Services.TextEdit[]) { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. var script = readFile(sourceFileName); var formattedScript = this.applyEdits(script, edits); var baseline = readFile(baselineFileName); @@ -2087,7 +2087,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /** Apply an array of text edits to a string, and return the resulting string. */ public applyEdits(content: string, edits: Services.TextEdit[]): string { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. var result = content; edits = this.normalizeEdits(edits); @@ -2104,18 +2104,18 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /** Normalize an array of edits by removing overlapping entries and sorting entries on the minChar position. */ private normalizeEdits(edits: Services.TextEdit[]): Services.TextEdit[] { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. var result: Services.TextEdit[] = []; ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. function mapEdits(edits: Services.TextEdit[]): { edit: Services.TextEdit; index: number; }[] { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. var result = []; for (var i = 0; i < edits.length; i++) { result.push({ edit: edits[i], index: i }); diff --git a/tests/baselines/reference/parserharness.js b/tests/baselines/reference/parserharness.js index 02304380013..d74e81fad27 100644 --- a/tests/baselines/reference/parserharness.js +++ b/tests/baselines/reference/parserharness.js @@ -2096,7 +2096,7 @@ module Harness { // See the License for the specific language governing permissions and // limitations under the License. // -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/parserindenter.errors.txt b/tests/baselines/reference/parserindenter.errors.txt index 3d8e5f7cc45..a332abab7bb 100644 --- a/tests/baselines/reference/parserindenter.errors.txt +++ b/tests/baselines/reference/parserindenter.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(16,1): er tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(20,38): error TS2304: Cannot find name 'ILineIndenationResolver'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(22,33): error TS2304: Cannot find name 'IndentationBag'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(24,42): error TS2304: Cannot find name 'Dictionary_int_int'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(27,28): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(27,28): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(28,26): error TS2304: Cannot find name 'ParseTree'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(29,30): error TS2304: Cannot find name 'ITextSnapshot'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(31,35): error TS2304: Cannot find name 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(31,35): error TS2503: Cannot find namespace 'Services'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(32,32): error TS2304: Cannot find name 'TokenSpan'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(35,39): error TS2304: Cannot find name 'IndentationBag'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(37,48): error TS2304: Cannot find name 'Dictionary_int_int'. @@ -27,9 +27,9 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(152,51): tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(152,63): error TS2304: Cannot find name 'List_TextEditInfo'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(153,30): error TS2304: Cannot find name 'List_TextEditInfo'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(155,32): error TS2304: Cannot find name 'AuthorTokenKind'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(182,79): error TS2304: Cannot find name 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(182,79): error TS2503: Cannot find namespace 'Services'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(183,20): error TS2304: Cannot find name 'GetIndentSizeFromText'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(186,67): error TS2304: Cannot find name 'Services'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(186,67): error TS2503: Cannot find namespace 'Services'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(207,50): error TS2304: Cannot find name 'TokenSpan'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(207,67): error TS2304: Cannot find name 'ParseNode'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(207,79): error TS2304: Cannot find name 'IndentationInfo'. @@ -165,7 +165,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38): constructor( public logger: TypeScript.ILogger, ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScript'. +!!! error TS2503: Cannot find namespace 'TypeScript'. public tree: ParseTree, ~~~~~~~~~ !!! error TS2304: Cannot find name 'ParseTree'. @@ -175,7 +175,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38): public languageHostIndentation: string, public editorOptions: Services.EditorOptions, ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. public firstToken: TokenSpan, ~~~~~~~~~ !!! error TS2304: Cannot find name 'TokenSpan'. @@ -370,7 +370,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38): static GetIndentSizeFromIndentText(indentText: string, editorOptions: Services.EditorOptions): number { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. return GetIndentSizeFromText(indentText, editorOptions, /*includeNonIndentChars:*/ false); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'GetIndentSizeFromText'. @@ -378,7 +378,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38): static GetIndentSizeFromText(text: string, editorOptions: Services.EditorOptions, includeNonIndentChars: boolean): number { ~~~~~~~~ -!!! error TS2304: Cannot find name 'Services'. +!!! error TS2503: Cannot find namespace 'Services'. var indentSize = 0; for (var i = 0; i < text.length; i++) { diff --git a/tests/baselines/reference/parservoidInQualifiedName2.errors.txt b/tests/baselines/reference/parservoidInQualifiedName2.errors.txt index ad96679f0fd..7ca94a8989a 100644 --- a/tests/baselines/reference/parservoidInQualifiedName2.errors.txt +++ b/tests/baselines/reference/parservoidInQualifiedName2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/parservoidInQualifiedName2.ts(1,9): error TS2304: Cannot find name 'x'. +tests/cases/conformance/parser/ecmascript5/parservoidInQualifiedName2.ts(1,9): error TS2503: Cannot find namespace 'x'. tests/cases/conformance/parser/ecmascript5/parservoidInQualifiedName2.ts(1,11): error TS1003: Identifier expected. tests/cases/conformance/parser/ecmascript5/parservoidInQualifiedName2.ts(1,15): error TS1109: Expression expected. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/parservoidInQualifiedName2.ts(1,15): ==== tests/cases/conformance/parser/ecmascript5/parservoidInQualifiedName2.ts (3 errors) ==== var v : x.void; ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2503: Cannot find namespace 'x'. ~~~~ !!! error TS1003: Identifier expected. ~ diff --git a/tests/baselines/reference/primaryExpressionMods.errors.txt b/tests/baselines/reference/primaryExpressionMods.errors.txt index 8de3d60c27d..197970591eb 100644 --- a/tests/baselines/reference/primaryExpressionMods.errors.txt +++ b/tests/baselines/reference/primaryExpressionMods.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/primaryExpressionMods.ts(7,8): error TS2304: Cannot find name 'M'. -tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2304: Cannot find name 'm'. +tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2503: Cannot find namespace 'm'. ==== tests/cases/compiler/primaryExpressionMods.ts (2 errors) ==== @@ -17,5 +17,5 @@ tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2304: Cannot find n var x2 = m.a; // Same as M.a var q: m.P; // Error ~ -!!! error TS2304: Cannot find name 'm'. +!!! error TS2503: Cannot find namespace 'm'. \ No newline at end of file diff --git a/tests/baselines/reference/primitiveMembers.js b/tests/baselines/reference/primitiveMembers.js index 629d55ed0f7..a49d6f7ee1c 100644 --- a/tests/baselines/reference/primitiveMembers.js +++ b/tests/baselines/reference/primitiveMembers.js @@ -32,7 +32,7 @@ class foo extends baz { public bar(){ return undefined}; } //// [primitiveMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privacyClass.js b/tests/baselines/reference/privacyClass.js index 564d49721f1..4d6d0a72e4a 100644 --- a/tests/baselines/reference/privacyClass.js +++ b/tests/baselines/reference/privacyClass.js @@ -128,7 +128,7 @@ export class glo_C12_public extends glo_c_private implements glo_i_private, glo } //// [privacyClass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js index 6a7d716d50d..044c30f3797 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js @@ -98,7 +98,7 @@ class publicClassExtendingPublicClassInGlobal extends publicClassInGlobal { //// [privacyClassExtendsClauseDeclFile_externalModule.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; @@ -285,7 +285,7 @@ var publicClassExtendingFromPrivateModuleClass = (function (_super) { })(privateModule.publicClassInPrivateModule); exports.publicClassExtendingFromPrivateModuleClass = publicClassExtendingFromPrivateModuleClass; //// [privacyClassExtendsClauseDeclFile_GlobalFile.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privacyGloClass.js b/tests/baselines/reference/privacyGloClass.js index 5cd5ace3247..58877eae167 100644 --- a/tests/baselines/reference/privacyGloClass.js +++ b/tests/baselines/reference/privacyGloClass.js @@ -61,7 +61,7 @@ class glo_C11_public extends glo_c_public implements glo_i_public { //// [privacyGloClass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privateAccessInSubclass1.js b/tests/baselines/reference/privateAccessInSubclass1.js index 0d56cf415ac..7004a535952 100644 --- a/tests/baselines/reference/privateAccessInSubclass1.js +++ b/tests/baselines/reference/privateAccessInSubclass1.js @@ -10,7 +10,7 @@ class D extends Base { } //// [privateAccessInSubclass1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.js b/tests/baselines/reference/privateInstanceMemberAccessibility.js index a719e54768b..4158ef6a8f7 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.js +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.js @@ -14,7 +14,7 @@ class Derived extends Base { } //// [privateInstanceMemberAccessibility.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.js b/tests/baselines/reference/privateStaticMemberAccessibility.js index fdcb2663299..013c606f829 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.js +++ b/tests/baselines/reference/privateStaticMemberAccessibility.js @@ -9,7 +9,7 @@ class Derived extends Base { } //// [privateStaticMemberAccessibility.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js index a4562e02b65..3db3a636c7d 100644 --- a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js +++ b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js @@ -16,7 +16,7 @@ module D { //// [privateStaticNotAccessibleInClodule2.js] // Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time error. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index 25059478bf5..1bda32a0b4c 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ -error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'. +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index 25059478bf5..1bda32a0b4c 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ -error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'. +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt index 0d3528b6dc3..47d1f6df86e 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt index 0d3528b6dc3..47d1f6df86e 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt index 01a3526196c..d00f552ef97 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt index 01a3526196c..d00f552ef97 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js index 7af6249615c..5bdce5cf48a 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js @@ -1,4 +1,4 @@ -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js index 7af6249615c..5bdce5cf48a 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js @@ -1,4 +1,4 @@ -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/prologueEmit/amd/out.js b/tests/baselines/reference/project/prologueEmit/amd/out.js index b19a07f6490..e621c38f984 100644 --- a/tests/baselines/reference/project/prologueEmit/amd/out.js +++ b/tests/baselines/reference/project/prologueEmit/amd/out.js @@ -1,7 +1,7 @@ var _this = this; // Add a lambda to ensure global 'this' capture is triggered (function () { return _this.window; }); -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/prologueEmit/node/out.js b/tests/baselines/reference/project/prologueEmit/node/out.js index b19a07f6490..e621c38f984 100644 --- a/tests/baselines/reference/project/prologueEmit/node/out.js +++ b/tests/baselines/reference/project/prologueEmit/node/out.js @@ -1,7 +1,7 @@ var _this = this; // Add a lambda to ensure global 'this' capture is triggered (function () { return _this.window; }); -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js index 3818742d7a4..b1f4dd64ef2 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js @@ -1,5 +1,5 @@ /// -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js index 3818742d7a4..b1f4dd64ef2 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js @@ -1,5 +1,5 @@ /// -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt index b7abc0c2d52..f4b65c12f35 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt index b7abc0c2d52..f4b65c12f35 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/promiseVoidErrorCallback.js b/tests/baselines/reference/promiseVoidErrorCallback.js new file mode 100644 index 00000000000..a9aa0f1b5d0 --- /dev/null +++ b/tests/baselines/reference/promiseVoidErrorCallback.js @@ -0,0 +1,43 @@ +//// [promiseVoidErrorCallback.ts] +interface T1 { + __t1: string; +} + +interface T2 { + __t2: string; +} + +interface T3 { + __t3: string; +} + +function f1(): Promise { + return Promise.resolve({ __t1: "foo_t1" }); +} + +function f2(x: T1): T2 { + return { __t2: x.__t1 + ":foo_21" }; +} + +var x3 = f1() + .then(f2, (e: Error) => { + throw e; +}) + .then((x: T2) => { + return { __t3: x.__t2 + "bar" }; +}); + +//// [promiseVoidErrorCallback.js] +function f1() { + return Promise.resolve({ __t1: "foo_t1" }); +} +function f2(x) { + return { __t2: x.__t1 + ":foo_21" }; +} +var x3 = f1() + .then(f2, (e) => { + throw e; +}) + .then((x) => { + return { __t3: x.__t2 + "bar" }; +}); diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols new file mode 100644 index 00000000000..78faacdb1f1 --- /dev/null +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -0,0 +1,75 @@ +=== tests/cases/compiler/promiseVoidErrorCallback.ts === +interface T1 { +>T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) + + __t1: string; +>__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 0, 14)) +} + +interface T2 { +>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) + + __t2: string; +>__t2 : Symbol(__t2, Decl(promiseVoidErrorCallback.ts, 4, 14)) +} + +interface T3 { +>T3 : Symbol(T3, Decl(promiseVoidErrorCallback.ts, 6, 1)) + + __t3: string; +>__t3 : Symbol(__t3, Decl(promiseVoidErrorCallback.ts, 8, 14)) +} + +function f1(): Promise { +>f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4854, 11)) +>T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) + + return Promise.resolve({ __t1: "foo_t1" }); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4854, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54)) +>__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) +} + +function f2(x: T1): T2 { +>f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) +>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 16, 12)) +>T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) +>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) + + return { __t2: x.__t1 + ":foo_21" }; +>__t2 : Symbol(__t2, Decl(promiseVoidErrorCallback.ts, 17, 12)) +>x.__t1 : Symbol(T1.__t1, Decl(promiseVoidErrorCallback.ts, 0, 14)) +>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 16, 12)) +>__t1 : Symbol(T1.__t1, Decl(promiseVoidErrorCallback.ts, 0, 14)) +} + +var x3 = f1() +>x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) + + .then(f2, (e: Error) => { +>then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) +>e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) +>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) + + throw e; +>e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) + +}) + .then((x: T2) => { +>then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158)) +>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) +>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) + + return { __t3: x.__t2 + "bar" }; +>__t3 : Symbol(__t3, Decl(promiseVoidErrorCallback.ts, 25, 12)) +>x.__t2 : Symbol(T2.__t2, Decl(promiseVoidErrorCallback.ts, 4, 14)) +>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) +>__t2 : Symbol(T2.__t2, Decl(promiseVoidErrorCallback.ts, 4, 14)) + +}); diff --git a/tests/baselines/reference/promiseVoidErrorCallback.types b/tests/baselines/reference/promiseVoidErrorCallback.types new file mode 100644 index 00000000000..82b248f64bd --- /dev/null +++ b/tests/baselines/reference/promiseVoidErrorCallback.types @@ -0,0 +1,89 @@ +=== tests/cases/compiler/promiseVoidErrorCallback.ts === +interface T1 { +>T1 : T1 + + __t1: string; +>__t1 : string +} + +interface T2 { +>T2 : T2 + + __t2: string; +>__t2 : string +} + +interface T3 { +>T3 : T3 + + __t3: string; +>__t3 : string +} + +function f1(): Promise { +>f1 : () => Promise +>Promise : Promise +>T1 : T1 + + return Promise.resolve({ __t1: "foo_t1" }); +>Promise.resolve({ __t1: "foo_t1" }) : Promise<{ __t1: string; }> +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>{ __t1: "foo_t1" } : { __t1: string; } +>__t1 : string +>"foo_t1" : string +} + +function f2(x: T1): T2 { +>f2 : (x: T1) => T2 +>x : T1 +>T1 : T1 +>T2 : T2 + + return { __t2: x.__t1 + ":foo_21" }; +>{ __t2: x.__t1 + ":foo_21" } : { __t2: string; } +>__t2 : string +>x.__t1 + ":foo_21" : string +>x.__t1 : string +>x : T1 +>__t1 : string +>":foo_21" : string +} + +var x3 = f1() +>x3 : Promise<{ __t3: string; }> +>f1() .then(f2, (e: Error) => { throw e;}) .then((x: T2) => { return { __t3: x.__t2 + "bar" };}) : Promise<{ __t3: string; }> +>f1() .then(f2, (e: Error) => { throw e;}) .then : { (onfulfilled?: (value: T2) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled?: (value: T2) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; } +>f1() .then(f2, (e: Error) => { throw e;}) : Promise +>f1() .then : { (onfulfilled?: (value: T1) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled?: (value: T1) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; } +>f1() : Promise +>f1 : () => Promise + + .then(f2, (e: Error) => { +>then : { (onfulfilled?: (value: T1) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled?: (value: T1) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; } +>f2 : (x: T1) => T2 +>(e: Error) => { throw e;} : (e: Error) => void +>e : Error +>Error : Error + + throw e; +>e : Error + +}) + .then((x: T2) => { +>then : { (onfulfilled?: (value: T2) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled?: (value: T2) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; } +>(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; } +>x : T2 +>T2 : T2 + + return { __t3: x.__t2 + "bar" }; +>{ __t3: x.__t2 + "bar" } : { __t3: string; } +>__t3 : string +>x.__t2 + "bar" : string +>x.__t2 : string +>x : T2 +>__t2 : string +>"bar" : string + +}); diff --git a/tests/baselines/reference/propertiesAndIndexers.js b/tests/baselines/reference/propertiesAndIndexers.js index 23673dbcfad..f67a9d89249 100644 --- a/tests/baselines/reference/propertiesAndIndexers.js +++ b/tests/baselines/reference/propertiesAndIndexers.js @@ -52,7 +52,7 @@ var c: { }; //// [propertiesAndIndexers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/propertyAccess.js b/tests/baselines/reference/propertyAccess.js index 9295ce43b26..1e6ef5c1d6d 100644 --- a/tests/baselines/reference/propertyAccess.js +++ b/tests/baselines/reference/propertyAccess.js @@ -151,7 +151,7 @@ var x3: A; //// [propertyAccess.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js index 88baee7752e..dc4c30d9165 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js @@ -83,7 +83,7 @@ var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, er //// [propertyAccessOnTypeParameterWithConstraints2.js] // generic types should behave as if they have properties of their constraint type -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js index 941adc7ab43..7e935609e36 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js @@ -58,7 +58,7 @@ var r4 = b.foo(new B()); // valid call to an invalid function //// [propertyAccessOnTypeParameterWithConstraints3.js] // generic types should behave as if they have properties of their constraint type -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js index fe3c9433796..f871ce553b7 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js @@ -45,7 +45,7 @@ var b = { var r4 = b.foo(new B()); // error after constraints above made illegal, doesn't matter //// [propertyAccessOnTypeParameterWithConstraints5.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js index 28a1da5ffec..45f001c65fb 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js @@ -21,7 +21,7 @@ class C extends B { //// [protectedClassPropertyAccessibleWithinSubclass.js] // no errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js index 73abc96cc43..10276f8ac85 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js @@ -95,7 +95,7 @@ d3.x; // Error, neither within their declaring class nor class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedClassPropertyAccessibleWithinSubclass2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js index 8085112d994..1a5b7489910 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js @@ -14,7 +14,7 @@ class Derived extends Base { } //// [protectedClassPropertyAccessibleWithinSubclass3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.js b/tests/baselines/reference/protectedInstanceMemberAccessibility.js index de7a6e0d00e..7560c5c89ca 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.js +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.js @@ -45,7 +45,7 @@ class C extends A { //// [protectedInstanceMemberAccessibility.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedMembers.js b/tests/baselines/reference/protectedMembers.js index dd2e113d665..33b6e2ebde2 100644 --- a/tests/baselines/reference/protectedMembers.js +++ b/tests/baselines/reference/protectedMembers.js @@ -117,7 +117,7 @@ class B3 extends A3 { //// [protectedMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js index 81c11369ee8..1bd102694d4 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js @@ -44,7 +44,7 @@ Derived2.x; // Error, neither within their declaring class nor classes deriv Derived3.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedStaticClassPropertyAccessibleWithinSubclass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js index 520851f5e95..c82c67b7003 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js @@ -22,7 +22,7 @@ class Derived2 extends Derived1 { } //// [protectedStaticClassPropertyAccessibleWithinSubclass2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js index a8dc4ebba21..8b071cb6b52 100644 --- a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js +++ b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js @@ -7,7 +7,7 @@ class Beta extends Alpha.x { } //// [qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveBaseCheck3.js b/tests/baselines/reference/recursiveBaseCheck3.js index d79aaa30d9a..6c1cd918779 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.js +++ b/tests/baselines/reference/recursiveBaseCheck3.js @@ -5,7 +5,7 @@ class C extends A { } (new C).blah; //// [recursiveBaseCheck3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveBaseCheck4.js b/tests/baselines/reference/recursiveBaseCheck4.js index e6779fc74e9..1abb6731263 100644 --- a/tests/baselines/reference/recursiveBaseCheck4.js +++ b/tests/baselines/reference/recursiveBaseCheck4.js @@ -3,7 +3,7 @@ class M extends M { } (new M).blah; //// [recursiveBaseCheck4.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveBaseCheck6.js b/tests/baselines/reference/recursiveBaseCheck6.js index ee97b3ec436..7fb9b444650 100644 --- a/tests/baselines/reference/recursiveBaseCheck6.js +++ b/tests/baselines/reference/recursiveBaseCheck6.js @@ -3,7 +3,7 @@ class S18 extends S18<{ S19: A; }>{ } (new S18()).blah; //// [recursiveBaseCheck6.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation1.js b/tests/baselines/reference/recursiveBaseConstructorCreation1.js index c475f604b14..d0fc83b30f2 100644 --- a/tests/baselines/reference/recursiveBaseConstructorCreation1.js +++ b/tests/baselines/reference/recursiveBaseConstructorCreation1.js @@ -7,7 +7,7 @@ var x = new C2(); // Valid //// [recursiveBaseConstructorCreation1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js index 403eb330cd7..214c543b836 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js @@ -10,7 +10,7 @@ export class MemberNameArray extends MemberName { //// [recursiveClassInstantiationsWithDefaultConstructors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js b/tests/baselines/reference/recursiveClassReferenceTest.js index d47d9340a8c..e9339fec4df 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js +++ b/tests/baselines/reference/recursiveClassReferenceTest.js @@ -105,7 +105,7 @@ module Sample.Thing.Languages.PlainText { //// [recursiveClassReferenceTest.js] // Scenario 1: Test reqursive function call with "this" parameter // Scenario 2: Test recursive function call with cast and "this" parameter -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index 23950aba4ba..67031d420ea 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -26,7 +26,7 @@ sourceFile:recursiveClassReferenceTest.ts 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 75) Source(2, 75) + SourceIndex(0) --- ->>>var __extends = this.__extends || function (d, b) { +>>>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; } >>> __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveComplicatedClasses.js b/tests/baselines/reference/recursiveComplicatedClasses.js index 25f20f57d23..6e88dd8dc22 100644 --- a/tests/baselines/reference/recursiveComplicatedClasses.js +++ b/tests/baselines/reference/recursiveComplicatedClasses.js @@ -25,7 +25,7 @@ class TypeSymbol extends InferenceSymbol { } //// [recursiveComplicatedClasses.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.errors.txt b/tests/baselines/reference/recursiveTypesWithTypeof.errors.txt new file mode 100644 index 00000000000..0604e38bd94 --- /dev/null +++ b/tests/baselines/reference/recursiveTypesWithTypeof.errors.txt @@ -0,0 +1,76 @@ +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(2,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(4,5): error TS2502: 'd' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(6,5): error TS2502: 'e' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(10,5): error TS2502: 'f' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(12,5): error TS2502: 'f2' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(14,5): error TS2502: 'f3' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(51,5): error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation. + + +==== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts (7 errors) ==== + // The following are errors because of circular references + var c: typeof c; + ~ +!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation. + var c: any; + var d: typeof e; + ~ +!!! error TS2502: 'd' is referenced directly or indirectly in its own type annotation. + var d: any; + var e: typeof d; + ~ +!!! error TS2502: 'e' is referenced directly or indirectly in its own type annotation. + var e: any; + + interface Foo { } + var f: Array; + ~ +!!! error TS2502: 'f' is referenced directly or indirectly in its own type annotation. + var f: any; + var f2: Foo; + ~~ +!!! error TS2502: 'f2' is referenced directly or indirectly in its own type annotation. + var f2: any; + var f3: Foo[]; + ~~ +!!! error TS2502: 'f3' is referenced directly or indirectly in its own type annotation. + var f3: any; + + // None of these declarations should have any errors! + // Truly recursive types + var g: { x: typeof g; }; + var g: typeof g.x; + var h: () => typeof h; + var h = h(); + var i: (x: typeof i) => typeof x; + var i = i(i); + var j: (x: T) => T; + var j = j(j); + + // Same as h, i, j with construct signatures + var h2: new () => typeof h2; + var h2 = new h2(); + var i2: new (x: typeof i2) => typeof x; + var i2 = new i2(i2); + var j2: new (x: T) => T; + var j2 = new j2(j2); + + // Indexers + var k: { [n: number]: typeof k;[s: string]: typeof k }; + var k = k[0]; + var k = k['']; + + // Hybrid - contains type literals as well as type arguments + // These two are recursive + var hy1: { x: typeof hy1 }[]; + var hy1 = hy1[0].x; + var hy2: { x: Array }; + var hy2 = hy2.x[0]; + + interface Foo2 { } + + // This one should be an error because the first type argument is not contained inside a type literal + var hy3: Foo2; + ~~~ +!!! error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation. + var hy3: any; \ No newline at end of file diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.js b/tests/baselines/reference/recursiveTypesWithTypeof.js index 36c13405b0b..9fffd5b2604 100644 --- a/tests/baselines/reference/recursiveTypesWithTypeof.js +++ b/tests/baselines/reference/recursiveTypesWithTypeof.js @@ -1,6 +1,5 @@ //// [recursiveTypesWithTypeof.ts] -// None of these declarations should have any errors! -// Using typeof directly, these should be any +// The following are errors because of circular references var c: typeof c; var c: any; var d: typeof e; @@ -8,7 +7,6 @@ var d: any; var e: typeof d; var e: any; -// In type arguments, these should be any interface Foo { } var f: Array; var f: any; @@ -17,6 +15,7 @@ var f2: any; var f3: Foo[]; var f3: any; +// None of these declarations should have any errors! // Truly recursive types var g: { x: typeof g; }; var g: typeof g.x; @@ -49,25 +48,25 @@ var hy2 = hy2.x[0]; interface Foo2 { } -// This one should be any because the first type argument is not contained inside a type literal +// This one should be an error because the first type argument is not contained inside a type literal var hy3: Foo2; var hy3: any; //// [recursiveTypesWithTypeof.js] +// The following are errors because of circular references +var c; +var c; +var d; +var d; +var e; +var e; +var f; +var f; +var f2; +var f2; +var f3; +var f3; // None of these declarations should have any errors! -// Using typeof directly, these should be any -var c; -var c; -var d; -var d; -var e; -var e; -var f; -var f; -var f2; -var f2; -var f3; -var f3; // Truly recursive types var g; var g; @@ -94,6 +93,6 @@ var hy1; var hy1 = hy1[0].x; var hy2; var hy2 = hy2.x[0]; -// This one should be any because the first type argument is not contained inside a type literal +// This one should be an error because the first type argument is not contained inside a type literal var hy3; var hy3; diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.symbols b/tests/baselines/reference/recursiveTypesWithTypeof.symbols deleted file mode 100644 index ae1a311bdf6..00000000000 --- a/tests/baselines/reference/recursiveTypesWithTypeof.symbols +++ /dev/null @@ -1,187 +0,0 @@ -=== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts === -// None of these declarations should have any errors! -// Using typeof directly, these should be any -var c: typeof c; ->c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3)) ->c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3)) - -var c: any; ->c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3)) - -var d: typeof e; ->d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3)) ->e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3)) - -var d: any; ->d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3)) - -var e: typeof d; ->e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3)) ->d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3)) - -var e: any; ->e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3)) - -// In type arguments, these should be any -interface Foo { } ->Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 10, 14)) - -var f: Array; ->f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3)) - -var f: any; ->f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3)) - -var f2: Foo; ->f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3)) ->Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11)) ->f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3)) - -var f2: any; ->f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3)) - -var f3: Foo[]; ->f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3)) ->Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11)) ->f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3)) - -var f3: any; ->f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3)) - -// Truly recursive types -var g: { x: typeof g; }; ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8)) ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) - -var g: typeof g.x; ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) ->g.x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8)) ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8)) - -var h: () => typeof h; ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) - -var h = h(); ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) - -var i: (x: typeof i) => typeof x; ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 23, 8)) ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 23, 8)) - -var i = i(i); ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) - -var j: (x: T) => T; ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8)) ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 25, 28)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8)) - -var j = j(j); ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) - -// Same as h, i, j with construct signatures -var h2: new () => typeof h2; ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) - -var h2 = new h2(); ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) - -var i2: new (x: typeof i2) => typeof x; ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 31, 13)) ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 31, 13)) - -var i2 = new i2(i2); ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) - -var j2: new (x: T) => T; ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13)) ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 33, 34)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13)) - -var j2 = new j2(j2); ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) - -// Indexers -var k: { [n: number]: typeof k;[s: string]: typeof k }; ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->n : Symbol(n, Decl(recursiveTypesWithTypeof.ts, 37, 10)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->s : Symbol(s, Decl(recursiveTypesWithTypeof.ts, 37, 32)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) - -var k = k[0]; ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) - -var k = k['']; ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) - -// Hybrid - contains type literals as well as type arguments -// These two are recursive -var hy1: { x: typeof hy1 }[]; ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10)) ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) - -var hy1 = hy1[0].x; ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) ->hy1[0].x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10)) ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10)) - -var hy2: { x: Array }; ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) - -var hy2 = hy2.x[0]; ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) ->hy2.x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10)) ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10)) - -interface Foo2 { } ->Foo2 : Symbol(Foo2, Decl(recursiveTypesWithTypeof.ts, 46, 19)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 48, 15)) ->U : Symbol(U, Decl(recursiveTypesWithTypeof.ts, 48, 17)) - -// This one should be any because the first type argument is not contained inside a type literal -var hy3: Foo2; ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) ->Foo2 : Symbol(Foo2, Decl(recursiveTypesWithTypeof.ts, 46, 19)) ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 51, 27)) ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) - -var hy3: any; ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) - diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.types b/tests/baselines/reference/recursiveTypesWithTypeof.types deleted file mode 100644 index 864c136743d..00000000000 --- a/tests/baselines/reference/recursiveTypesWithTypeof.types +++ /dev/null @@ -1,201 +0,0 @@ -=== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts === -// None of these declarations should have any errors! -// Using typeof directly, these should be any -var c: typeof c; ->c : any ->c : any - -var c: any; ->c : any - -var d: typeof e; ->d : any ->e : any - -var d: any; ->d : any - -var e: typeof d; ->e : any ->d : any - -var e: any; ->e : any - -// In type arguments, these should be any -interface Foo { } ->Foo : Foo ->T : T - -var f: Array; ->f : any ->Array : T[] ->f : any - -var f: any; ->f : any - -var f2: Foo; ->f2 : any ->Foo : Foo ->f2 : any - -var f2: any; ->f2 : any - -var f3: Foo[]; ->f3 : any ->Foo : Foo ->f3 : any - -var f3: any; ->f3 : any - -// Truly recursive types -var g: { x: typeof g; }; ->g : { x: any; } ->x : { x: any; } ->g : { x: any; } - -var g: typeof g.x; ->g : { x: any; } ->g.x : { x: any; } ->g : { x: any; } ->x : { x: any; } - -var h: () => typeof h; ->h : () => any ->h : () => any - -var h = h(); ->h : () => any ->h() : () => any ->h : () => any - -var i: (x: typeof i) => typeof x; ->i : (x: any) => any ->x : (x: any) => any ->i : (x: any) => any ->x : (x: any) => any - -var i = i(i); ->i : (x: any) => any ->i(i) : (x: any) => any ->i : (x: any) => any ->i : (x: any) => any - -var j: (x: T) => T; ->j : (x: T) => T ->T : T ->j : (x: T) => T ->x : T ->T : T ->T : T - -var j = j(j); ->j : (x: T) => T ->j(j) : (x: T) => T ->j : (x: T) => T ->j : (x: T) => T - -// Same as h, i, j with construct signatures -var h2: new () => typeof h2; ->h2 : new () => any ->h2 : new () => any - -var h2 = new h2(); ->h2 : new () => any ->new h2() : new () => any ->h2 : new () => any - -var i2: new (x: typeof i2) => typeof x; ->i2 : new (x: any) => any ->x : new (x: any) => any ->i2 : new (x: any) => any ->x : new (x: any) => any - -var i2 = new i2(i2); ->i2 : new (x: any) => any ->new i2(i2) : new (x: any) => any ->i2 : new (x: any) => any ->i2 : new (x: any) => any - -var j2: new (x: T) => T; ->j2 : new (x: T) => T ->T : T ->j2 : new (x: T) => T ->x : T ->T : T ->T : T - -var j2 = new j2(j2); ->j2 : new (x: T) => T ->new j2(j2) : new (x: T) => T ->j2 : new (x: T) => T ->j2 : new (x: T) => T - -// Indexers -var k: { [n: number]: typeof k;[s: string]: typeof k }; ->k : { [s: string]: any; [n: number]: any; } ->n : number ->k : { [s: string]: any; [n: number]: any; } ->s : string ->k : { [s: string]: any; [n: number]: any; } - -var k = k[0]; ->k : { [s: string]: any; [n: number]: any; } ->k[0] : { [s: string]: any; [n: number]: any; } ->k : { [s: string]: any; [n: number]: any; } ->0 : number - -var k = k['']; ->k : { [s: string]: any; [n: number]: any; } ->k[''] : { [s: string]: any; [n: number]: any; } ->k : { [s: string]: any; [n: number]: any; } ->'' : string - -// Hybrid - contains type literals as well as type arguments -// These two are recursive -var hy1: { x: typeof hy1 }[]; ->hy1 : { x: any[]; }[] ->x : { x: any[]; }[] ->hy1 : { x: any[]; }[] - -var hy1 = hy1[0].x; ->hy1 : { x: any[]; }[] ->hy1[0].x : { x: any[]; }[] ->hy1[0] : { x: any[]; } ->hy1 : { x: any[]; }[] ->0 : number ->x : { x: any[]; }[] - -var hy2: { x: Array }; ->hy2 : { x: any[]; } ->x : { x: any[]; }[] ->Array : T[] ->hy2 : { x: any[]; } - -var hy2 = hy2.x[0]; ->hy2 : { x: any[]; } ->hy2.x[0] : { x: any[]; } ->hy2.x : { x: any[]; }[] ->hy2 : { x: any[]; } ->x : { x: any[]; }[] ->0 : number - -interface Foo2 { } ->Foo2 : Foo2 ->T : T ->U : U - -// This one should be any because the first type argument is not contained inside a type literal -var hy3: Foo2; ->hy3 : any ->Foo2 : Foo2 ->hy3 : any ->x : any ->hy3 : any - -var hy3: any; ->hy3 : any - diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index c0abe985dbc..60022dc245a 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -30,7 +30,7 @@ declare module MsPortal.Controls.Base.ItemList { */ //// [recursivelySpecializedConstructorDeclaration.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js index 24f0e7f1bcb..72cc702309c 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js @@ -1020,7 +1020,7 @@ module caurinus { //// [resolvingClassDeclarationWhenInBaseTypeResolution.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/returnInConstructor1.js b/tests/baselines/reference/returnInConstructor1.js index 0096c4d65b6..87b1b6d672a 100644 --- a/tests/baselines/reference/returnInConstructor1.js +++ b/tests/baselines/reference/returnInConstructor1.js @@ -67,7 +67,7 @@ class I extends G { //// [returnInConstructor1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/returnStatements.js b/tests/baselines/reference/returnStatements.js index 77b6ae1f774..35c208b19ee 100644 --- a/tests/baselines/reference/returnStatements.js +++ b/tests/baselines/reference/returnStatements.js @@ -25,7 +25,7 @@ function fn13(): C { return null; } //// [returnStatements.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/scannerImportDeclaration1.errors.txt b/tests/baselines/reference/scannerImportDeclaration1.errors.txt index 243670c6854..d8378248d51 100644 --- a/tests/baselines/reference/scannerImportDeclaration1.errors.txt +++ b/tests/baselines/reference/scannerImportDeclaration1.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/scanner/ecmascript5/scannerImportDeclaration1.ts(1,21): error TS2304: Cannot find name 'TypeScriptServices'. +tests/cases/conformance/scanner/ecmascript5/scannerImportDeclaration1.ts(1,21): error TS2503: Cannot find namespace 'TypeScriptServices'. ==== tests/cases/conformance/scanner/ecmascript5/scannerImportDeclaration1.ts (1 errors) ==== import TypeScript = TypeScriptServices.TypeScript; ~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'TypeScriptServices'. \ No newline at end of file +!!! error TS2503: Cannot find namespace 'TypeScriptServices'. \ No newline at end of file diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js index 23b6f2f7e50..f971f089741 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js @@ -9,7 +9,7 @@ class D extends C { } //// [scopeCheckExtendedClassInsidePublicMethod2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js index 7e604118f52..a7f7f4fde99 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js @@ -9,7 +9,7 @@ class D extends C { } //// [scopeCheckExtendedClassInsideStaticMethod1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/scopeTests.js b/tests/baselines/reference/scopeTests.js index c21a821100e..99a933cf157 100644 --- a/tests/baselines/reference/scopeTests.js +++ b/tests/baselines/reference/scopeTests.js @@ -12,7 +12,7 @@ class D extends C { } //// [scopeTests.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/separateCompilationImportExportElision.js b/tests/baselines/reference/separateCompilationImportExportElision.js index 2d255798c3f..cfa57980249 100644 --- a/tests/baselines/reference/separateCompilationImportExportElision.js +++ b/tests/baselines/reference/separateCompilationImportExportElision.js @@ -14,7 +14,7 @@ export {c1} from "module"; export var z = x; //// [separateCompilationImportExportElision.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/shadowPrivateMembers.js b/tests/baselines/reference/shadowPrivateMembers.js index 098a7914a71..4100dba13e3 100644 --- a/tests/baselines/reference/shadowPrivateMembers.js +++ b/tests/baselines/reference/shadowPrivateMembers.js @@ -4,7 +4,7 @@ class derived extends base { private n() {} } //// [shadowPrivateMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js index 94d91cc03cb..cae6e991e24 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js @@ -8,7 +8,7 @@ class Greeter extends AbstractGreeter { } //// [sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt index 96b52724320..d0934f3c9ed 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt @@ -8,7 +8,7 @@ sources: sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts emittedFile:tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts ------------------------------------------------------------------- ->>>var __extends = this.__extends || function (d, b) { +>>>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; } >>> __.prototype = b.prototype; diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js b/tests/baselines/reference/sourceMapValidationDecorators.js index fc4417c2f45..f858aeff586 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js +++ b/tests/baselines/reference/sourceMapValidationDecorators.js @@ -55,7 +55,7 @@ class Greeter { } //// [sourceMapValidationDecorators.js] -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -63,7 +63,7 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target, case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -if (typeof __param !== "function") __param = function (paramIndex, decorator) { +var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var Greeter = (function () { diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index b5749e50fa1..68ad353db9f 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -8,7 +8,7 @@ sources: sourceMapValidationDecorators.ts emittedFile:tests/cases/compiler/sourceMapValidationDecorators.js sourceFile:sourceMapValidationDecorators.ts ------------------------------------------------------------------- ->>>if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +>>>var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { >>> if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); >>> switch (arguments.length) { >>> case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); @@ -16,7 +16,7 @@ sourceFile:sourceMapValidationDecorators.ts >>> case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); >>> } >>>}; ->>>if (typeof __param !== "function") __param = function (paramIndex, decorator) { +>>>var __param = (this && this.__param) || function (paramIndex, decorator) { >>> return function (target, key) { decorator(target, key, paramIndex); } >>>}; >>>var Greeter = (function () { diff --git a/tests/baselines/reference/specializedInheritedConstructors1.js b/tests/baselines/reference/specializedInheritedConstructors1.js index 36280f9a44e..ec467ad9877 100644 --- a/tests/baselines/reference/specializedInheritedConstructors1.js +++ b/tests/baselines/reference/specializedInheritedConstructors1.js @@ -18,7 +18,7 @@ var myView = new MyView(m); // was error //// [specializedInheritedConstructors1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/specializedOverloadWithRestParameters.js b/tests/baselines/reference/specializedOverloadWithRestParameters.js index f091a39677c..2a022cdf7da 100644 --- a/tests/baselines/reference/specializedOverloadWithRestParameters.js +++ b/tests/baselines/reference/specializedOverloadWithRestParameters.js @@ -13,7 +13,7 @@ function g(tagName: any): Base { } //// [specializedOverloadWithRestParameters.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/staticFactory1.js b/tests/baselines/reference/staticFactory1.js index 529cc230d73..96303af586f 100644 --- a/tests/baselines/reference/staticFactory1.js +++ b/tests/baselines/reference/staticFactory1.js @@ -14,7 +14,7 @@ var d = Derived.create(); d.foo(); //// [staticFactory1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/staticInheritance.js b/tests/baselines/reference/staticInheritance.js index a577bad3a86..0aba29b3560 100644 --- a/tests/baselines/reference/staticInheritance.js +++ b/tests/baselines/reference/staticInheritance.js @@ -12,7 +12,7 @@ doThing(B); //OK //// [staticInheritance.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js index a4bbc3947cd..ab3c010d571 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js @@ -10,7 +10,7 @@ class P extends SomeBase { //// [staticMemberAccessOffDerivedType1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/staticPropSuper.js b/tests/baselines/reference/staticPropSuper.js index f77098b56e4..f0d50b3ecb6 100644 --- a/tests/baselines/reference/staticPropSuper.js +++ b/tests/baselines/reference/staticPropSuper.js @@ -36,7 +36,7 @@ class E extends A { } //// [staticPropSuper.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index f7c5c3ecc5c..fef1ef46b1a 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -61,7 +61,7 @@ class Ds extends A { } //// [strictModeInConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/strictModeReservedWord.errors.txt b/tests/baselines/reference/strictModeReservedWord.errors.txt index 9e76e36551d..9b7c0e03d0c 100644 --- a/tests/baselines/reference/strictModeReservedWord.errors.txt +++ b/tests/baselines/reference/strictModeReservedWord.errors.txt @@ -19,19 +19,19 @@ tests/cases/compiler/strictModeReservedWord.ts(13,28): error TS1212: Identifier tests/cases/compiler/strictModeReservedWord.ts(15,25): error TS9003: 'class' expressions are not currently supported. tests/cases/compiler/strictModeReservedWord.ts(17,9): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS1215: Type expected. 'public' is a reserved word in strict mode -tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS2304: Cannot find name 'public'. +tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS2503: Cannot find namespace 'public'. tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS1215: Type expected. 'private' is a reserved word in strict mode -tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS2304: Cannot find name 'private'. +tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS2503: Cannot find namespace 'private'. tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS1215: Type expected. 'private' is a reserved word in strict mode -tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS2304: Cannot find name 'private'. +tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS2503: Cannot find namespace 'private'. tests/cases/compiler/strictModeReservedWord.ts(20,30): error TS1215: Type expected. 'package' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS1215: Type expected. 'private' is a reserved word in strict mode -tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS2304: Cannot find name 'private'. +tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS2503: Cannot find namespace 'private'. tests/cases/compiler/strictModeReservedWord.ts(21,30): error TS1215: Type expected. 'package' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(21,38): error TS1215: Type expected. 'protected' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(22,9): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS1215: Type expected. 'interface' is a reserved word in strict mode -tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS2304: Cannot find name 'interface'. +tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS2503: Cannot find namespace 'interface'. tests/cases/compiler/strictModeReservedWord.ts(22,22): error TS1215: Type expected. 'package' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(22,30): error TS1215: Type expected. 'implements' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(23,5): error TS2304: Cannot find name 'ublic'. @@ -100,25 +100,25 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invok ~~~~~~ !!! error TS1215: Type expected. 'public' is a reserved word in strict mode ~~~~~~ -!!! error TS2304: Cannot find name 'public'. +!!! error TS2503: Cannot find namespace 'public'. function foo(x: private.x) { } ~~~~~~~ !!! error TS1215: Type expected. 'private' is a reserved word in strict mode ~~~~~~~ -!!! error TS2304: Cannot find name 'private'. +!!! error TS2503: Cannot find namespace 'private'. function foo1(x: private.package.x) { } ~~~~~~~ !!! error TS1215: Type expected. 'private' is a reserved word in strict mode ~~~~~~~ -!!! error TS2304: Cannot find name 'private'. +!!! error TS2503: Cannot find namespace 'private'. ~~~~~~~ !!! error TS1215: Type expected. 'package' is a reserved word in strict mode function foo2(x: private.package.protected) { } ~~~~~~~ !!! error TS1215: Type expected. 'private' is a reserved word in strict mode ~~~~~~~ -!!! error TS2304: Cannot find name 'private'. +!!! error TS2503: Cannot find namespace 'private'. ~~~~~~~ !!! error TS1215: Type expected. 'package' is a reserved word in strict mode ~~~~~~~~~ @@ -129,7 +129,7 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invok ~~~~~~~~~ !!! error TS1215: Type expected. 'interface' is a reserved word in strict mode ~~~~~~~~~ -!!! error TS2304: Cannot find name 'interface'. +!!! error TS2503: Cannot find namespace 'interface'. ~~~~~~~ !!! error TS1215: Type expected. 'package' is a reserved word in strict mode ~~~~~~~~~~ diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt index b7876b1b849..43222495b9f 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt @@ -15,13 +15,13 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,9): error TS tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(23,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2304: Cannot find name 'public'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2503: Cannot find namespace 'public'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2304: Cannot find name 'public'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2503: Cannot find namespace 'public'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2304: Cannot find name 'package'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2503: Cannot find namespace 'package'. ==== tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts (24 errors) ==== @@ -85,12 +85,12 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2304: Cannot find name 'public'. +!!! error TS2503: Cannot find namespace 'public'. class F1 implements public.private.implements { } ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2304: Cannot find name 'public'. +!!! error TS2503: Cannot find namespace 'public'. class G extends package { } ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. @@ -100,4 +100,4 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~~ -!!! error TS2304: Cannot find name 'package'. \ No newline at end of file +!!! error TS2503: Cannot find namespace 'package'. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js index 98b38532aa6..9ee817182c2 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js @@ -29,7 +29,7 @@ class G extends package { } class H extends package.A { } //// [strictModeReservedWordInClassDeclaration.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js index c9278c40446..b6bd2dbd437 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js @@ -41,7 +41,7 @@ var b: { [x: string]: A } = { //// [stringIndexerConstrainsPropertyDeclarations2.js] // String indexer providing a constraint of a user defined type -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypesOfTypeParameter.js b/tests/baselines/reference/subtypesOfTypeParameter.js index 7fe3d28278b..5abdd633424 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.js +++ b/tests/baselines/reference/subtypesOfTypeParameter.js @@ -107,7 +107,7 @@ function f2(x: T, y: U) { //// [subtypesOfTypeParameter.js] // checking whether other types are subtypes of type parameters -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js index 2adc3712c26..afe9b998bd4 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js @@ -169,7 +169,7 @@ class D29 extends C3 { //// [subtypesOfTypeParameterWithConstraints.js] // checking whether other types are subtypes of type parameters with constraints -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js index f1cf61d484f..6f1756912a6 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js @@ -80,7 +80,7 @@ class D9 extends B1 { //// [subtypesOfTypeParameterWithConstraints4.js] // checking whether other types are subtypes of type parameters with constraints -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js index 1caa7d99087..3d2b6372302 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js @@ -159,7 +159,7 @@ module M2 { //// [subtypesOfTypeParameterWithRecursiveConstraints.js] // checking whether other types are subtypes of type parameters with constraints -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingTransitivity.js b/tests/baselines/reference/subtypingTransitivity.js index 828831c19bf..9dcb4095aa2 100644 --- a/tests/baselines/reference/subtypingTransitivity.js +++ b/tests/baselines/reference/subtypingTransitivity.js @@ -20,7 +20,7 @@ b.x = 1; // assigned number to string //// [subtypingTransitivity.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.js b/tests/baselines/reference/subtypingWithCallSignatures2.js index e1341914739..db6f1d85954 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.js +++ b/tests/baselines/reference/subtypingWithCallSignatures2.js @@ -174,7 +174,7 @@ var r18 = foo18(r18arg1); //// [subtypingWithCallSignatures2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.js b/tests/baselines/reference/subtypingWithCallSignatures3.js index fb7b0fef551..d7ff8a79b6c 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.js +++ b/tests/baselines/reference/subtypingWithCallSignatures3.js @@ -121,7 +121,7 @@ module WithGenericSignaturesInBaseType { //// [subtypingWithCallSignatures3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.js b/tests/baselines/reference/subtypingWithCallSignatures4.js index cbdf92e2e60..739e3cacd86 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.js +++ b/tests/baselines/reference/subtypingWithCallSignatures4.js @@ -113,7 +113,7 @@ var r18 = foo18(r18arg); //// [subtypingWithCallSignatures4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.js b/tests/baselines/reference/subtypingWithConstructSignatures2.js index 9a7ecd791c3..4e93ddbbe55 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.js @@ -174,7 +174,7 @@ var r18 = foo18(r18arg1); //// [subtypingWithConstructSignatures2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.js b/tests/baselines/reference/subtypingWithConstructSignatures3.js index a74c14e8d4b..7022b4b395c 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.js @@ -123,7 +123,7 @@ module WithGenericSignaturesInBaseType { //// [subtypingWithConstructSignatures3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.js b/tests/baselines/reference/subtypingWithConstructSignatures4.js index b3d43b03087..a16ea8e2397 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.js @@ -113,7 +113,7 @@ var r18 = foo18(r18arg); //// [subtypingWithConstructSignatures4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index 3e1a373d4ee..fe3b86d1775 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -51,7 +51,7 @@ interface I extends B { //// [subtypingWithConstructSignatures5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.js b/tests/baselines/reference/subtypingWithConstructSignatures6.js index 3d8f0cfee60..990b654bf45 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.js @@ -54,7 +54,7 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithNumericIndexer.js b/tests/baselines/reference/subtypingWithNumericIndexer.js index 643d71e035f..a7790fba564 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer.js @@ -41,7 +41,7 @@ module Generics { //// [subtypingWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.js b/tests/baselines/reference/subtypingWithNumericIndexer3.js index 44bd366d705..c3fff86274f 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.js @@ -45,7 +45,7 @@ module Generics { //// [subtypingWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.js b/tests/baselines/reference/subtypingWithNumericIndexer4.js index 44c88e1c520..e7ec08436a7 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.js @@ -29,7 +29,7 @@ module Generics { //// [subtypingWithNumericIndexer4.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithObjectMembers.js b/tests/baselines/reference/subtypingWithObjectMembers.js index 06d8f4e0a78..28af7239222 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.js +++ b/tests/baselines/reference/subtypingWithObjectMembers.js @@ -68,7 +68,7 @@ module TwoLevels { } //// [subtypingWithObjectMembers.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithObjectMembers4.js b/tests/baselines/reference/subtypingWithObjectMembers4.js index 31b0cb6e8f9..b04c3056a3e 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers4.js +++ b/tests/baselines/reference/subtypingWithObjectMembers4.js @@ -35,7 +35,7 @@ class B3 extends A3 { //// [subtypingWithObjectMembers4.js] // subtyping when property names do not match -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js index ef873bf81b2..d3b62890855 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js @@ -35,7 +35,7 @@ class B3 extends A3 { //// [subtypingWithObjectMembersAccessibility.js] // Derived member is private, base member is not causes errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js index 6981fbcfebe..4a0ff448b7b 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js @@ -63,7 +63,7 @@ module ImplicitPublic { //// [subtypingWithObjectMembersAccessibility2.js] // Derived member is private, base member is not causes errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithStringIndexer.js b/tests/baselines/reference/subtypingWithStringIndexer.js index 46f46a570cf..4b398451de8 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer.js +++ b/tests/baselines/reference/subtypingWithStringIndexer.js @@ -42,7 +42,7 @@ module Generics { //// [subtypingWithStringIndexer.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.js b/tests/baselines/reference/subtypingWithStringIndexer3.js index c5b9d96ce54..cf1ec80a8d2 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.js +++ b/tests/baselines/reference/subtypingWithStringIndexer3.js @@ -45,7 +45,7 @@ module Generics { //// [subtypingWithStringIndexer3.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.js b/tests/baselines/reference/subtypingWithStringIndexer4.js index 0dbe8912eba..e6aa298fed8 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.js +++ b/tests/baselines/reference/subtypingWithStringIndexer4.js @@ -29,7 +29,7 @@ module Generics { //// [subtypingWithStringIndexer4.js] // Derived type indexer must be subtype of base type indexer -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index 453eb820ddb..ed220ae1f18 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -38,7 +38,7 @@ s.foo() + ss.foo(); //// [super.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index ab982aa8fdf..1bf75783a60 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -67,7 +67,7 @@ module Base4 { //// [super1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/super2.js b/tests/baselines/reference/super2.js index 0b596b44d32..0f5531a8d57 100644 --- a/tests/baselines/reference/super2.js +++ b/tests/baselines/reference/super2.js @@ -51,7 +51,7 @@ results1.x() + results1.y() + results2.y(); //// [super2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superAccess.js b/tests/baselines/reference/superAccess.js index 3d9080b76e1..bf6a9ee3ad0 100644 --- a/tests/baselines/reference/superAccess.js +++ b/tests/baselines/reference/superAccess.js @@ -14,7 +14,7 @@ class MyDerived extends MyBase { } //// [superAccess.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index 8672b5b9935..afcba34aa5d 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -25,7 +25,7 @@ class Q extends P { } //// [superAccess2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superAccessInFatArrow1.js b/tests/baselines/reference/superAccessInFatArrow1.js index c7cc8308c5a..6222bf42fee 100644 --- a/tests/baselines/reference/superAccessInFatArrow1.js +++ b/tests/baselines/reference/superAccessInFatArrow1.js @@ -16,7 +16,7 @@ module test { } //// [superAccessInFatArrow1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallArgsMustMatch.js b/tests/baselines/reference/superCallArgsMustMatch.js index e38c519ead9..7c7948cc387 100644 --- a/tests/baselines/reference/superCallArgsMustMatch.js +++ b/tests/baselines/reference/superCallArgsMustMatch.js @@ -26,7 +26,7 @@ class T6 extends T5{ //// [superCallArgsMustMatch.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallAssignResult.js b/tests/baselines/reference/superCallAssignResult.js index 3a57a173a1c..a83e5b3de75 100644 --- a/tests/baselines/reference/superCallAssignResult.js +++ b/tests/baselines/reference/superCallAssignResult.js @@ -11,7 +11,7 @@ class H extends E { } //// [superCallAssignResult.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js index 036c6de833e..15e26b5481f 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js @@ -12,7 +12,7 @@ class D extends B { //// [superCallFromClassThatDerivesFromGenericType1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js index 193e3c1ed28..15d24015a04 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js @@ -11,7 +11,7 @@ class D extends B { //// [superCallFromClassThatDerivesFromGenericType2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js index 92abed0d66d..114505b85a2 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js @@ -11,7 +11,7 @@ class B extends A { } //// [superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js index 7e3c61e6690..226665e3e67 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js @@ -11,7 +11,7 @@ class B extends A { } //// [superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js index b48d5bb7f58..7c07e78b0f9 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js @@ -11,7 +11,7 @@ class B extends A { } //// [superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallInNonStaticMethod.js b/tests/baselines/reference/superCallInNonStaticMethod.js index 7ef1ce1c62a..c3038e23c4c 100644 --- a/tests/baselines/reference/superCallInNonStaticMethod.js +++ b/tests/baselines/reference/superCallInNonStaticMethod.js @@ -51,7 +51,7 @@ class Other extends Doing { //// [superCallInNonStaticMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallInStaticMethod.js b/tests/baselines/reference/superCallInStaticMethod.js index 820551724ac..7e57cd2d2e8 100644 --- a/tests/baselines/reference/superCallInStaticMethod.js +++ b/tests/baselines/reference/superCallInStaticMethod.js @@ -47,7 +47,7 @@ class Other extends Doing { //// [superCallInStaticMethod.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallOutsideConstructor.js b/tests/baselines/reference/superCallOutsideConstructor.js index 94f41cccb57..0a1822bc549 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.js +++ b/tests/baselines/reference/superCallOutsideConstructor.js @@ -23,7 +23,7 @@ var d = new D(); //// [superCallOutsideConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallParameterContextualTyping1.js b/tests/baselines/reference/superCallParameterContextualTyping1.js index b11d62d62c8..4888473319e 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping1.js +++ b/tests/baselines/reference/superCallParameterContextualTyping1.js @@ -13,7 +13,7 @@ class B extends A { //// [superCallParameterContextualTyping1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallParameterContextualTyping2.js b/tests/baselines/reference/superCallParameterContextualTyping2.js index 61e8b94f00f..ab6093c42be 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping2.js +++ b/tests/baselines/reference/superCallParameterContextualTyping2.js @@ -12,7 +12,7 @@ class C extends A { } //// [superCallParameterContextualTyping2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallParameterContextualTyping3.js b/tests/baselines/reference/superCallParameterContextualTyping3.js index e33bcb29bb8..574d281ed09 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping3.js +++ b/tests/baselines/reference/superCallParameterContextualTyping3.js @@ -32,7 +32,7 @@ class C extends CBase { } //// [superCallParameterContextualTyping3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCalls.js b/tests/baselines/reference/superCalls.js index 2928793feb6..d2e4f9ff7f1 100644 --- a/tests/baselines/reference/superCalls.js +++ b/tests/baselines/reference/superCalls.js @@ -31,7 +31,7 @@ class OtherDerived extends OtherBase { //// [superCalls.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superCallsInConstructor.js b/tests/baselines/reference/superCallsInConstructor.js index 0c19e365d92..6bd313898d4 100644 --- a/tests/baselines/reference/superCallsInConstructor.js +++ b/tests/baselines/reference/superCallsInConstructor.js @@ -21,7 +21,7 @@ class Derived extends Base { } //// [superCallsInConstructor.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superErrors.js b/tests/baselines/reference/superErrors.js index bb17019aa4e..2e1cd346cd4 100644 --- a/tests/baselines/reference/superErrors.js +++ b/tests/baselines/reference/superErrors.js @@ -52,7 +52,7 @@ class RegisteredUser extends User { } //// [superErrors.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superInCatchBlock1.js b/tests/baselines/reference/superInCatchBlock1.js index 1b9085ec266..38131f5f08e 100644 --- a/tests/baselines/reference/superInCatchBlock1.js +++ b/tests/baselines/reference/superInCatchBlock1.js @@ -14,7 +14,7 @@ class B extends A { //// [superInCatchBlock1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superInConstructorParam1.js b/tests/baselines/reference/superInConstructorParam1.js index e08dc9d73fd..aaf4162e992 100644 --- a/tests/baselines/reference/superInConstructorParam1.js +++ b/tests/baselines/reference/superInConstructorParam1.js @@ -11,7 +11,7 @@ class C extends B { } //// [superInConstructorParam1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superInLambdas.js b/tests/baselines/reference/superInLambdas.js index 10c489f1b40..5640425f6bc 100644 --- a/tests/baselines/reference/superInLambdas.js +++ b/tests/baselines/reference/superInLambdas.js @@ -68,7 +68,7 @@ class RegisteredUser4 extends User { } //// [superInLambdas.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superNewCall1.js b/tests/baselines/reference/superNewCall1.js index d9b74ac5080..1b11b61ce2f 100644 --- a/tests/baselines/reference/superNewCall1.js +++ b/tests/baselines/reference/superNewCall1.js @@ -13,7 +13,7 @@ class B extends A { } //// [superNewCall1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superPropertyAccess.js b/tests/baselines/reference/superPropertyAccess.js index a5419aaf36e..016fc09ff96 100644 --- a/tests/baselines/reference/superPropertyAccess.js +++ b/tests/baselines/reference/superPropertyAccess.js @@ -37,7 +37,7 @@ class MyDerived extends MyBase { } //// [superPropertyAccess.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superPropertyAccess1.js b/tests/baselines/reference/superPropertyAccess1.js index a0a52526f93..1ee834f3495 100644 --- a/tests/baselines/reference/superPropertyAccess1.js +++ b/tests/baselines/reference/superPropertyAccess1.js @@ -28,7 +28,7 @@ class D extends C { } //// [superPropertyAccess1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superPropertyAccess2.js b/tests/baselines/reference/superPropertyAccess2.js index b906f1b0a8b..0877cf23b9d 100644 --- a/tests/baselines/reference/superPropertyAccess2.js +++ b/tests/baselines/reference/superPropertyAccess2.js @@ -28,7 +28,7 @@ class D extends C { } //// [superPropertyAccess2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superPropertyAccessNoError.js b/tests/baselines/reference/superPropertyAccessNoError.js index e49a2c6b719..f8ee7f6d01b 100644 --- a/tests/baselines/reference/superPropertyAccessNoError.js +++ b/tests/baselines/reference/superPropertyAccessNoError.js @@ -67,7 +67,7 @@ class SomeDerivedClass extends SomeBaseClass { //super.publicInstanceMemberFunction in lambda in member function //super.publicStaticMemberFunction in static member function of derived class //super.publicStaticMemberFunction in static member accessor(get and set) of derived class -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superWithGenericSpecialization.js b/tests/baselines/reference/superWithGenericSpecialization.js index 92d7a8156aa..5cd85f90735 100644 --- a/tests/baselines/reference/superWithGenericSpecialization.js +++ b/tests/baselines/reference/superWithGenericSpecialization.js @@ -15,7 +15,7 @@ var r: string = d.x; var r2: number = d.y; //// [superWithGenericSpecialization.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superWithGenerics.js b/tests/baselines/reference/superWithGenerics.js index 1daef3e269f..8ba6f878dc2 100644 --- a/tests/baselines/reference/superWithGenerics.js +++ b/tests/baselines/reference/superWithGenerics.js @@ -12,7 +12,7 @@ class D extends B { //// [superWithGenerics.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superWithTypeArgument.js b/tests/baselines/reference/superWithTypeArgument.js index 96566a57490..2e5ea93a47a 100644 --- a/tests/baselines/reference/superWithTypeArgument.js +++ b/tests/baselines/reference/superWithTypeArgument.js @@ -10,7 +10,7 @@ class D extends C { } //// [superWithTypeArgument.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superWithTypeArgument2.js b/tests/baselines/reference/superWithTypeArgument2.js index a3dc7fbe58d..c33497d58fd 100644 --- a/tests/baselines/reference/superWithTypeArgument2.js +++ b/tests/baselines/reference/superWithTypeArgument2.js @@ -10,7 +10,7 @@ class D extends C { } //// [superWithTypeArgument2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/superWithTypeArgument3.js b/tests/baselines/reference/superWithTypeArgument3.js index ef228a3ba20..1266d97f264 100644 --- a/tests/baselines/reference/superWithTypeArgument3.js +++ b/tests/baselines/reference/superWithTypeArgument3.js @@ -14,7 +14,7 @@ class D extends C { } //// [superWithTypeArgument3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js index 2a97b6d04d7..97fa57528cf 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js @@ -28,7 +28,7 @@ class SuperObjectTest extends F { //// [super_inside-object-literal-getters-and-setters.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/switchStatements.js b/tests/baselines/reference/switchStatements.js index 6348ca62e78..debd9a4d531 100644 --- a/tests/baselines/reference/switchStatements.js +++ b/tests/baselines/reference/switchStatements.js @@ -56,7 +56,7 @@ switch (((x: T) => '')(1)) { } //// [switchStatements.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index 9205c9561c1..f24cfe2b783 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 0f967048ef6..375bcf2174a 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -4,12 +4,12 @@ var obj = { get [Symbol.isConcatSpreadable]() { return '' }, >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) set [Symbol.isConcatSpreadable](x) { } >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index 1f9b2f021a0..90290569e07 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -4,22 +4,22 @@ class C { static [Symbol.iterator] = 0; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) static [Symbol.isConcatSpreadable]() { } >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index a4605173830..66f540a8cae 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index dcd0f523d61..5927b8a6a29 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 66d5fccb56e..3c214bd9c25 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index 6fb95c4d2ac..d3a3a313223 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index feebcb95db5..d552300b70e 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index c8db12c3e98..7f5fc3cf51b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -4,6 +4,6 @@ interface I { [Symbol.isConcatSpreadable](): string; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index 999a852c5c7..fe60e2ecc31 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -4,6 +4,6 @@ interface I { [Symbol.isConcatSpreadable]: string; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index 75e92a85922..b044c5264d8 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -4,6 +4,6 @@ var obj: { [Symbol.isConcatSpreadable]: string; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index e57bb11047b..797b422c7fc 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -4,6 +4,6 @@ var obj = { [Symbol.isConcatSpreadable]: 0 >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index fe80dae2816..deaf1c1bb62 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -4,6 +4,6 @@ var obj = { [Symbol.isConcatSpreadable]() { } >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index f1988f05268..f8b758cbf68 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -7,7 +7,7 @@ interface I { [Symbol.iterator]?: { x }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index a2b66415992..246ca2f0851 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -4,7 +4,7 @@ class C { [Symbol.iterator]: { x; y }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) @@ -14,7 +14,7 @@ interface I { [Symbol.iterator]: { x }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index 27e8a5fd4c6..4531b13dca1 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -4,7 +4,7 @@ class C { [Symbol.iterator]: { x; y }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) @@ -14,7 +14,7 @@ interface I { [Symbol.iterator]?: { x }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index b18cc518ccb..6027f5e797e 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -7,7 +7,7 @@ interface I { [Symbol.iterator]?: { x }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index c23f6ecd892..f7700e3b777 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -4,7 +4,7 @@ class C { private [Symbol.iterator]: { x }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } @@ -13,7 +13,7 @@ interface I { [Symbol.iterator]: { x }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index db5cfb0d3f0..bc23c468a22 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -4,18 +4,18 @@ var i = { [Symbol.iterator]: 0, >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } @@ -23,19 +23,19 @@ var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index 5030f37d6bc..a0274f2c762 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -4,14 +4,14 @@ var i = { [Symbol.iterator]: { p: null }, >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -20,13 +20,13 @@ var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index a2eea4344ab..c6bb74bef31 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index d7281ee1aec..04c76275b55 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -4,14 +4,14 @@ interface I { [Symbol.iterator]: (s: string) => string; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -21,15 +21,15 @@ var i: I = { [Symbol.iterator]: s => s, >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols index 5a62b46dd85..544813c3056 100644 --- a/tests/baselines/reference/symbolProperty21.symbols +++ b/tests/baselines/reference/symbolProperty21.symbols @@ -5,14 +5,14 @@ interface I { >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) >T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) [Symbol.isConcatSpreadable]: U; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) } @@ -35,17 +35,17 @@ foo({ [Symbol.isConcatSpreadable]: "", >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) [Symbol.unscopables]: true ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) }); diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index c346eb2df33..e9f6761e121 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index f6cb0feaa45..d220f80c0f7 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index e64337f1cf2..819b93e6147 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index f2d92b6e0c7..7ead7b14b34 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index 045ed15a707..9f57cd1e2e3 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index 564597e236d..a6594f5146b 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index a524bd2b809..1f0fdaf91a7 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -4,19 +4,19 @@ class C { [Symbol.iterator](x: string): string; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) @@ -32,12 +32,12 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index 78eae3f7704..d50401a637a 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -4,14 +4,14 @@ class C { [Symbol.iterator](x: string): { x: string }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) @@ -19,7 +19,7 @@ class C { [Symbol.iterator](x: any) { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) @@ -35,12 +35,12 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index d086418b1f7..4c3d2595c13 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -4,15 +4,15 @@ class C { get [Symbol.hasInstance]() { >Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index 8bef856c527..a759e09588e 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -4,18 +4,18 @@ var x = { [Symbol.iterator]: 0, >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index 7d2c00d0c1f..ee785ae606d 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -10,7 +10,7 @@ module M { [Symbol.iterator]() { } >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 1f66a4f6416..825f73ebcd1 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -10,7 +10,7 @@ module M { [Symbol.iterator]() { } >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index fadedd9c9ac..e76ad43f43d 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -4,7 +4,7 @@ var obj = { [Symbol.iterator]: 0 >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) }; diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index 51540e8f743..caca4686bbf 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -4,7 +4,7 @@ var obj = { [Symbol.iterator]: 0 >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 01bedd59434..4e0ce420388 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -4,7 +4,7 @@ var obj = { [Symbol.iterator]: 0 >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) }; @@ -12,5 +12,5 @@ var obj = { // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index 9accb8142b4..cedcfe69a9f 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -4,23 +4,23 @@ class C { [Symbol.iterator] = 0; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1248, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 7c894d2b00d..269a8412d95 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1254, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1242, 21)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index 219e0b2f496..4bf91a6112e 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -2,7 +2,7 @@ var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) >Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) >for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) s && s; diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index ac0749f4ac5..1d87ae6a1a4 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.js b/tests/baselines/reference/systemModuleAmbientDeclarations.js new file mode 100644 index 00000000000..82c18cd7981 --- /dev/null +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.js @@ -0,0 +1,84 @@ +//// [tests/cases/compiler/systemModuleAmbientDeclarations.ts] //// + +//// [file1.ts] + +declare class Promise { } +declare function Foo(): void; +declare class C {} +declare enum E {X = 1}; + +export var promise = Promise; +export var foo = Foo; +export var c = C; +export var e = E; + +//// [file2.ts] +export declare function foo(); + +//// [file3.ts] +export declare class C {} + +//// [file4.ts] +export declare var v: number; + +//// [file5.ts] +export declare enum E {X = 1} + +//// [file6.ts] +export declare module M { var v: number; } + + +//// [file1.js] +System.register([], function(exports_1) { + var promise, foo, c, e; + return { + setters:[], + execute: function() { + ; + exports_1("promise", promise = Promise); + exports_1("foo", foo = Foo); + exports_1("c", c = C); + exports_1("e", e = E); + } + } +}); +//// [file2.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file3.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file4.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file5.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); +//// [file6.js] +System.register([], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.symbols b/tests/baselines/reference/systemModuleAmbientDeclarations.symbols new file mode 100644 index 00000000000..c2e8557270b --- /dev/null +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/file1.ts === + +declare class Promise { } +>Promise : Symbol(Promise, Decl(file1.ts, 0, 0)) + +declare function Foo(): void; +>Foo : Symbol(Foo, Decl(file1.ts, 1, 25)) + +declare class C {} +>C : Symbol(C, Decl(file1.ts, 2, 29)) + +declare enum E {X = 1}; +>E : Symbol(E, Decl(file1.ts, 3, 18)) +>X : Symbol(E.X, Decl(file1.ts, 4, 16)) + +export var promise = Promise; +>promise : Symbol(promise, Decl(file1.ts, 6, 10)) +>Promise : Symbol(Promise, Decl(file1.ts, 0, 0)) + +export var foo = Foo; +>foo : Symbol(foo, Decl(file1.ts, 7, 10)) +>Foo : Symbol(Foo, Decl(file1.ts, 1, 25)) + +export var c = C; +>c : Symbol(c, Decl(file1.ts, 8, 10)) +>C : Symbol(C, Decl(file1.ts, 2, 29)) + +export var e = E; +>e : Symbol(e, Decl(file1.ts, 9, 10)) +>E : Symbol(E, Decl(file1.ts, 3, 18)) + +=== tests/cases/compiler/file2.ts === +export declare function foo(); +>foo : Symbol(foo, Decl(file2.ts, 0, 0)) + +=== tests/cases/compiler/file3.ts === +export declare class C {} +>C : Symbol(C, Decl(file3.ts, 0, 0)) + +=== tests/cases/compiler/file4.ts === +export declare var v: number; +>v : Symbol(v, Decl(file4.ts, 0, 18)) + +=== tests/cases/compiler/file5.ts === +export declare enum E {X = 1} +>E : Symbol(E, Decl(file5.ts, 0, 0)) +>X : Symbol(E.X, Decl(file5.ts, 0, 23)) + +=== tests/cases/compiler/file6.ts === +export declare module M { var v: number; } +>M : Symbol(M, Decl(file6.ts, 0, 0)) +>v : Symbol(v, Decl(file6.ts, 0, 29)) + diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.types b/tests/baselines/reference/systemModuleAmbientDeclarations.types new file mode 100644 index 00000000000..3633f922881 --- /dev/null +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/file1.ts === + +declare class Promise { } +>Promise : Promise + +declare function Foo(): void; +>Foo : () => void + +declare class C {} +>C : C + +declare enum E {X = 1}; +>E : E +>X : E +>1 : number + +export var promise = Promise; +>promise : typeof Promise +>Promise : typeof Promise + +export var foo = Foo; +>foo : () => void +>Foo : () => void + +export var c = C; +>c : typeof C +>C : typeof C + +export var e = E; +>e : typeof E +>E : typeof E + +=== tests/cases/compiler/file2.ts === +export declare function foo(); +>foo : () => any + +=== tests/cases/compiler/file3.ts === +export declare class C {} +>C : C + +=== tests/cases/compiler/file4.ts === +export declare var v: number; +>v : number + +=== tests/cases/compiler/file5.ts === +export declare enum E {X = 1} +>E : E +>X : E +>1 : number + +=== tests/cases/compiler/file6.ts === +export declare module M { var v: number; } +>M : typeof M +>v : number + diff --git a/tests/baselines/reference/systemModuleConstEnums.js b/tests/baselines/reference/systemModuleConstEnums.js new file mode 100644 index 00000000000..126e6266b2c --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnums.js @@ -0,0 +1,27 @@ +//// [systemModuleConstEnums.ts] + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} + +//// [systemModuleConstEnums.js] +System.register([], function(exports_1) { + function foo() { + use(0 /* X */); + use(0 /* X */); + } + exports_1("foo", foo); + return { + setters:[], + execute: function() { + } + } +}); diff --git a/tests/baselines/reference/systemModuleConstEnums.symbols b/tests/baselines/reference/systemModuleConstEnums.symbols new file mode 100644 index 00000000000..171f24628ec --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnums.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/systemModuleConstEnums.ts === + +declare function use(a: any); +>use : Symbol(use, Decl(systemModuleConstEnums.ts, 0, 0)) +>a : Symbol(a, Decl(systemModuleConstEnums.ts, 1, 21)) + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnums.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 2, 30)) + +export function foo() { +>foo : Symbol(foo, Decl(systemModuleConstEnums.ts, 2, 34)) + + use(TopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnums.ts, 0, 0)) +>TopLevelConstEnum.X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 2, 30)) +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnums.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 2, 30)) + + use(M.NonTopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnums.ts, 0, 0)) +>M.NonTopLevelConstEnum.X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 10, 44)) +>M.NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnums.ts, 9, 10)) +>M : Symbol(M, Decl(systemModuleConstEnums.ts, 7, 1)) +>NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnums.ts, 9, 10)) +>X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 10, 44)) +} + +module M { +>M : Symbol(M, Decl(systemModuleConstEnums.ts, 7, 1)) + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : Symbol(NonTopLevelConstEnum, Decl(systemModuleConstEnums.ts, 9, 10)) +>X : Symbol(NonTopLevelConstEnum.X, Decl(systemModuleConstEnums.ts, 10, 44)) +} diff --git a/tests/baselines/reference/systemModuleConstEnums.types b/tests/baselines/reference/systemModuleConstEnums.types new file mode 100644 index 00000000000..193de0da3ab --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnums.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/systemModuleConstEnums.ts === + +declare function use(a: any); +>use : (a: any) => any +>a : any + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : TopLevelConstEnum +>X : TopLevelConstEnum + +export function foo() { +>foo : () => void + + use(TopLevelConstEnum.X); +>use(TopLevelConstEnum.X) : any +>use : (a: any) => any +>TopLevelConstEnum.X : TopLevelConstEnum +>TopLevelConstEnum : typeof TopLevelConstEnum +>X : TopLevelConstEnum + + use(M.NonTopLevelConstEnum.X); +>use(M.NonTopLevelConstEnum.X) : any +>use : (a: any) => any +>M.NonTopLevelConstEnum.X : M.NonTopLevelConstEnum +>M.NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>M : typeof M +>NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>X : M.NonTopLevelConstEnum +} + +module M { +>M : typeof M + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : NonTopLevelConstEnum +>X : NonTopLevelConstEnum +} diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js new file mode 100644 index 00000000000..381331a84db --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.js @@ -0,0 +1,37 @@ +//// [systemModuleConstEnumsSeparateCompilation.ts] + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} + +//// [systemModuleConstEnumsSeparateCompilation.js] +System.register([], function(exports_1) { + var TopLevelConstEnum, M; + function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); + } + exports_1("foo", foo); + return { + setters:[], + execute: function() { + (function (TopLevelConstEnum) { + TopLevelConstEnum[TopLevelConstEnum["X"] = 0] = "X"; + })(TopLevelConstEnum || (TopLevelConstEnum = {})); + (function (M) { + (function (NonTopLevelConstEnum) { + NonTopLevelConstEnum[NonTopLevelConstEnum["X"] = 0] = "X"; + })(M.NonTopLevelConstEnum || (M.NonTopLevelConstEnum = {})); + var NonTopLevelConstEnum = M.NonTopLevelConstEnum; + })(M || (M = {})); + } + } +}); diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols new file mode 100644 index 00000000000..d57740b75e9 --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts === + +declare function use(a: any); +>use : Symbol(use, Decl(systemModuleConstEnumsSeparateCompilation.ts, 0, 0)) +>a : Symbol(a, Decl(systemModuleConstEnumsSeparateCompilation.ts, 1, 21)) + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 30)) + +export function foo() { +>foo : Symbol(foo, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 34)) + + use(TopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnumsSeparateCompilation.ts, 0, 0)) +>TopLevelConstEnum.X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 30)) +>TopLevelConstEnum : Symbol(TopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 1, 29)) +>X : Symbol(TopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 2, 30)) + + use(M.NonTopLevelConstEnum.X); +>use : Symbol(use, Decl(systemModuleConstEnumsSeparateCompilation.ts, 0, 0)) +>M.NonTopLevelConstEnum.X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 10, 44)) +>M.NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 9, 10)) +>M : Symbol(M, Decl(systemModuleConstEnumsSeparateCompilation.ts, 7, 1)) +>NonTopLevelConstEnum : Symbol(M.NonTopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 9, 10)) +>X : Symbol(M.NonTopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 10, 44)) +} + +module M { +>M : Symbol(M, Decl(systemModuleConstEnumsSeparateCompilation.ts, 7, 1)) + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : Symbol(NonTopLevelConstEnum, Decl(systemModuleConstEnumsSeparateCompilation.ts, 9, 10)) +>X : Symbol(NonTopLevelConstEnum.X, Decl(systemModuleConstEnumsSeparateCompilation.ts, 10, 44)) +} diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types new file mode 100644 index 00000000000..c3a352f66ec --- /dev/null +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts === + +declare function use(a: any); +>use : (a: any) => any +>a : any + +const enum TopLevelConstEnum { X } +>TopLevelConstEnum : TopLevelConstEnum +>X : TopLevelConstEnum + +export function foo() { +>foo : () => void + + use(TopLevelConstEnum.X); +>use(TopLevelConstEnum.X) : any +>use : (a: any) => any +>TopLevelConstEnum.X : TopLevelConstEnum +>TopLevelConstEnum : typeof TopLevelConstEnum +>X : TopLevelConstEnum + + use(M.NonTopLevelConstEnum.X); +>use(M.NonTopLevelConstEnum.X) : any +>use : (a: any) => any +>M.NonTopLevelConstEnum.X : M.NonTopLevelConstEnum +>M.NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>M : typeof M +>NonTopLevelConstEnum : typeof M.NonTopLevelConstEnum +>X : M.NonTopLevelConstEnum +} + +module M { +>M : typeof M + + export const enum NonTopLevelConstEnum { X } +>NonTopLevelConstEnum : NonTopLevelConstEnum +>X : NonTopLevelConstEnum +} diff --git a/tests/baselines/reference/systemModuleDeclarationMerging.js b/tests/baselines/reference/systemModuleDeclarationMerging.js new file mode 100644 index 00000000000..b745ed04891 --- /dev/null +++ b/tests/baselines/reference/systemModuleDeclarationMerging.js @@ -0,0 +1,43 @@ +//// [systemModuleDeclarationMerging.ts] + +export function F() {} +export module F { var x; } + +export class C {} +export module C { var x; } + +export enum E {} +export module E { var x; } + +//// [systemModuleDeclarationMerging.js] +System.register([], function(exports_1) { + var F, C, E; + function F() { } + exports_1("F", F); + return { + setters:[], + execute: function() { + (function (F) { + var x; + })(F = F || (F = {})); + exports_1("F", F) + C = (function () { + function C() { + } + return C; + })(); + exports_1("C", C); + (function (C) { + var x; + })(C = C || (C = {})); + exports_1("C", C) + (function (E) { + })(E || (E = {})); + exports_1("E", E) + (function (E) { + var x; + })(E = E || (E = {})); + exports_1("E", E) + } + } +}); diff --git a/tests/baselines/reference/systemModuleDeclarationMerging.symbols b/tests/baselines/reference/systemModuleDeclarationMerging.symbols new file mode 100644 index 00000000000..8efce4022ba --- /dev/null +++ b/tests/baselines/reference/systemModuleDeclarationMerging.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/systemModuleDeclarationMerging.ts === + +export function F() {} +>F : Symbol(F, Decl(systemModuleDeclarationMerging.ts, 0, 0), Decl(systemModuleDeclarationMerging.ts, 1, 22)) + +export module F { var x; } +>F : Symbol(F, Decl(systemModuleDeclarationMerging.ts, 0, 0), Decl(systemModuleDeclarationMerging.ts, 1, 22)) +>x : Symbol(x, Decl(systemModuleDeclarationMerging.ts, 2, 21)) + +export class C {} +>C : Symbol(C, Decl(systemModuleDeclarationMerging.ts, 2, 26), Decl(systemModuleDeclarationMerging.ts, 4, 17)) + +export module C { var x; } +>C : Symbol(C, Decl(systemModuleDeclarationMerging.ts, 2, 26), Decl(systemModuleDeclarationMerging.ts, 4, 17)) +>x : Symbol(x, Decl(systemModuleDeclarationMerging.ts, 5, 21)) + +export enum E {} +>E : Symbol(E, Decl(systemModuleDeclarationMerging.ts, 5, 26), Decl(systemModuleDeclarationMerging.ts, 7, 16)) + +export module E { var x; } +>E : Symbol(E, Decl(systemModuleDeclarationMerging.ts, 5, 26), Decl(systemModuleDeclarationMerging.ts, 7, 16)) +>x : Symbol(x, Decl(systemModuleDeclarationMerging.ts, 8, 21)) + diff --git a/tests/baselines/reference/systemModuleDeclarationMerging.types b/tests/baselines/reference/systemModuleDeclarationMerging.types new file mode 100644 index 00000000000..20bf1e67f51 --- /dev/null +++ b/tests/baselines/reference/systemModuleDeclarationMerging.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/systemModuleDeclarationMerging.ts === + +export function F() {} +>F : typeof F + +export module F { var x; } +>F : typeof F +>x : any + +export class C {} +>C : C + +export module C { var x; } +>C : typeof C +>x : any + +export enum E {} +>E : E + +export module E { var x; } +>E : typeof E +>x : any + diff --git a/tests/baselines/reference/systemModuleExportDefault.js b/tests/baselines/reference/systemModuleExportDefault.js new file mode 100644 index 00000000000..4df3ec828c1 --- /dev/null +++ b/tests/baselines/reference/systemModuleExportDefault.js @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/systemModuleExportDefault.ts] //// + +//// [file1.ts] + +export default function() {} + +//// [file2.ts] +export default function foo() {} + +//// [file3.ts] +export default class {} + +//// [file4.ts] +export default class C {} + + + +//// [file1.js] +System.register([], function(exports_1) { + function default_1() { } + exports_1("default", default_1); + return { + setters:[], + execute: function() { + } + } +}); +//// [file2.js] +System.register([], function(exports_1) { + function foo() { } + exports_1("default", foo); + return { + setters:[], + execute: function() { + } + } +}); +//// [file3.js] +System.register([], function(exports_1) { + var default_1; + return { + setters:[], + execute: function() { + default_1 = (function () { + function default_1() { + } + return default_1; + })(); + exports_1("default", default_1); + } + } +}); +//// [file4.js] +System.register([], function(exports_1) { + var C; + return { + setters:[], + execute: function() { + C = (function () { + function C() { + } + return C; + })(); + exports_1("default", C); + } + } +}); diff --git a/tests/baselines/reference/systemModuleExportDefault.symbols b/tests/baselines/reference/systemModuleExportDefault.symbols new file mode 100644 index 00000000000..d6e7cde9b71 --- /dev/null +++ b/tests/baselines/reference/systemModuleExportDefault.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.export default function() {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === +export default function foo() {} +>foo : Symbol(foo, Decl(file2.ts, 0, 0)) + +=== tests/cases/compiler/file3.ts === +export default class {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file4.ts === +export default class C {} +>C : Symbol(C, Decl(file4.ts, 0, 0)) + + diff --git a/tests/baselines/reference/systemModuleExportDefault.types b/tests/baselines/reference/systemModuleExportDefault.types new file mode 100644 index 00000000000..38b5abec8ed --- /dev/null +++ b/tests/baselines/reference/systemModuleExportDefault.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === + +No type information for this code.export default function() {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file2.ts === +export default function foo() {} +>foo : () => void + +=== tests/cases/compiler/file3.ts === +export default class {} +No type information for this code. +No type information for this code.=== tests/cases/compiler/file4.ts === +export default class C {} +>C : C + + diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js new file mode 100644 index 00000000000..87e96259bf1 --- /dev/null +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.js @@ -0,0 +1,58 @@ +//// [systemModuleNonTopLevelModuleMembers.ts] + +export class TopLevelClass {} +export module TopLevelModule {var v;} +export function TopLevelFunction(): void {} +export enum TopLevelEnum {E} + +export module TopLevelModule2 { + export class NonTopLevelClass {} + export module NonTopLevelModule {var v;} + export function NonTopLevelFunction(): void {} + export enum NonTopLevelEnum {E} +} + +//// [systemModuleNonTopLevelModuleMembers.js] +System.register([], function(exports_1) { + var TopLevelClass, TopLevelModule, TopLevelEnum, TopLevelModule2; + function TopLevelFunction() { } + exports_1("TopLevelFunction", TopLevelFunction); + return { + setters:[], + execute: function() { + TopLevelClass = (function () { + function TopLevelClass() { + } + return TopLevelClass; + })(); + exports_1("TopLevelClass", TopLevelClass); + (function (TopLevelModule) { + var v; + })(TopLevelModule = TopLevelModule || (TopLevelModule = {})); + exports_1("TopLevelModule", TopLevelModule) + (function (TopLevelEnum) { + TopLevelEnum[TopLevelEnum["E"] = 0] = "E"; + })(TopLevelEnum || (TopLevelEnum = {})); + exports_1("TopLevelEnum", TopLevelEnum) + (function (TopLevelModule2) { + var NonTopLevelClass = (function () { + function NonTopLevelClass() { + } + return NonTopLevelClass; + })(); + TopLevelModule2.NonTopLevelClass = NonTopLevelClass; + var NonTopLevelModule; + (function (NonTopLevelModule) { + var v; + })(NonTopLevelModule = TopLevelModule2.NonTopLevelModule || (TopLevelModule2.NonTopLevelModule = {})); + function NonTopLevelFunction() { } + TopLevelModule2.NonTopLevelFunction = NonTopLevelFunction; + (function (NonTopLevelEnum) { + NonTopLevelEnum[NonTopLevelEnum["E"] = 0] = "E"; + })(TopLevelModule2.NonTopLevelEnum || (TopLevelModule2.NonTopLevelEnum = {})); + var NonTopLevelEnum = TopLevelModule2.NonTopLevelEnum; + })(TopLevelModule2 = TopLevelModule2 || (TopLevelModule2 = {})); + exports_1("TopLevelModule2", TopLevelModule2) + } + } +}); diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols new file mode 100644 index 00000000000..e0b69c71a2f --- /dev/null +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.symbols @@ -0,0 +1,33 @@ +=== tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts === + +export class TopLevelClass {} +>TopLevelClass : Symbol(TopLevelClass, Decl(systemModuleNonTopLevelModuleMembers.ts, 0, 0)) + +export module TopLevelModule {var v;} +>TopLevelModule : Symbol(TopLevelModule, Decl(systemModuleNonTopLevelModuleMembers.ts, 1, 29)) +>v : Symbol(v, Decl(systemModuleNonTopLevelModuleMembers.ts, 2, 33)) + +export function TopLevelFunction(): void {} +>TopLevelFunction : Symbol(TopLevelFunction, Decl(systemModuleNonTopLevelModuleMembers.ts, 2, 37)) + +export enum TopLevelEnum {E} +>TopLevelEnum : Symbol(TopLevelEnum, Decl(systemModuleNonTopLevelModuleMembers.ts, 3, 43)) +>E : Symbol(TopLevelEnum.E, Decl(systemModuleNonTopLevelModuleMembers.ts, 4, 26)) + +export module TopLevelModule2 { +>TopLevelModule2 : Symbol(TopLevelModule2, Decl(systemModuleNonTopLevelModuleMembers.ts, 4, 28)) + + export class NonTopLevelClass {} +>NonTopLevelClass : Symbol(NonTopLevelClass, Decl(systemModuleNonTopLevelModuleMembers.ts, 6, 31)) + + export module NonTopLevelModule {var v;} +>NonTopLevelModule : Symbol(NonTopLevelModule, Decl(systemModuleNonTopLevelModuleMembers.ts, 7, 36)) +>v : Symbol(v, Decl(systemModuleNonTopLevelModuleMembers.ts, 8, 40)) + + export function NonTopLevelFunction(): void {} +>NonTopLevelFunction : Symbol(NonTopLevelFunction, Decl(systemModuleNonTopLevelModuleMembers.ts, 8, 44)) + + export enum NonTopLevelEnum {E} +>NonTopLevelEnum : Symbol(NonTopLevelEnum, Decl(systemModuleNonTopLevelModuleMembers.ts, 9, 50)) +>E : Symbol(NonTopLevelEnum.E, Decl(systemModuleNonTopLevelModuleMembers.ts, 10, 33)) +} diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types new file mode 100644 index 00000000000..ffe3d23f7a6 --- /dev/null +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts === + +export class TopLevelClass {} +>TopLevelClass : TopLevelClass + +export module TopLevelModule {var v;} +>TopLevelModule : typeof TopLevelModule +>v : any + +export function TopLevelFunction(): void {} +>TopLevelFunction : () => void + +export enum TopLevelEnum {E} +>TopLevelEnum : TopLevelEnum +>E : TopLevelEnum + +export module TopLevelModule2 { +>TopLevelModule2 : typeof TopLevelModule2 + + export class NonTopLevelClass {} +>NonTopLevelClass : NonTopLevelClass + + export module NonTopLevelModule {var v;} +>NonTopLevelModule : typeof NonTopLevelModule +>v : any + + export function NonTopLevelFunction(): void {} +>NonTopLevelFunction : () => void + + export enum NonTopLevelEnum {E} +>NonTopLevelEnum : NonTopLevelEnum +>E : NonTopLevelEnum +} diff --git a/tests/baselines/reference/targetTypeBaseCalls.js b/tests/baselines/reference/targetTypeBaseCalls.js index c886183bacf..bde689ba2c9 100644 --- a/tests/baselines/reference/targetTypeBaseCalls.js +++ b/tests/baselines/reference/targetTypeBaseCalls.js @@ -19,7 +19,7 @@ class Bar extends Foo { constructor() { super(function(s) { s = 5 }) } } // err //// [targetTypeBaseCalls.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index 7191801513a..0cfe0d854be 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1508, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1)) diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 5720156de0b..afce4ec0375 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -49,7 +49,7 @@ enum SomeEnum { //// [thisInInvalidContexts.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index eee8bcc8487..8fcbe226437 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -49,7 +49,7 @@ enum SomeEnum { export = this; // Should be an error //// [thisInInvalidContextsExternalModule.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/thisInSuperCall.js b/tests/baselines/reference/thisInSuperCall.js index 779d74daa58..3da6d9c8a68 100644 --- a/tests/baselines/reference/thisInSuperCall.js +++ b/tests/baselines/reference/thisInSuperCall.js @@ -23,7 +23,7 @@ class Foo3 extends Base { } //// [thisInSuperCall.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/thisInSuperCall1.js b/tests/baselines/reference/thisInSuperCall1.js index 09b3c2cb591..b0ff1bd4bab 100644 --- a/tests/baselines/reference/thisInSuperCall1.js +++ b/tests/baselines/reference/thisInSuperCall1.js @@ -11,7 +11,7 @@ class Foo extends Base { //// [thisInSuperCall1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/thisInSuperCall2.js b/tests/baselines/reference/thisInSuperCall2.js index d21496a9834..fca671a2c73 100644 --- a/tests/baselines/reference/thisInSuperCall2.js +++ b/tests/baselines/reference/thisInSuperCall2.js @@ -20,7 +20,7 @@ class Foo2 extends Base { //// [thisInSuperCall2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/thisInSuperCall3.js b/tests/baselines/reference/thisInSuperCall3.js index 6660788e40d..fe2bdec77ed 100644 --- a/tests/baselines/reference/thisInSuperCall3.js +++ b/tests/baselines/reference/thisInSuperCall3.js @@ -13,7 +13,7 @@ class Foo extends Base { //// [thisInSuperCall3.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeAssertions.js b/tests/baselines/reference/typeAssertions.js index 01acf58227b..51ca6a27f0e 100644 --- a/tests/baselines/reference/typeAssertions.js +++ b/tests/baselines/reference/typeAssertions.js @@ -43,7 +43,7 @@ someOther = someOther; //// [typeAssertions.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.js b/tests/baselines/reference/typeGuardOfFormInstanceOf.js index 093e80cbb74..de7e9813a84 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.js +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.js @@ -36,7 +36,7 @@ var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 // - when true, narrows the type of x to the type of the 'prototype' property in C provided // it is a subtype of the type of x, or // - when false, has no effect on the type of x. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt b/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt new file mode 100644 index 00000000000..4e6a8b83ae3 --- /dev/null +++ b/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(14,70): error TS2339: Property 'join' does not exist on type 'string | string[]'. +tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(26,44): error TS2339: Property 'toLowerCase' does not exist on type 'string | number'. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts (2 errors) ==== + // Note that type guards affect types of variables and parameters only and + // have no effect on members of objects such as properties. + + // Note that the class's property must be copied to a local variable for + // the type guard to have an effect + class D { + data: string | string[]; + getData() { + var data = this.data; + return typeof data === "string" ? data : data.join(" "); + } + + getData1() { + return typeof this.data === "string" ? this.data : this.data.join(" "); + ~~~~ +!!! error TS2339: Property 'join' does not exist on type 'string | string[]'. + } + } + + var o: { + prop1: number|string; + prop2: boolean|string; + } = { + prop1: "string" , + prop2: true + } + + if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {} + ~~~~~~~~~~~ +!!! error TS2339: Property 'toLowerCase' does not exist on type 'string | number'. + var prop1 = o.prop1; + if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsOnClassProperty.js b/tests/baselines/reference/typeGuardsOnClassProperty.js new file mode 100644 index 00000000000..de4fcb50638 --- /dev/null +++ b/tests/baselines/reference/typeGuardsOnClassProperty.js @@ -0,0 +1,54 @@ +//// [typeGuardsOnClassProperty.ts] +// Note that type guards affect types of variables and parameters only and +// have no effect on members of objects such as properties. + +// Note that the class's property must be copied to a local variable for +// the type guard to have an effect +class D { + data: string | string[]; + getData() { + var data = this.data; + return typeof data === "string" ? data : data.join(" "); + } + + getData1() { + return typeof this.data === "string" ? this.data : this.data.join(" "); + } +} + +var o: { + prop1: number|string; + prop2: boolean|string; +} = { + prop1: "string" , + prop2: true + } + +if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {} +var prop1 = o.prop1; +if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { } + +//// [typeGuardsOnClassProperty.js] +// Note that type guards affect types of variables and parameters only and +// have no effect on members of objects such as properties. +// Note that the class's property must be copied to a local variable for +// the type guard to have an effect +var D = (function () { + function D() { + } + D.prototype.getData = function () { + var data = this.data; + return typeof data === "string" ? data : data.join(" "); + }; + D.prototype.getData1 = function () { + return typeof this.data === "string" ? this.data : this.data.join(" "); + }; + return D; +})(); +var o = { + prop1: "string", + prop2: true +}; +if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) { } +var prop1 = o.prop1; +if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { } diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt new file mode 100644 index 00000000000..4960940d3ab --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -0,0 +1,229 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(12,10): error TS2339: Property 'bar' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(33,5): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(34,10): error TS2339: Property 'bar' does not exist on type 'B'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(65,10): error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(85,10): error TS2339: Property 'bar' does not exist on type 'D'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(111,10): error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'string | F'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'string | F'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(160,11): error TS2339: Property 'foo2' does not exist on type 'G1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(182,11): error TS2339: Property 'bar' does not exist on type 'H'. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (12 errors) ==== + interface AConstructor { + new (): A; + } + interface A { + foo: string; + } + declare var A: AConstructor; + + var obj1: A | string; + if (obj1 instanceof A) { // narrowed to A. + obj1.foo; + obj1.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'A'. + } + + var obj2: any; + if (obj2 instanceof A) { // can't narrow type from 'any' + obj2.foo; + obj2.bar; + } + + // a construct signature with generics + interface BConstructor { + new (): B; + } + interface B { + foo: T; + } + declare var B: BConstructor; + + var obj3: B | string; + if (obj3 instanceof B) { // narrowed to B. + obj3.foo = 1; + obj3.foo = "str"; + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + obj3.bar = "str"; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'B'. + } + + var obj4: any; + if (obj4 instanceof B) { // can't narrow type from 'any' + obj4.foo = "str"; + obj4.foo = 1; + obj4.bar = "str"; + } + + // has multiple construct signature + interface CConstructor { + new (value: string): C1; + new (value: number): C2; + } + interface C1 { + foo: string; + c: string; + bar1: number; + } + interface C2 { + foo: string; + c: string; + bar2: number; + } + declare var C: CConstructor; + + var obj5: C1 | A; + if (obj5 instanceof C) { // narrowed to C1|C2. + obj5.foo; + obj5.c; + obj5.bar1; + ~~~~ +!!! error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. + obj5.bar2; + ~~~~ +!!! error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. + } + + var obj6: any; + if (obj6 instanceof C) { // can't narrow type from 'any' + obj6.foo; + obj6.bar1; + obj6.bar2; + } + + // with object type literal + interface D { + foo: string; + } + declare var D: { new (): D; }; + + var obj7: D | string; + if (obj7 instanceof D) { // narrowed to D. + obj7.foo; + obj7.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'D'. + } + + var obj8: any; + if (obj8 instanceof D) { // can't narrow type from 'any' + obj8.foo; + obj8.bar; + } + + // a construct signature that returns a union type + interface EConstructor { + new (): E1 | E2; + } + interface E1 { + foo: string; + bar1: number; + } + interface E2 { + foo: string; + bar2: number; + } + declare var E: EConstructor; + + var obj9: E1 | A; + if (obj9 instanceof E) { // narrowed to E1 | E2 + obj9.foo; + obj9.bar1; + ~~~~ +!!! error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. + obj9.bar2; + ~~~~ +!!! error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. + } + + var obj10: any; + if (obj10 instanceof E) { // can't narrow type from 'any' + obj10.foo; + obj10.bar1; + obj10.bar2; + } + + // a construct signature that returns any + interface FConstructor { + new (): any; + } + interface F { + foo: string; + bar: number; + } + declare var F: FConstructor; + + var obj11: F | string; + if (obj11 instanceof F) { // can't type narrowing, construct signature returns any. + obj11.foo; + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'string | F'. + obj11.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'string | F'. + } + + var obj12: any; + if (obj12 instanceof F) { // can't narrow type from 'any' + obj12.foo; + obj12.bar; + } + + // a type with a prototype, it overrides the construct signature + interface GConstructor { + prototype: G1; // high priority + new (): G2; // low priority + } + interface G1 { + foo1: number; + } + interface G2 { + foo2: boolean; + } + declare var G: GConstructor; + + var obj13: G1 | G2; + if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype property. + obj13.foo1; + obj13.foo2; + ~~~~ +!!! error TS2339: Property 'foo2' does not exist on type 'G1'. + } + + var obj14: any; + if (obj14 instanceof G) { // can't narrow type from 'any' + obj14.foo1; + obj14.foo2; + } + + // a type with a prototype that has any type + interface HConstructor { + prototype: any; // high priority, but any type is ignored. interface has implicit `prototype: any`. + new (): H; // low priority + } + interface H { + foo: number; + } + declare var H: HConstructor; + + var obj15: H | string; + if (obj15 instanceof H) { // narrowed to H. + obj15.foo; + obj15.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'H'. + } + + var obj16: any; + if (obj16 instanceof H) { // can't narrow type from 'any' + obj16.foo1; + obj16.foo2; + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js new file mode 100644 index 00000000000..7e6b3324470 --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js @@ -0,0 +1,280 @@ +//// [typeGuardsWithInstanceOfByConstructorSignature.ts] +interface AConstructor { + new (): A; +} +interface A { + foo: string; +} +declare var A: AConstructor; + +var obj1: A | string; +if (obj1 instanceof A) { // narrowed to A. + obj1.foo; + obj1.bar; +} + +var obj2: any; +if (obj2 instanceof A) { // can't narrow type from 'any' + obj2.foo; + obj2.bar; +} + +// a construct signature with generics +interface BConstructor { + new (): B; +} +interface B { + foo: T; +} +declare var B: BConstructor; + +var obj3: B | string; +if (obj3 instanceof B) { // narrowed to B. + obj3.foo = 1; + obj3.foo = "str"; + obj3.bar = "str"; +} + +var obj4: any; +if (obj4 instanceof B) { // can't narrow type from 'any' + obj4.foo = "str"; + obj4.foo = 1; + obj4.bar = "str"; +} + +// has multiple construct signature +interface CConstructor { + new (value: string): C1; + new (value: number): C2; +} +interface C1 { + foo: string; + c: string; + bar1: number; +} +interface C2 { + foo: string; + c: string; + bar2: number; +} +declare var C: CConstructor; + +var obj5: C1 | A; +if (obj5 instanceof C) { // narrowed to C1|C2. + obj5.foo; + obj5.c; + obj5.bar1; + obj5.bar2; +} + +var obj6: any; +if (obj6 instanceof C) { // can't narrow type from 'any' + obj6.foo; + obj6.bar1; + obj6.bar2; +} + +// with object type literal +interface D { + foo: string; +} +declare var D: { new (): D; }; + +var obj7: D | string; +if (obj7 instanceof D) { // narrowed to D. + obj7.foo; + obj7.bar; +} + +var obj8: any; +if (obj8 instanceof D) { // can't narrow type from 'any' + obj8.foo; + obj8.bar; +} + +// a construct signature that returns a union type +interface EConstructor { + new (): E1 | E2; +} +interface E1 { + foo: string; + bar1: number; +} +interface E2 { + foo: string; + bar2: number; +} +declare var E: EConstructor; + +var obj9: E1 | A; +if (obj9 instanceof E) { // narrowed to E1 | E2 + obj9.foo; + obj9.bar1; + obj9.bar2; +} + +var obj10: any; +if (obj10 instanceof E) { // can't narrow type from 'any' + obj10.foo; + obj10.bar1; + obj10.bar2; +} + +// a construct signature that returns any +interface FConstructor { + new (): any; +} +interface F { + foo: string; + bar: number; +} +declare var F: FConstructor; + +var obj11: F | string; +if (obj11 instanceof F) { // can't type narrowing, construct signature returns any. + obj11.foo; + obj11.bar; +} + +var obj12: any; +if (obj12 instanceof F) { // can't narrow type from 'any' + obj12.foo; + obj12.bar; +} + +// a type with a prototype, it overrides the construct signature +interface GConstructor { + prototype: G1; // high priority + new (): G2; // low priority +} +interface G1 { + foo1: number; +} +interface G2 { + foo2: boolean; +} +declare var G: GConstructor; + +var obj13: G1 | G2; +if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype property. + obj13.foo1; + obj13.foo2; +} + +var obj14: any; +if (obj14 instanceof G) { // can't narrow type from 'any' + obj14.foo1; + obj14.foo2; +} + +// a type with a prototype that has any type +interface HConstructor { + prototype: any; // high priority, but any type is ignored. interface has implicit `prototype: any`. + new (): H; // low priority +} +interface H { + foo: number; +} +declare var H: HConstructor; + +var obj15: H | string; +if (obj15 instanceof H) { // narrowed to H. + obj15.foo; + obj15.bar; +} + +var obj16: any; +if (obj16 instanceof H) { // can't narrow type from 'any' + obj16.foo1; + obj16.foo2; +} + + +//// [typeGuardsWithInstanceOfByConstructorSignature.js] +var obj1; +if (obj1 instanceof A) { + obj1.foo; + obj1.bar; +} +var obj2; +if (obj2 instanceof A) { + obj2.foo; + obj2.bar; +} +var obj3; +if (obj3 instanceof B) { + obj3.foo = 1; + obj3.foo = "str"; + obj3.bar = "str"; +} +var obj4; +if (obj4 instanceof B) { + obj4.foo = "str"; + obj4.foo = 1; + obj4.bar = "str"; +} +var obj5; +if (obj5 instanceof C) { + obj5.foo; + obj5.c; + obj5.bar1; + obj5.bar2; +} +var obj6; +if (obj6 instanceof C) { + obj6.foo; + obj6.bar1; + obj6.bar2; +} +var obj7; +if (obj7 instanceof D) { + obj7.foo; + obj7.bar; +} +var obj8; +if (obj8 instanceof D) { + obj8.foo; + obj8.bar; +} +var obj9; +if (obj9 instanceof E) { + obj9.foo; + obj9.bar1; + obj9.bar2; +} +var obj10; +if (obj10 instanceof E) { + obj10.foo; + obj10.bar1; + obj10.bar2; +} +var obj11; +if (obj11 instanceof F) { + obj11.foo; + obj11.bar; +} +var obj12; +if (obj12 instanceof F) { + obj12.foo; + obj12.bar; +} +var obj13; +if (obj13 instanceof G) { + obj13.foo1; + obj13.foo2; +} +var obj14; +if (obj14 instanceof G) { + obj14.foo1; + obj14.foo2; +} +var obj15; +if (obj15 instanceof H) { + obj15.foo; + obj15.bar; +} +var obj16; +if (obj16 instanceof H) { + obj16.foo1; + obj16.foo2; +} diff --git a/tests/baselines/reference/typeMatch2.js b/tests/baselines/reference/typeMatch2.js index 1fd624e4e5b..6f05bf684f1 100644 --- a/tests/baselines/reference/typeMatch2.js +++ b/tests/baselines/reference/typeMatch2.js @@ -45,7 +45,7 @@ function f4() { //// [typeMatch2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeOfSuperCall.js b/tests/baselines/reference/typeOfSuperCall.js index 206b44ea349..5df29d615e4 100644 --- a/tests/baselines/reference/typeOfSuperCall.js +++ b/tests/baselines/reference/typeOfSuperCall.js @@ -9,7 +9,7 @@ class D extends C { } //// [typeOfSuperCall.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeParameterAsBaseClass.js b/tests/baselines/reference/typeParameterAsBaseClass.js index 8814b3a8531..b00a00abac5 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.js +++ b/tests/baselines/reference/typeParameterAsBaseClass.js @@ -3,7 +3,7 @@ class C extends T {} class C2 implements T {} //// [typeParameterAsBaseClass.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeParameterAsBaseType.js b/tests/baselines/reference/typeParameterAsBaseType.js index c7b15484cba..2715c09fa23 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.js +++ b/tests/baselines/reference/typeParameterAsBaseType.js @@ -13,7 +13,7 @@ interface I2 extends U { } //// [typeParameterAsBaseType.js] // type parameters cannot be used as base types // these are all errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.js b/tests/baselines/reference/typeParameterExtendingUnion1.js index 2cfbe7b07b6..c5e8fccf350 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.js +++ b/tests/baselines/reference/typeParameterExtendingUnion1.js @@ -13,7 +13,7 @@ function f(a: T) { } //// [typeParameterExtendingUnion1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.js b/tests/baselines/reference/typeParameterExtendingUnion2.js index c5e462bb96c..e53aeb42f22 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.js +++ b/tests/baselines/reference/typeParameterExtendingUnion2.js @@ -13,7 +13,7 @@ function f(a: T) { } //// [typeParameterExtendingUnion2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeValueConflict1.js b/tests/baselines/reference/typeValueConflict1.js index 8f39b913f82..d036d90262f 100644 --- a/tests/baselines/reference/typeValueConflict1.js +++ b/tests/baselines/reference/typeValueConflict1.js @@ -12,7 +12,7 @@ module M2 { //// [typeValueConflict1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typeValueConflict2.js b/tests/baselines/reference/typeValueConflict2.js index 52d3d906cfd..c927e70615a 100644 --- a/tests/baselines/reference/typeValueConflict2.js +++ b/tests/baselines/reference/typeValueConflict2.js @@ -19,7 +19,7 @@ module M3 { //// [typeValueConflict2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index c0ddc7183f0..27b72cc54f1 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1404, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2351, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2351, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2381, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2381, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2641, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2641, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2671, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2671, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3221, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3221, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3251, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3251, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3511, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3511, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3541, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3541, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3801, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3801, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3831, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3831, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4091, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4091, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4121, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4121, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4381, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4381, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4411, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4411, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4671, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4671, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4701, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4701, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2931, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2931, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2961, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2961, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1404, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1404, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2077, 42), Decl(lib.d.ts, 2367, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2357, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2107, 42), Decl(lib.d.ts, 2397, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2387, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2367, 44), Decl(lib.d.ts, 2657, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2647, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2397, 44), Decl(lib.d.ts, 2687, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2677, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2947, 60), Decl(lib.d.ts, 3237, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3227, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2977, 60), Decl(lib.d.ts, 3267, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3257, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3237, 46), Decl(lib.d.ts, 3527, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3517, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3267, 46), Decl(lib.d.ts, 3557, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3547, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3527, 48), Decl(lib.d.ts, 3817, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3807, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3557, 48), Decl(lib.d.ts, 3847, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3837, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3817, 46), Decl(lib.d.ts, 4107, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4097, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3847, 46), Decl(lib.d.ts, 4137, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4127, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4107, 48), Decl(lib.d.ts, 4397, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4387, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4137, 48), Decl(lib.d.ts, 4427, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4417, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4397, 50), Decl(lib.d.ts, 4687, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4677, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4427, 50), Decl(lib.d.ts, 4717, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4707, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2657, 46), Decl(lib.d.ts, 2947, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2937, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2687, 46), Decl(lib.d.ts, 2977, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2967, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/typeofANonExportedType.errors.txt b/tests/baselines/reference/typeofANonExportedType.errors.txt index b6b165cdd4f..d07468f62e1 100644 --- a/tests/baselines/reference/typeofANonExportedType.errors.txt +++ b/tests/baselines/reference/typeofANonExportedType.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (1 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (2 errors) ==== var x = 1; export var r1: typeof x; ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -46,6 +47,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType export var r11: typeof E.A; export var r12: typeof r12; + ~~~ +!!! error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. function foo() { } module foo { diff --git a/tests/baselines/reference/typeofAnExportedType.errors.txt b/tests/baselines/reference/typeofAnExportedType.errors.txt index 9f64f697c08..cb6d8c68887 100644 --- a/tests/baselines/reference/typeofAnExportedType.errors.txt +++ b/tests/baselines/reference/typeofAnExportedType.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (1 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (2 errors) ==== export var x = 1; ~~~~~~~~~~~~~~~~~ !!! error TS1148: Cannot compile modules unless the '--module' flag is provided. @@ -46,6 +47,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.t export var r11: typeof E.A; export var r12: typeof r12; + ~~~ +!!! error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. export function foo() { } export module foo { diff --git a/tests/baselines/reference/typeofClass2.js b/tests/baselines/reference/typeofClass2.js index 1cef22bf2eb..f4401db1549 100644 --- a/tests/baselines/reference/typeofClass2.js +++ b/tests/baselines/reference/typeofClass2.js @@ -22,7 +22,7 @@ var r1: typeof D; var r2: typeof d; //// [typeofClass2.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typesWithSpecializedCallSignatures.js b/tests/baselines/reference/typesWithSpecializedCallSignatures.js index e33c0302a2a..4baa9d71194 100644 --- a/tests/baselines/reference/typesWithSpecializedCallSignatures.js +++ b/tests/baselines/reference/typesWithSpecializedCallSignatures.js @@ -43,7 +43,7 @@ var r3: Base = c.foo('hm'); //// [typesWithSpecializedCallSignatures.js] // basic uses of specialized signatures without errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/typesWithSpecializedConstructSignatures.js b/tests/baselines/reference/typesWithSpecializedConstructSignatures.js index ecb43cfcc9e..8f64b4be3bf 100644 --- a/tests/baselines/reference/typesWithSpecializedConstructSignatures.js +++ b/tests/baselines/reference/typesWithSpecializedConstructSignatures.js @@ -41,7 +41,7 @@ var r3: Base = new a('hm'); //// [typesWithSpecializedConstructSignatures.js] // basic uses of specialized signatures without errors -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/undeclaredBase.js b/tests/baselines/reference/undeclaredBase.js index 33e1d522b1f..bb78d5995c3 100644 --- a/tests/baselines/reference/undeclaredBase.js +++ b/tests/baselines/reference/undeclaredBase.js @@ -4,7 +4,7 @@ module M { export class C extends M.I { } } //// [undeclaredBase.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.js b/tests/baselines/reference/undefinedIsSubtypeOfEverything.js index b1ef3e19edd..49877eb62e0 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.js +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.js @@ -123,7 +123,7 @@ class D17 extends Base { //// [undefinedIsSubtypeOfEverything.js] // undefined is a subtype of every other types, no errors expected below -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/underscoreMapFirst.js b/tests/baselines/reference/underscoreMapFirst.js index bff8b7ef43f..c1839fadfdc 100644 --- a/tests/baselines/reference/underscoreMapFirst.js +++ b/tests/baselines/reference/underscoreMapFirst.js @@ -49,7 +49,7 @@ class MyView extends View { //// [underscoreMapFirst.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/unionTypeEquivalence.js b/tests/baselines/reference/unionTypeEquivalence.js index 8343b8e5208..04ee64b73e3 100644 --- a/tests/baselines/reference/unionTypeEquivalence.js +++ b/tests/baselines/reference/unionTypeEquivalence.js @@ -20,7 +20,7 @@ var z1: string | typeof BC; //// [unionTypeEquivalence.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.js b/tests/baselines/reference/unionTypeFromArrayLiteral.js index 0aa549f5490..ab43a6273b2 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.js +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.js @@ -28,7 +28,7 @@ var arr9 = [e, f]; // (E|F)[] // If the array literal is empty, the resulting type is an array type with the element type Undefined. // Otherwise, if the array literal is contextually typed by a type that has a property with the numeric name ‘0’, the resulting type is a tuple type constructed from the types of the element expressions. // Otherwise, the resulting type is an array type with an element type that is the union of the types of the element expressions. -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/unionTypesAssignability.js b/tests/baselines/reference/unionTypesAssignability.js index a94ea07dce2..7778e1beded 100644 --- a/tests/baselines/reference/unionTypesAssignability.js +++ b/tests/baselines/reference/unionTypesAssignability.js @@ -73,7 +73,7 @@ function foo(t: T, u: U) { //// [unionTypesAssignability.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/unknownSymbols1.js b/tests/baselines/reference/unknownSymbols1.js index cbcdd2ea27f..0e081a66b83 100644 --- a/tests/baselines/reference/unknownSymbols1.js +++ b/tests/baselines/reference/unknownSymbols1.js @@ -33,7 +33,7 @@ class C5 { } //// [unknownSymbols1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/unknownSymbols2.errors.txt b/tests/baselines/reference/unknownSymbols2.errors.txt index e78b4a14b61..e85d3c2f3bc 100644 --- a/tests/baselines/reference/unknownSymbols2.errors.txt +++ b/tests/baselines/reference/unknownSymbols2.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/unknownSymbols2.ts(15,13): error TS2304: Cannot find name ' tests/cases/compiler/unknownSymbols2.ts(16,14): error TS2304: Cannot find name 'qwerty'. tests/cases/compiler/unknownSymbols2.ts(22,19): error TS2304: Cannot find name 'asdf'. tests/cases/compiler/unknownSymbols2.ts(23,32): error TS2304: Cannot find name 'qwerty'. -tests/cases/compiler/unknownSymbols2.ts(29,16): error TS2304: Cannot find name 'asdf'. +tests/cases/compiler/unknownSymbols2.ts(29,16): error TS2503: Cannot find namespace 'asdf'. ==== tests/cases/compiler/unknownSymbols2.ts (10 errors) ==== @@ -59,5 +59,5 @@ tests/cases/compiler/unknownSymbols2.ts(29,16): error TS2304: Cannot find name ' import c = N; import d = asdf; ~~~~ -!!! error TS2304: Cannot find name 'asdf'. +!!! error TS2503: Cannot find namespace 'asdf'. } \ No newline at end of file diff --git a/tests/baselines/reference/unspecializedConstraints.js b/tests/baselines/reference/unspecializedConstraints.js index 0ca464a93af..df64daff2bf 100644 --- a/tests/baselines/reference/unspecializedConstraints.js +++ b/tests/baselines/reference/unspecializedConstraints.js @@ -154,7 +154,7 @@ module ts { //// [unspecializedConstraints.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js index 9e0ff95536d..8304aae576f 100644 --- a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js +++ b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js @@ -44,7 +44,7 @@ c5(1); // error //// [untypedFunctionCallsWithTypeParameters1.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/validUseOfThisInSuper.js b/tests/baselines/reference/validUseOfThisInSuper.js index d71548e02e8..6f2fc67d7e1 100644 --- a/tests/baselines/reference/validUseOfThisInSuper.js +++ b/tests/baselines/reference/validUseOfThisInSuper.js @@ -10,7 +10,7 @@ class Super extends Base { } //// [validUseOfThisInSuper.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/baselines/reference/varArgsOnConstructorTypes.js b/tests/baselines/reference/varArgsOnConstructorTypes.js index e61377e255b..005ba55d761 100644 --- a/tests/baselines/reference/varArgsOnConstructorTypes.js +++ b/tests/baselines/reference/varArgsOnConstructorTypes.js @@ -25,7 +25,7 @@ reg.register(B); //// [varArgsOnConstructorTypes.js] -var __extends = this.__extends || function (d, b) { +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; } __.prototype = b.prototype; diff --git a/tests/cases/compiler/contextualTyping.ts b/tests/cases/compiler/contextualTyping.ts index e378fd82065..a50d542343a 100644 --- a/tests/cases/compiler/contextualTyping.ts +++ b/tests/cases/compiler/contextualTyping.ts @@ -1,4 +1,4 @@ -// @newline: \n +// @normalizenewline: \n // @sourcemap: true // DEFAULT INTERFACES interface IFoo { diff --git a/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts b/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts new file mode 100644 index 00000000000..9d4a2331b45 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts @@ -0,0 +1,10 @@ +// @target: es5 + +function f0(a, [a, [b]], {b}) { } +function f1([a, a]) { } +function f2({b}, {b}) { } +function f3([c,[c],[[c]]]) { } +function f4({d, d:{d}}) { } +function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { } +function f6([f, ...f]) { } +function f7(a, func = (a) => { return 1 }) { } // not error \ No newline at end of file diff --git a/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts b/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts new file mode 100644 index 00000000000..f42e490dae1 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts @@ -0,0 +1,11 @@ +// @target: es5 + +"use strict" +function f0(a, [a, [b]], {b}) { } +function f1([a, a]) { } +function f2({b}, {b}) { } +function f3([c, [c], [[c]]]) { } +function f4({d, d: {d}}) { } +function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { } +function f6([f, ...f]) { } +function f7(a, func = (a) => { return 1 }){ } // not error \ No newline at end of file diff --git a/tests/cases/compiler/exportDefaultVariable.ts b/tests/cases/compiler/exportDefaultVariable.ts new file mode 100644 index 00000000000..95fd503dfc4 --- /dev/null +++ b/tests/cases/compiler/exportDefaultVariable.ts @@ -0,0 +1,7 @@ +// Regression test for #3018 + +declare var io: any; + +declare module 'module' { + export default io; +} diff --git a/tests/cases/compiler/narrowTypeByInstanceof.ts b/tests/cases/compiler/narrowTypeByInstanceof.ts new file mode 100644 index 00000000000..6fe6693dd96 --- /dev/null +++ b/tests/cases/compiler/narrowTypeByInstanceof.ts @@ -0,0 +1,24 @@ + class Match { + public range(): any { + return undefined; + } + } + + class FileMatch { + public resource(): any { + return undefined; + } + } + +type FileMatchOrMatch = FileMatch | Match; + + +let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; + +if (elementA instanceof FileMatch && elementB instanceof FileMatch) { + let a = elementA.resource().path; + let b = elementB.resource().path; +} else if (elementA instanceof Match && elementB instanceof Match) { + let a = elementA.range(); + let b = elementB.range(); +} diff --git a/tests/cases/compiler/newLineFlagWithCRLF.ts b/tests/cases/compiler/newLineFlagWithCRLF.ts new file mode 100644 index 00000000000..2a25ebc50d1 --- /dev/null +++ b/tests/cases/compiler/newLineFlagWithCRLF.ts @@ -0,0 +1,4 @@ +// @newline: CRLF +var x=1; +x=2; + diff --git a/tests/cases/compiler/newLineFlagWithLF.ts b/tests/cases/compiler/newLineFlagWithLF.ts new file mode 100644 index 00000000000..2f85a3a1e7f --- /dev/null +++ b/tests/cases/compiler/newLineFlagWithLF.ts @@ -0,0 +1,4 @@ +// @newline: LF +var x=1; +x=2; + diff --git a/tests/cases/compiler/noEmitHelpers.ts b/tests/cases/compiler/noEmitHelpers.ts new file mode 100644 index 00000000000..cb37c0db961 --- /dev/null +++ b/tests/cases/compiler/noEmitHelpers.ts @@ -0,0 +1,4 @@ +// @noemithelpers: true + +class A { } +class B extends A { } diff --git a/tests/cases/compiler/noEmitHelpers2.ts b/tests/cases/compiler/noEmitHelpers2.ts new file mode 100644 index 00000000000..df71f4fae82 --- /dev/null +++ b/tests/cases/compiler/noEmitHelpers2.ts @@ -0,0 +1,11 @@ +// @noemithelpers: true +// @emitdecoratormetadata: true +// @target: es5 + +function decorator() { } + +@decorator +class A { + constructor(a: number, @decorator b: string) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/promiseVoidErrorCallback.ts b/tests/cases/compiler/promiseVoidErrorCallback.ts new file mode 100644 index 00000000000..3169288f79a --- /dev/null +++ b/tests/cases/compiler/promiseVoidErrorCallback.ts @@ -0,0 +1,28 @@ +//@target: ES6 +interface T1 { + __t1: string; +} + +interface T2 { + __t2: string; +} + +interface T3 { + __t3: string; +} + +function f1(): Promise { + return Promise.resolve({ __t1: "foo_t1" }); +} + +function f2(x: T1): T2 { + return { __t2: x.__t1 + ":foo_21" }; +} + +var x3 = f1() + .then(f2, (e: Error) => { + throw e; +}) + .then((x: T2) => { + return { __t3: x.__t2 + "bar" }; +}); \ No newline at end of file diff --git a/tests/cases/compiler/separateCompilationSourceMap.ts b/tests/cases/compiler/separateCompilationSourceMap.ts index 7becf7cbdaf..84c6290caf5 100644 --- a/tests/cases/compiler/separateCompilationSourceMap.ts +++ b/tests/cases/compiler/separateCompilationSourceMap.ts @@ -1,5 +1,5 @@ // @separateCompilation: true -// @sourceMap:sourcemap.map +// @sourceMap:true // @target: es6 // @filename: file1.ts diff --git a/tests/cases/compiler/systemModuleAmbientDeclarations.ts b/tests/cases/compiler/systemModuleAmbientDeclarations.ts new file mode 100644 index 00000000000..05f78592780 --- /dev/null +++ b/tests/cases/compiler/systemModuleAmbientDeclarations.ts @@ -0,0 +1,28 @@ +// @module: system +// @separateCompilation: true + +// @filename: file1.ts +declare class Promise { } +declare function Foo(): void; +declare class C {} +declare enum E {X = 1}; + +export var promise = Promise; +export var foo = Foo; +export var c = C; +export var e = E; + +// @filename: file2.ts +export declare function foo(); + +// @filename: file3.ts +export declare class C {} + +// @filename: file4.ts +export declare var v: number; + +// @filename: file5.ts +export declare enum E {X = 1} + +// @filename: file6.ts +export declare module M { var v: number; } diff --git a/tests/cases/compiler/systemModuleConstEnums.ts b/tests/cases/compiler/systemModuleConstEnums.ts new file mode 100644 index 00000000000..6ad7f31ef91 --- /dev/null +++ b/tests/cases/compiler/systemModuleConstEnums.ts @@ -0,0 +1,13 @@ +// @module: system + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} \ No newline at end of file diff --git a/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts b/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts new file mode 100644 index 00000000000..2fc4707b78e --- /dev/null +++ b/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts @@ -0,0 +1,14 @@ +// @module: system +// @separateCompilation: true + +declare function use(a: any); +const enum TopLevelConstEnum { X } + +export function foo() { + use(TopLevelConstEnum.X); + use(M.NonTopLevelConstEnum.X); +} + +module M { + export const enum NonTopLevelConstEnum { X } +} \ No newline at end of file diff --git a/tests/cases/compiler/systemModuleDeclarationMerging.ts b/tests/cases/compiler/systemModuleDeclarationMerging.ts new file mode 100644 index 00000000000..45c59c5b5dc --- /dev/null +++ b/tests/cases/compiler/systemModuleDeclarationMerging.ts @@ -0,0 +1,11 @@ +// @module: system +// @separateCompilation: true + +export function F() {} +export module F { var x; } + +export class C {} +export module C { var x; } + +export enum E {} +export module E { var x; } \ No newline at end of file diff --git a/tests/cases/compiler/systemModuleExportDefault.ts b/tests/cases/compiler/systemModuleExportDefault.ts new file mode 100644 index 00000000000..102c03f0bcd --- /dev/null +++ b/tests/cases/compiler/systemModuleExportDefault.ts @@ -0,0 +1,14 @@ +// @module: system + +// @filename: file1.ts +export default function() {} + +// @filename: file2.ts +export default function foo() {} + +// @filename: file3.ts +export default class {} + +// @filename: file4.ts +export default class C {} + diff --git a/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts b/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts new file mode 100644 index 00000000000..756d430a2de --- /dev/null +++ b/tests/cases/compiler/systemModuleNonTopLevelModuleMembers.ts @@ -0,0 +1,14 @@ +// @module: system +// @separateCompilation: true + +export class TopLevelClass {} +export module TopLevelModule {var v;} +export function TopLevelFunction(): void {} +export enum TopLevelEnum {E} + +export module TopLevelModule2 { + export class NonTopLevelClass {} + export module NonTopLevelModule {var v;} + export function NonTopLevelFunction(): void {} + export enum NonTopLevelEnum {E} +} \ No newline at end of file diff --git a/tests/cases/conformance/ambient/ambientEnumDeclaration1.ts b/tests/cases/conformance/ambient/ambientEnumDeclaration1.ts new file mode 100644 index 00000000000..9cafe943d13 --- /dev/null +++ b/tests/cases/conformance/ambient/ambientEnumDeclaration1.ts @@ -0,0 +1,9 @@ +// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. + +declare enum E { + a = 10, + b = 10 + 1, + c = b, + d = (c) + 1, + e = 10 << 2 * 8, +} \ No newline at end of file diff --git a/tests/cases/conformance/ambient/ambientEnumDeclaration2.ts b/tests/cases/conformance/ambient/ambientEnumDeclaration2.ts new file mode 100644 index 00000000000..dd6e1a1605e --- /dev/null +++ b/tests/cases/conformance/ambient/ambientEnumDeclaration2.ts @@ -0,0 +1,12 @@ +// In ambient enum declarations that specify no const modifier, enum member declarations +// that omit a value are considered computed members (as opposed to having auto- incremented values assigned). + +declare enum E { + a, // E.a + b, // E.b +} + +declare const enum E1 { + a, // E.a = 0 + b, // E.b = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/constEnums/constEnum1.ts b/tests/cases/conformance/constEnums/constEnum1.ts new file mode 100644 index 00000000000..6bf59b772e9 --- /dev/null +++ b/tests/cases/conformance/constEnums/constEnum1.ts @@ -0,0 +1,16 @@ +// @declaration: true + +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + +const enum E { + a = 10, + b = a, + c = (a+1), + e, + d = ~e, + f = a << 2 >> 1, + g = a << 2 >>> 1, + h = a | b +} \ No newline at end of file diff --git a/tests/cases/conformance/constEnums/constEnum2.ts b/tests/cases/conformance/constEnums/constEnum2.ts new file mode 100644 index 00000000000..a90e83d6c43 --- /dev/null +++ b/tests/cases/conformance/constEnums/constEnum2.ts @@ -0,0 +1,15 @@ +// @declaration: true + +// An enum declaration that specifies a const modifier is a constant enum declaration. +// In a constant enum declaration, all members must have constant values and +// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + +// Error : not a constant enum expression + +const CONST = 9000 % 2; +const enum D { + d = 10, + e = 199 * Math.floor(Math.random() * 1000), + f = d - (100 * Math.floor(Math.random() % 8)) + g = CONST, +} \ No newline at end of file diff --git a/tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts b/tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts new file mode 100644 index 00000000000..bf1b277e3b5 --- /dev/null +++ b/tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts @@ -0,0 +1,32 @@ +// @declaration: true +// @target: es6 + +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members + +const enum G { + A = 1, + B = 2, + C = A + B, + D = A * 2 +} + +var o: { + [idx: number]: boolean +} = { + 1: true + }; + +var a = G.A; +var a1 = G["A"]; +var g = o[G.A]; + +class C { + [G.A]() { } + get [G.B]() { + return true; + } + set [G.B](x: number) { } +} + diff --git a/tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts b/tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts new file mode 100644 index 00000000000..229f034269b --- /dev/null +++ b/tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts @@ -0,0 +1,20 @@ +// @declaration: true + +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members + +const enum G { + A = 1, + B = 2, + C = A + B, + D = A * 2 +} + +// Error from referring constant enum in any other context than a property access +var z = G; +var z1 = G[G.A]; +var g: G; +g = "string"; +function foo(x: G) { } +G.B = 3; diff --git a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts new file mode 100644 index 00000000000..5b594e3cada --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts @@ -0,0 +1,52 @@ +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +var [a2 = false, a3 = 1]: any = undefined; + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + +function foo() { + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +var [...b8] = foo(); + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +var [c0, c1] = [...temp]; +var [c2] = []; +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +var [, c7] = [1, 2, 3]; +var [,,, c8] = [1, 2, 3, 4]; +var [,,, c9] = [1, 2, 3, 4]; +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +var [c11, c12, ...c13] = [1, 2, "string"]; +var [c14, c15, c16] = [1, 2, "string"]; + diff --git a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts new file mode 100644 index 00000000000..9b631706bfd --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts @@ -0,0 +1,53 @@ +// @target: es6 + +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +var [a2 = false, a3 = 1]: any = undefined; + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + +function foo() { + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +var [...b8] = foo(); + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +var [c0, c1] = [...temp]; +var [c2] = []; +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +var [, c7] = [1, 2, 3]; +var [,,, c8] = [1, 2, 3, 4]; +var [,,, c9] = [1, 2, 3, 4]; +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +var [c11, c12, ...c13] = [1, 2, "string"]; +var [c14, c15, c16] = [1, 2, "string"]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts new file mode 100644 index 00000000000..bc5a2da176b --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts @@ -0,0 +1,34 @@ +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or +var [[a0], [[a1]]] = [] // Error +var [[a2], [[a3]]] = undefined // Error + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error +interface J extends Array { + 2: number; +} + +function bar(): J { + return <[number, number, number]>[1, 2, 3]; +} +var [b3 = "string", b4, b5] = bar(); // Error + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1, 2, 3] +var [c0, c1]: [number, number] = [...temp]; // Error +var [c2, c3]: [string, string] = [...temp]; // Error + +interface F { + [idx: number]: boolean +} + +function foo(idx: number): F { + return { + 2: true + } +} +var [c4, c5, c6] = foo(1); // Error \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5.ts new file mode 100644 index 00000000000..e25a11ba5b0 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5.ts @@ -0,0 +1,54 @@ +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +var { a2 }: any = {}; + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +var {1: b3} = { 1: "string" }; +var {b4 = 1}: any = { b4: 100000 }; +var {b5: { b52 } } = { b5: { b52 } }; + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { + [idx: number]: boolean; +} + +function foo(): F { + return { + 1: true + }; +} + +function bar(): F { + return { + 2: true + }; +} +var {1: c0} = foo(); +var {1: c1} = bar(); + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { + [str: string]: number; +} + +function foo1(): F1 { + return { + "prop1": 2 + } +} + +var {"prop1": d1} = foo1(); +var {"prop2": d1} = foo1(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.ts b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.ts new file mode 100644 index 00000000000..a99b48d75da --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.ts @@ -0,0 +1,55 @@ +// @target: es6 +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an object assignment pattern and, for each assignment property P in V, +// S is the type Any, or +var { a1 }: any = undefined; +var { a2 }: any = {}; + +// V is an object assignment pattern and, for each assignment property P in V, +// S has an apparent property with the property name specified in +// P of a type that is assignable to the target given in P, or +var { b1, } = { b1:1, }; +var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +var {1: b3} = { 1: "string" }; +var {b4 = 1}: any = { b4: 100000 }; +var {b5: { b52 } } = { b5: { b52 } }; + +// V is an object assignment pattern and, for each assignment property P in V, +// P specifies a numeric property name and S has a numeric index signature +// of a type that is assignable to the target given in P, or + +interface F { + [idx: number]: boolean; +} + +function foo(): F { + return { + 1: true + }; +} + +function bar(): F { + return { + 2: true + }; +} +var {1: c0} = foo(); +var {1: c1} = bar(); + +// V is an object assignment pattern and, for each assignment property P in V, +// S has a string index signature of a type that is assignable to the target given in P + +interface F1 { + [str: string]: number; +} + +function foo1(): F1 { + return { + "prop1": 2 + } +} + +var {"prop1": d1} = foo1(); +var {"prop2": d1} = foo1(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts new file mode 100644 index 00000000000..2b3192bc9a2 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts @@ -0,0 +1,10 @@ +// Error +var {h?} = { h?: 1 }; +var {i}: string | number = { i: 2 }; +var {i1}: string | number| {} = { i1: 2 }; +var { f2: {f21} = { f212: "string" } }: any = undefined; +var { ...d1 } = { + a: 1, b: 1, d1: 9, e: 10 +} +var {1} = { 1 }; +var {"prop"} = { "prop": 1 }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts new file mode 100644 index 00000000000..01f3cda52bf --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts @@ -0,0 +1,96 @@ +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a1([a, b, [[c]]]: [number, number, string[][]]) { } +function a2(o: { x: number, a: number }) { } +function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; +function a4({x, a}: { x: number, a: number }) { } + +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +function b1(z = [undefined, null]) { }; +function b2(z = null, o = { x: 0, y: undefined }) { } +function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + +interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); +} + +function b6([a, z, y] = [undefined, null, undefined]) { } +function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); +b6(["string", 1, 2]); // Shouldn't be an error +b7([["string"], 1, [[true, false]]]); // Shouldn't be an error + + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +enum Foo { a } +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string} = { b: "hello" }) { } +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c=1]]]) { } + +c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } +c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + +c1(); // Implied type is {z:number}? +c1({ z: 1 }) // Implied type is {z:number}? + +c2({}); // Implied type is {z?: number} +c2({z:1}); // Implied type is {z?: number} + +c3({ b: 1 }); // Implied type is { b: number|string }. + +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. + +function d0(x?) { } +function d0(x = 10) { } + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } +} + +class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } +} + + +function d5({x, y} = { x: 1, y: 2 }) { } +d5(); // Parameter is optional as its declaration included an initializer + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e1({x: number}) { } // x has type any NOT number +function e2({x}: { x: number }) { } // x is type number +function e3({x}: { x?: number }) { } // x is an optional with type number +function e4({x: [number,string,any] }) { } // x has type [any, any, any] +function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts new file mode 100644 index 00000000000..b66e14f017b --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts @@ -0,0 +1,99 @@ +// Conformance for emitting ES6 +// @target: es6 + +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a1([a, b, [[c]]]: [number, number, string[][]]) { } +function a2(o: { x: number, a: number }) { } +function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; +function a4({x, a}: { x: number, a: number }) { } + +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); + + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +function b1(z = [undefined, null]) { }; +function b2(z = null, o = { x: 0, y: undefined }) { } +function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + +interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); +} + +function b6([a, z, y] = [undefined, null, undefined]) { } +function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); + + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +enum Foo { a } +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string} = { b: "hello" }) { } +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c=1]]]) { } + +c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } +c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + +c1(); // Implied type is {z:number}? +c1({ z: 1 }) // Implied type is {z:number}? + +c2({}); // Implied type is {z?: number} +c2({z:1}); // Implied type is {z?: number} + +c3({ b: 1 }); // Implied type is { b: number|string }. + +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } +} + +class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } +} + +function d5({x, y} = { x: 1, y: 2 }) { } +d5(); // Parameter is optional as its declaration included an initializer + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e1({x: number}) { } // x has type any NOT number +function e2({x}: { x: number }) { } // x is type number +function e3({x}: { x?: number }) { } // x is an optional with type number +function e4({x: [number,string,any] }) { } // x has type [any, any, any] +function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + +function e6({x: [number, number, number]}) { } // error, duplicate identifier; + + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts new file mode 100644 index 00000000000..48858044932 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts @@ -0,0 +1,67 @@ +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a0([a, b, [[c]]]: [number, number, string[][]]) { } +a0([1, "string", [["world"]]); // Error +a0([1, 2, [["world"]], "string"]); // Error + + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +interface F1 { + b0(z = 10, [[a, b], d, {u}] = [[1, 2], "string", { u: false }]); // Error, no function body +} + +function b1(z = null, o = { x: 0, y: undefined }) { } +function b2([a, z, y] = [undefined, null, undefined]) { } +function b3([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1("string", { x: "string", y: true }); // Error + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string } = { b: "hello" }) { } +function c4([z], z: number) { } // Error Duplicate identifier +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c = 1]]]) { } + +c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} } +c1({}); // Error, implied type is {z:number}? +c1({ z: true }); // Error, implied type is {z:number}? +c2({ z: false }); // Error, implied type is {z?: number} +c3({ b: true }); // Error, implied type is { b: number|string }. +c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] +c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. Initializers (including binding property or element initializers) are +// permitted only when the parameter list occurs in conjunction with a function body + +function d1([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature +function d2({x, y, z}?) { } // Error, binding pattern can't be optional in implementation signature + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C4 implements F2 { + d3([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature + d4({x, y, c}) { } + e0([a, b, q]) { } +} + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e0({x: [number, number, number]}) { } // error, duplicate identifier; + + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts new file mode 100644 index 00000000000..6eab2225e03 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts @@ -0,0 +1,46 @@ +// @target: es6 + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a1(...x: (number|string)[]) { } +function a2(...a) { } +function a3(...a: Array) { } +function a4(...a: arrayString) { } +function a5(...a: stringOrNumArray) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]: number[]) { } + + +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] + +// Rest parameter with generic +function foo(...a: T[]) { } +foo("hello", 1, 2); +foo("hello", "world"); + +enum E { a, b } +const enum E1 { a, b } +function foo1(...a: T[]) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, E1.a, E.b); + + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts new file mode 100644 index 00000000000..6eab2225e03 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts @@ -0,0 +1,46 @@ +// @target: es6 + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a1(...x: (number|string)[]) { } +function a2(...a) { } +function a3(...a: Array) { } +function a4(...a: arrayString) { } +function a5(...a: stringOrNumArray) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]: number[]) { } + + +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] + +// Rest parameter with generic +function foo(...a: T[]) { } +foo("hello", 1, 2); +foo("hello", "world"); + +enum E { a, b } +const enum E1 { a, b } +function foo1(...a: T[]) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, E1.a, E.b); + + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts new file mode 100644 index 00000000000..02fc84b380a --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts @@ -0,0 +1,36 @@ +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type +function a1(...x: (number|string)[]) { } +function a2(...a: someArray) { } // Error, rest parameter must be array type +function a3(...b?) { } // Error, can't be optional +function a4(...b = [1,2,3]) { } // Error, can't have initializer +function a5([a, b, [[c]]]) { } +function a6([a, b, c, ...x]: number[]) { } + + +a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] +a1(...array2); // Error parameter type is (number|string)[] +a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] +a5([1, 2]); // Error, parameter type is [any, any, [[any]]] +a6([1, 2, "string"]); // Error, parameter type is number[] + + +var temp = [1, 2, 3]; +class C { + constructor(public ...temp) { } // Error, rest parameter can't have accessibilityModifier +} + +// Rest parameter with generic +function foo1(...a: T[]) { } +foo1(1, 2, "string", E1.a, E.b); // Error + + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts new file mode 100644 index 00000000000..c4fcffed491 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts @@ -0,0 +1,50 @@ +// Parameter Declaration with generic + +interface F { } +class Class implements F { + constructor() { } +} + +class SubClass extends Class { + foo: boolean; + constructor() { super(); } +} + +class D implements F { + foo: boolean + constructor() { } +} + +class SubD extends D { + bar: number + constructor() { + super(); + } +} + + +function d0({x} = { x: new Class() }) { } +function d1({x}: { x: F }) { } +function d2({x}: { x: Class }) { } +function d3({y}: { y: D }) { } +function d4({y} = { y: new D() }) { } + +var obj = new Class(); +d0({ x: 1 }); +d0({ x: {} }); +d0({ x: "string" }); + +d1({ x: new Class() }); +d1({ x: {} }); +d1({ x: "string" }); + +d2({ x: new SubClass() }); +d2({ x: {} }); + +d3({ y: new SubD() }); +d3({ y: new SubClass() }); +// Error +d3({ y: new Class() }); +d3({}); +d3({ y: 1 }); +d3({ y: "world" }); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts new file mode 100644 index 00000000000..c583b750fef --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration6.ts @@ -0,0 +1,20 @@ +// A parameter declaration may specify either an identifier or a binding pattern. + +// Reserved words are not allowed to be used as an identifier in parameter declaration +"use strict" + +// Error +function a({while}) { } +function a1({public}) { } +function a4([while, for, public]){ } +function a5(...while) { } +function a6(...public) { } +function a7(...a: string) { } +a({ while: 1 }); + +// No Error +function b1({public: x}) { } +function b2({while: y}) { } +b1({ public: 1 }); +b2({ while: 1 }); + diff --git a/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5.ts new file mode 100644 index 00000000000..6121c00a784 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5.ts @@ -0,0 +1,40 @@ +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +var temp = { t1: true, t2: "false" }; +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +var [...c2] = [1,2,3, "string"]; + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +var [d3, d4] = [1, "string", ...temp1]; + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; + diff --git a/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES6.ts b/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES6.ts new file mode 100644 index 00000000000..dee06e000ce --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES6.ts @@ -0,0 +1,41 @@ +// @target: es6 +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +var temp = { t1: true, t2: "false" }; +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +var [...c2] = [1,2,3, "string"]; + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +var [d3, d4] = [1, "string", ...temp1]; + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; + diff --git a/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts b/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts new file mode 100644 index 00000000000..8ffd3bddd58 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts @@ -0,0 +1,19 @@ +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var temp = { t1: true, t2: "false" }; +var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }]; // Error + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error \ No newline at end of file diff --git a/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES5.ts b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES5.ts new file mode 100644 index 00000000000..34c77288f3f --- /dev/null +++ b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES5.ts @@ -0,0 +1,56 @@ +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [,, 2, 3, 4] +var a1 = ["hello", "world"] +var a2 = [, , , ...a0, "hello"]; +var a3 = [,, ...a0] +var a4 = [() => 1, ]; +var a5 = [...a0, , ] + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +var temp3 = [undefined, null, undefined]; +var temp4 = []; + +interface myArray extends Array { } +interface myArray2 extends Array { } +var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] +var d1 = [...temp]; // has type string[] +var d2: number[] = [...temp1]; +var d3: myArray = [...temp1]; +var d4: myArray2 = [...temp, ...temp1]; +var d5 = [...temp3]; +var d6 = [...temp4]; +var d7 = [...[...temp1]]; +var d8: number[][] = [[...temp1]] +var d9 = [[...temp1], ...["hello"]]; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES6.ts b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES6.ts new file mode 100644 index 00000000000..1a4e11e31eb --- /dev/null +++ b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals2ES6.ts @@ -0,0 +1,55 @@ +// @target:es6 +// ElementList: ( Modified ) +// Elisionopt AssignmentExpression +// Elisionopt SpreadElement +// ElementList, Elisionopt AssignmentExpression +// ElementList, Elisionopt SpreadElement + +// SpreadElement: +// ... AssignmentExpression + +var a0 = [, , 2, 3, 4] +var a1 = ["hello", "world"] +var a2 = [, , , ...a0, "hello"]; +var a3 = [, , ...a0] +var a4 = [() => 1, ]; +var a5 = [...a0, , ] + +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var b0: [any, any, any] = [undefined, null, undefined]; +var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [c0, c1] = [1, 2]; // tuple type [number, number] +var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +interface myArray extends Array { } +interface myArray2 extends Array { } +var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] +var d1 = [...temp]; // has type string[] +var d2: number[] = [...temp1]; +var d3: myArray = [...temp1]; +var d4: myArray2 = [...temp, ...temp1]; +var d5 = [...a2]; +var d6 = [...a3]; +var d7 = [...a4]; +var d8: number[][] = [[...temp1]] +var d9 = [[...temp1], ...["hello"]]; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts new file mode 100644 index 00000000000..fd07347f503 --- /dev/null +++ b/tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts @@ -0,0 +1,34 @@ +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var a0: [any, any, any] = []; // Error +var a1: [boolean, string, number] = ["string", 1, true]; // Error + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [b1, b2]: [number, number] = [1, 2, "string", true]; + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +var temp1 = [1, 2, 3]; +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; + +interface tup { + 0: number[]|string[]; + 1: number[]|string[]; +} +interface myArray extends Array { } +interface myArray2 extends Array { } +var c0: tup = [...temp2]; // Error +var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] +var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] diff --git a/tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts new file mode 100644 index 00000000000..a6ee88c1076 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts @@ -0,0 +1,18 @@ +// In a typed function call, argument expressions are contextually typed by their corresponding parameter types. +function foo({x: [a, b], y: {c, d, e}}) { } +function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { } +function baz(x: [string, number, boolean]) { } + +var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +foo(o1); // Not error since x has contextual type of tuple namely [string, number] +foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error + +var array = ["string", 1, true]; +var tuple: [string, number, boolean] = ["string", 1, true]; +baz(tuple); +baz(["string", 1, true]); + +baz(array); // Error +baz(["string", 1, true, ...array]); // Error +foo(o); // Error because x has an array type namely (string|number)[] \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts new file mode 100644 index 00000000000..17bca640a29 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts @@ -0,0 +1,14 @@ +// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by +// the type of the property with the numeric name N in the contextual type, if any, or otherwise +// the numeric index type of the contextual type, if any. +var array = [1, 2, 3]; +var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type +var tup: [number, number, number] = [1, 2, 3, 4]; +var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"]; +var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error + +// In a contextually typed array literal expression containing one or more spread elements, +// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. +var spr = [1, 2, 3, ...array]; +var spr1 = [1, 2, 3, ...tup]; +var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error diff --git a/tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping1.ts b/tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping1.ts new file mode 100644 index 00000000000..ea8e60cb5b9 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping1.ts @@ -0,0 +1,56 @@ +// When a function expression with no type parameters and no parameter type annotations +// is contextually typed (section 4.19) by a type T and a contextual signature S can be extracted from T + +enum E { red, blue } + +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. + +var a0: (n: number, s: string) => number = (num, str) => { + num.toExponential(); + return 0; +} + +class Class { + foo() { } +} + +var a1: (c: Class) => number = (a1) => { + a1.foo(); + return 1; +} + +// A contextual signature S is extracted from a function type T as follows: +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, +// then S is a signature with the same parameters and a union of the return types. +var b1: ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string); +b1 = (k, h) => { }; +var b2: typeof a0 | ((n: number, s: string) => string); +b2 = (foo, bar) => { return foo + 1; } +b2 = (foo, bar) => { return "hello"; } +var b3: (name: string, num: number, boo: boolean) => void; +b3 = (name, number) => { }; + +var b4: (n: E) => string = (number = 1) => { return "hello"; }; +var b5: (n: {}) => string = (number = "string") => { return "hello"; }; + +// A contextual signature S is extracted from a function type T as follows: +// Otherwise, no contextual signature can be extracted from T and S is undefined. +var b6: ((s: string, w: boolean) => void) | ((n: number) => number); +var b7: ((s: string, w: boolean) => void) | ((s: string, w: number) => string); +b6 = (k) => { k.toLowerCase() }; +b6 = (i) => { + i.toExponential(); + return i; +}; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) +b7 = (j, m) => { }; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause) + +class C { + constructor() { + var k: ((j: T, k: U) => (T|U)[]) | ((j: number,k :U) => number[]) = (j, k) => { + return [j, k]; + } // Per spec, no contextual signature can be extracted in this case. + } +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts b/tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts new file mode 100644 index 00000000000..1b88c1a8cfb --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts @@ -0,0 +1,11 @@ +// A contextual signature S is extracted from a function type T as follows: +// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. +// If T is a union type, let U be the set of element types in T that have call signatures. +// If each type in U has exactly one call signature and that call signature is non- generic, +// and if all of the signatures are identical ignoring return types, then S is a signature +// with the same parameters and a union of the return types. +// Otherwise, no contextual signature can be extracted from T and S is undefined. + +var a0: (n: number, s: string) => number +var a1: typeof a0 | ((n: number, s: string) => string); +a1 = (foo, bar) => { return true; } // Error \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts new file mode 100644 index 00000000000..dcea1cfe2ba --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts @@ -0,0 +1,26 @@ +// @target: es5 +// In the body of a get accessor with no return type annotation, +// if a matching set accessor exists and that set accessor has a parameter type annotation, +// return expressions are contextually typed by the type given in the set accessor's parameter type annotation. + +class C { + set X(x: number) { } + get X() { + return "string"; // Error; get contextual type by set accessor parameter type annotation + } + + set Y(y) { } + get Y() { + return true; + } + + set W(w) { } + get W(): boolean { + return true; + } + + set Z(z: number) { } + get Z() { + return 1; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts index cb2fe8ee8d4..97c399211be 100644 --- a/tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts +++ b/tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts @@ -1,4 +1,7 @@ -// Tests related to #1774 +// In a contextually typed object literal, each property value expression is contextually typed by +// the type of the property with a matching name in the contextual type, if any, or otherwise +// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise +// the string index type of the contextual type, if any. interface Item { name: string; diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts new file mode 100644 index 00000000000..2c26b10c6a1 --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts @@ -0,0 +1,28 @@ +// Note that type guards affect types of variables and parameters only and +// have no effect on members of objects such as properties. + +// Note that the class's property must be copied to a local variable for +// the type guard to have an effect +class D { + data: string | string[]; + getData() { + var data = this.data; + return typeof data === "string" ? data : data.join(" "); + } + + getData1() { + return typeof this.data === "string" ? this.data : this.data.join(" "); + } +} + +var o: { + prop1: number|string; + prop2: boolean|string; +} = { + prop1: "string" , + prop2: true + } + +if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {} +var prop1 = o.prop1; +if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { } \ No newline at end of file diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts new file mode 100644 index 00000000000..b81dd26652b --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts @@ -0,0 +1,189 @@ +interface AConstructor { + new (): A; +} +interface A { + foo: string; +} +declare var A: AConstructor; + +var obj1: A | string; +if (obj1 instanceof A) { // narrowed to A. + obj1.foo; + obj1.bar; +} + +var obj2: any; +if (obj2 instanceof A) { // can't narrow type from 'any' + obj2.foo; + obj2.bar; +} + +// a construct signature with generics +interface BConstructor { + new (): B; +} +interface B { + foo: T; +} +declare var B: BConstructor; + +var obj3: B | string; +if (obj3 instanceof B) { // narrowed to B. + obj3.foo = 1; + obj3.foo = "str"; + obj3.bar = "str"; +} + +var obj4: any; +if (obj4 instanceof B) { // can't narrow type from 'any' + obj4.foo = "str"; + obj4.foo = 1; + obj4.bar = "str"; +} + +// has multiple construct signature +interface CConstructor { + new (value: string): C1; + new (value: number): C2; +} +interface C1 { + foo: string; + c: string; + bar1: number; +} +interface C2 { + foo: string; + c: string; + bar2: number; +} +declare var C: CConstructor; + +var obj5: C1 | A; +if (obj5 instanceof C) { // narrowed to C1|C2. + obj5.foo; + obj5.c; + obj5.bar1; + obj5.bar2; +} + +var obj6: any; +if (obj6 instanceof C) { // can't narrow type from 'any' + obj6.foo; + obj6.bar1; + obj6.bar2; +} + +// with object type literal +interface D { + foo: string; +} +declare var D: { new (): D; }; + +var obj7: D | string; +if (obj7 instanceof D) { // narrowed to D. + obj7.foo; + obj7.bar; +} + +var obj8: any; +if (obj8 instanceof D) { // can't narrow type from 'any' + obj8.foo; + obj8.bar; +} + +// a construct signature that returns a union type +interface EConstructor { + new (): E1 | E2; +} +interface E1 { + foo: string; + bar1: number; +} +interface E2 { + foo: string; + bar2: number; +} +declare var E: EConstructor; + +var obj9: E1 | A; +if (obj9 instanceof E) { // narrowed to E1 | E2 + obj9.foo; + obj9.bar1; + obj9.bar2; +} + +var obj10: any; +if (obj10 instanceof E) { // can't narrow type from 'any' + obj10.foo; + obj10.bar1; + obj10.bar2; +} + +// a construct signature that returns any +interface FConstructor { + new (): any; +} +interface F { + foo: string; + bar: number; +} +declare var F: FConstructor; + +var obj11: F | string; +if (obj11 instanceof F) { // can't type narrowing, construct signature returns any. + obj11.foo; + obj11.bar; +} + +var obj12: any; +if (obj12 instanceof F) { // can't narrow type from 'any' + obj12.foo; + obj12.bar; +} + +// a type with a prototype, it overrides the construct signature +interface GConstructor { + prototype: G1; // high priority + new (): G2; // low priority +} +interface G1 { + foo1: number; +} +interface G2 { + foo2: boolean; +} +declare var G: GConstructor; + +var obj13: G1 | G2; +if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype property. + obj13.foo1; + obj13.foo2; +} + +var obj14: any; +if (obj14 instanceof G) { // can't narrow type from 'any' + obj14.foo1; + obj14.foo2; +} + +// a type with a prototype that has any type +interface HConstructor { + prototype: any; // high priority, but any type is ignored. interface has implicit `prototype: any`. + new (): H; // low priority +} +interface H { + foo: number; +} +declare var H: HConstructor; + +var obj15: H | string; +if (obj15 instanceof H) { // narrowed to H. + obj15.foo; + obj15.bar; +} + +var obj16: any; +if (obj16 instanceof H) { // can't narrow type from 'any' + obj16.foo1; + obj16.foo2; +} diff --git a/tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts b/tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts new file mode 100644 index 00000000000..e3483aa27d3 --- /dev/null +++ b/tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts @@ -0,0 +1,9 @@ +type typeAlias1 = typeof varOfAliasedType1; +var varOfAliasedType1: typeAlias1; + +var varOfAliasedType2: typeAlias2; +type typeAlias2 = typeof varOfAliasedType2; + +function func(): typeAlias3 { return null; } +var varOfAliasedType3 = func(); +type typeAlias3 = typeof varOfAliasedType3; diff --git a/tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts b/tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts index 7852f99dd9b..b39d9dd53a8 100644 --- a/tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts +++ b/tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts @@ -1,5 +1,4 @@ -// None of these declarations should have any errors! -// Using typeof directly, these should be any +// The following are errors because of circular references var c: typeof c; var c: any; var d: typeof e; @@ -7,7 +6,6 @@ var d: any; var e: typeof d; var e: any; -// In type arguments, these should be any interface Foo { } var f: Array; var f: any; @@ -16,6 +14,7 @@ var f2: any; var f3: Foo[]; var f3: any; +// None of these declarations should have any errors! // Truly recursive types var g: { x: typeof g; }; var g: typeof g.x; @@ -48,6 +47,6 @@ var hy2 = hy2.x[0]; interface Foo2 { } -// This one should be any because the first type argument is not contained inside a type literal +// This one should be an error because the first type argument is not contained inside a type literal var hy3: Foo2; var hy3: any; \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnChainedCallbacks.ts b/tests/cases/fourslash/formattingOnChainedCallbacks.ts index 0d72364d506..37fa6ff03f1 100644 --- a/tests/cases/fourslash/formattingOnChainedCallbacks.ts +++ b/tests/cases/fourslash/formattingOnChainedCallbacks.ts @@ -4,7 +4,7 @@ //// .resolve() //// .then(() => {/*1*/""/*2*/ ////}).then(() => {/*3*//*4*/ -////})/*semi1*/ /*semi2*/ +////})/*semi1*//*semi2*/ ////function foo() { //// return Promise.resolve() @@ -16,8 +16,7 @@ goTo.marker('1'); edit.insertLine(''); goTo.marker('2'); -// Expected, with bug 1888: verify.currentLineContentIs(' ""'); -verify.currentLineContentIs(' ""'); +verify.currentLineContentIs(' ""'); goTo.marker('4'); edit.insertLine(''); goTo.marker('3'); @@ -25,8 +24,7 @@ verify.currentLineContentIs(' }).then(() => {'); goTo.marker("semi1"); edit.insert(';'); -// Expected, with bug 1888: verify.currentLineContentIs(' });'); -verify.currentLineContentIs('}); '); +verify.currentLineContentIs(' });'); goTo.marker("semi2"); edit.insert(';'); verify.currentLineContentIs(' });;'); @@ -36,5 +34,4 @@ edit.insert(';'); verify.currentLineContentIs(' "";'); goTo.marker('b'); edit.insert(';'); -// Expected, with bug 1888: verify.currentLineContentIs(' });'); -verify.currentLineContentIs(' });'); \ No newline at end of file +verify.currentLineContentIs(' });'); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 8ade18fc200..9c6fd814d9f 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -119,6 +119,10 @@ module FourSlashInterface { FourSlash.currentTestState.goToDefinition(definitionIndex); } + public type(definitionIndex: number = 0) { + FourSlash.currentTestState.goToTypeDefinition(definitionIndex); + } + public position(position: number, fileIndex?: number); public position(position: number, fileName?: string); public position(position: number, fileNameOrIndex?: any) { @@ -234,6 +238,10 @@ module FourSlashInterface { FourSlash.currentTestState.verifyDefinitionsCount(this.negative, expectedCount); } + public typeDefinitionCountIs(expectedCount: number) { + FourSlash.currentTestState.verifyTypeDefinitionsCount(this.negative, expectedCount); + } + public definitionLocationExists() { FourSlash.currentTestState.verifyDefinitionLocationExists(this.negative); } @@ -651,8 +659,12 @@ module FourSlashInterface { return getClassification("typeParameterName", text, position); } - export function typeAlias(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { - return getClassification("typeAlias", text, position); + export function parameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("parameterName", text, position); + } + + export function typeAliasName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } { + return getClassification("typeAliasName", text, position); } function getClassification(type: string, text: string, position?: number) { diff --git a/tests/cases/fourslash/getEmitOutputOut.ts b/tests/cases/fourslash/getEmitOutputOut.ts new file mode 100644 index 00000000000..077b257e4de --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputOut.ts @@ -0,0 +1,23 @@ +/// + +// @BaselineFile: getEmitOutputOut.baseline +// @out: out.js + +// @Filename: my.d.ts +// @emitThisFile: false +////declare module foo.bar { +//// class Baz { } +////} + +// @Filename: input0.ts +// @emitThisFile: false +/////// +////module foo.bar { +//// var baz1 = Baz.prototype; // Should emit as bar.Baz.prototype +////} + +// @Filename: input1.ts +// @emitThisFile: true +////var x; + +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToTypeDefinition.ts b/tests/cases/fourslash/goToTypeDefinition.ts new file mode 100644 index 00000000000..6b34e7e4886 --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinition.ts @@ -0,0 +1,14 @@ +/// + +// @Filename: goToTypeDefinition_Definition.ts +/////*definition*/class C { +//// p; +////} +////var c: C; + +// @Filename: goToTypeDefinition_Consumption.ts +/////*reference*/c = undefined; + +goTo.marker('reference'); +goTo.type(); +verify.caretAtMarker('definition'); diff --git a/tests/cases/fourslash/goToTypeDefinition2.ts b/tests/cases/fourslash/goToTypeDefinition2.ts new file mode 100644 index 00000000000..8c76655f4a8 --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinition2.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: goToTypeDefinition2_Definition.ts +/////*definition*/interface I1 { +//// p; +////} +////type propertyType = I1; +////interface I2 { +//// property: propertyType; +////} + +// @Filename: goToTypeDefinition2_Consumption.ts +////var i2: I2; +////i2.prop/*reference*/erty; + +goTo.marker('reference'); +goTo.type(); +verify.caretAtMarker('definition'); diff --git a/tests/cases/fourslash/goToTypeDefinitionAliases.ts b/tests/cases/fourslash/goToTypeDefinitionAliases.ts new file mode 100644 index 00000000000..19abc22ca30 --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinitionAliases.ts @@ -0,0 +1,24 @@ +/// + +// @Filename: goToTypeDefinitioAliases_module1.ts +/////*definition*/interface I { +//// p; +////} +////export {I as I2}; + +// @Filename: goToTypeDefinitioAliases_module2.ts +////import {I2 as I3} from "goToTypeDefinitioAliases_module1"; +////var v1: I3; +////export {v1 as v2}; + +// @Filename: goToTypeDefinitioAliases_module3.ts +////import {/*reference1*/v2 as v3} from "goToTypeDefinitioAliases_module2"; +/////*reference2*/v3; + +goTo.marker('reference1'); +goTo.type(); +verify.caretAtMarker('definition'); + +goTo.marker('reference2'); +goTo.type(); +verify.caretAtMarker('definition'); diff --git a/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts b/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts new file mode 100644 index 00000000000..4b5f151498c --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts @@ -0,0 +1,13 @@ +/// + +/////*definition*/enum E { +//// value1, +//// value2 +////} +////var x = E.value2; +//// +/////*reference*/x; + +goTo.marker('reference'); +goTo.type(); +verify.caretAtMarker('definition'); diff --git a/tests/cases/fourslash/goToTypeDefinitionModule.ts b/tests/cases/fourslash/goToTypeDefinitionModule.ts new file mode 100644 index 00000000000..2afccab97c3 --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinitionModule.ts @@ -0,0 +1,19 @@ +/// + +// @Filename: goToTypeDefinitioAliases_module1.ts +/////*definition*/module M { +//// export var p; +////} +////var m: typeof M; + +// @Filename: goToTypeDefinitioAliases_module3.ts +/////*reference1*/M; +/////*reference2*/m; + +goTo.marker('reference1'); +goTo.type(); +verify.caretAtMarker('definition'); + +goTo.marker('reference2'); +goTo.type(); +verify.caretAtMarker('definition'); \ No newline at end of file diff --git a/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts b/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts new file mode 100644 index 00000000000..d38a0c16343 --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts @@ -0,0 +1,25 @@ +/// + +// @Filename: module1.ts +////var w: {a: number}; +////var x = "string"; +////var y: number | string; +////var z; // any + +// @Filename: module2.ts +////w./*reference1*/a; +/////*reference2*/x; +/////*reference3*/y; +/////*reference4*/y; + +goTo.marker('reference1'); +verify.typeDefinitionCountIs(0); + +goTo.marker('reference1'); +verify.typeDefinitionCountIs(0); + +goTo.marker('reference2'); +verify.typeDefinitionCountIs(0); + +goTo.marker('reference4'); +verify.typeDefinitionCountIs(0); diff --git a/tests/cases/fourslash/goToTypeDefinitionUnionType.ts b/tests/cases/fourslash/goToTypeDefinitionUnionType.ts new file mode 100644 index 00000000000..0630ae3ebb9 --- /dev/null +++ b/tests/cases/fourslash/goToTypeDefinitionUnionType.ts @@ -0,0 +1,31 @@ +/// + +/////*definition0*/class C { +//// p; +////} +//// +/////*definition1*/interface I { +//// x; +////} +//// +////module M { +//// /*definition2*/export interface I { +//// y; +//// } +////} +//// +////var x: C | I | M.I; +//// +/////*reference*/x; + +goTo.marker('reference'); +goTo.type(0); +verify.caretAtMarker('definition0'); + +goTo.marker('reference'); +goTo.type(1); +verify.caretAtMarker('definition1'); + +goTo.marker('reference'); +goTo.type(2); +verify.caretAtMarker('definition2'); diff --git a/tests/cases/fourslash/semanticClassificatonTypeAlias.ts b/tests/cases/fourslash/semanticClassificatonTypeAlias.ts index 726588a2c9e..188a09afcbc 100644 --- a/tests/cases/fourslash/semanticClassificatonTypeAlias.ts +++ b/tests/cases/fourslash/semanticClassificatonTypeAlias.ts @@ -7,9 +7,9 @@ var c = classification; verify.semanticClassificationsAre( - c.typeAlias("Alias", test.marker("0").position), - c.typeAlias("Alias", test.marker("1").position), - c.typeAlias("Alias", test.marker("2").position), - c.typeAlias("Alias", test.marker("3").position), - c.typeAlias("Alias", test.marker("4").position) + c.typeAliasName("Alias", test.marker("0").position), + c.typeAliasName("Alias", test.marker("1").position), + c.typeAliasName("Alias", test.marker("2").position), + c.typeAliasName("Alias", test.marker("3").position), + c.typeAliasName("Alias", test.marker("4").position) ); \ No newline at end of file diff --git a/tests/cases/fourslash/server/typedefinition01.ts b/tests/cases/fourslash/server/typedefinition01.ts new file mode 100644 index 00000000000..e7c37747aba --- /dev/null +++ b/tests/cases/fourslash/server/typedefinition01.ts @@ -0,0 +1,12 @@ +/// + +// @Filename: b.ts +////import n = require('a'); +////var x/*1*/ = new n.Foo(); + +// @Filename: a.ts +//// /*2*/export class Foo {} + +goTo.marker('1'); +goTo.type(); +verify.caretAtMarker('2'); \ No newline at end of file diff --git a/tests/cases/fourslash/shims/goToTypeDefinition.ts b/tests/cases/fourslash/shims/goToTypeDefinition.ts new file mode 100644 index 00000000000..6b34e7e4886 --- /dev/null +++ b/tests/cases/fourslash/shims/goToTypeDefinition.ts @@ -0,0 +1,14 @@ +/// + +// @Filename: goToTypeDefinition_Definition.ts +/////*definition*/class C { +//// p; +////} +////var c: C; + +// @Filename: goToTypeDefinition_Consumption.ts +/////*reference*/c = undefined; + +goTo.marker('reference'); +goTo.type(); +verify.caretAtMarker('definition'); diff --git a/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts b/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts index eeaf4a7033f..f7e5b7355a7 100644 --- a/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts +++ b/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts @@ -19,7 +19,7 @@ var firstCommentText = var c = classification; verify.syntacticClassificationsAre( c.comment(firstCommentText), - c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.text("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"), + c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"), c.keyword("var"), c.text("y"), c.operator("="), c.text("x"), c.operator("?"), c.text("x"), c.operator("++"), c.operator(":"), c.operator("++"), c.text("x"), c.punctuation(";"), c.punctuation("}"), c.comment("// end of file")); \ No newline at end of file diff --git a/tests/cases/unittests/services/colorization.ts b/tests/cases/unittests/services/colorization.ts index 6c685cdb174..4351f0ccb1d 100644 --- a/tests/cases/unittests/services/colorization.ts +++ b/tests/cases/unittests/services/colorization.ts @@ -66,8 +66,9 @@ describe('Colorization', function () { describe("test getClassifications", function () { it("Returns correct token classes", function () { + debugger; testLexicalClassification("var x: string = \"foo\"; //Hello", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, keyword("var"), whitespace(" "), identifier("x"), @@ -81,7 +82,7 @@ describe('Colorization', function () { it("correctly classifies a comment after a divide operator", function () { testLexicalClassification("1 / 2 // comment", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, numberLiteral("1"), whitespace(" "), operator("/"), @@ -91,7 +92,7 @@ describe('Colorization', function () { it("correctly classifies a literal after a divide operator", function () { testLexicalClassification("1 / 2, 3 / 4", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, numberLiteral("1"), whitespace(" "), operator("/"), @@ -103,40 +104,41 @@ describe('Colorization', function () { it("correctly classifies a multi-line string with one backslash", function () { testLexicalClassification("'line1\\", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("'line1\\"), finalEndOfLineState(ts.EndOfLineState.InSingleQuoteStringLiteral)); }); it("correctly classifies a multi-line string with three backslashes", function () { testLexicalClassification("'line1\\\\\\", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("'line1\\\\\\"), finalEndOfLineState(ts.EndOfLineState.InSingleQuoteStringLiteral)); }); it("correctly classifies an unterminated single-line string with no backslashes", function () { testLexicalClassification("'line1", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("'line1"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies an unterminated single-line string with two backslashes", function () { testLexicalClassification("'line1\\\\", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("'line1\\\\"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies an unterminated single-line string with four backslashes", function () { testLexicalClassification("'line1\\\\\\\\", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("'line1\\\\\\\\"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies the continuing line of a multi-line string ending in one backslash", function () { + debugger; testLexicalClassification("\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\"), @@ -154,33 +156,33 @@ describe('Colorization', function () { testLexicalClassification(" ", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral(" "), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies the last line of an unterminated multi-line string ending in two backslashes", function () { testLexicalClassification("\\\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\\\"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies the last line of an unterminated multi-line string ending in four backslashes", function () { testLexicalClassification("\\\\\\\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\\\\\\\"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies the last line of a multi-line string", function () { testLexicalClassification("'", ts.EndOfLineState.InSingleQuoteStringLiteral, stringLiteral("'"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies an unterminated multiline comment", function () { testLexicalClassification("/*", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, comment("/*"), finalEndOfLineState(ts.EndOfLineState.InMultiLineCommentTrivia)); }); @@ -189,7 +191,7 @@ describe('Colorization', function () { testLexicalClassification(" */ ", ts.EndOfLineState.InMultiLineCommentTrivia, comment(" */"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("correctly classifies the continuation of a multiline comment", function () { @@ -201,33 +203,33 @@ describe('Colorization', function () { it("correctly classifies an unterminated multiline comment on a line ending in '/*/'", function () { testLexicalClassification(" /*/", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, comment("/*/"), finalEndOfLineState(ts.EndOfLineState.InMultiLineCommentTrivia)); }); it("correctly classifies an unterminated multiline comment with trailing space", function () { testLexicalClassification("/* ", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, comment("/* "), finalEndOfLineState(ts.EndOfLineState.InMultiLineCommentTrivia)); }); it("correctly classifies a keyword after a dot", function () { testLexicalClassification("a.var", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, identifier("var")); }); it("correctly classifies a string literal after a dot", function () { testLexicalClassification("a.\"var\"", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("\"var\"")); }); it("correctly classifies a keyword after a dot separated by comment trivia", function () { testLexicalClassification("a./*hello world*/ var", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, identifier("a"), punctuation("."), comment("/*hello world*/"), @@ -236,41 +238,41 @@ describe('Colorization', function () { it("classifies a property access with whitespace around the dot", function () { testLexicalClassification(" x .\tfoo ()", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, identifier("x"), identifier("foo")); }); it("classifies a keyword after a dot on previous line", function () { testLexicalClassification("var", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, keyword("var"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies multiple keywords properly", function () { testLexicalClassification("public static", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, keyword("public"), keyword("static"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); testLexicalClassification("public var", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, keyword("public"), identifier("var"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies a single line no substitution template string correctly", () => { testLexicalClassification("`number number public string`", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("`number number public string`"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies substitution parts of a template string correctly", () => { testLexicalClassification("`number '${ 1 + 1 }' string '${ 'hello' }'`", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("`number '${"), numberLiteral("1"), operator("+"), @@ -278,11 +280,11 @@ describe('Colorization', function () { stringLiteral("}' string '${"), stringLiteral("'hello'"), stringLiteral("}'`"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies an unterminated no substitution template string correctly", () => { testLexicalClassification("`hello world", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, stringLiteral("`hello world"), finalEndOfLineState(ts.EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate)); }); @@ -308,7 +310,7 @@ describe('Colorization', function () { testLexicalClassification("...`", ts.EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate, stringLiteral("...`"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies the substitution parts and middle/tail of a multiline template string", () => { testLexicalClassification("${ 1 + 1 }...`", @@ -318,7 +320,7 @@ describe('Colorization', function () { operator("+"), numberLiteral("1"), stringLiteral("}...`"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies a template middle and propagates the end of line state",() => { testLexicalClassification("${ 1 + 1 }...`", @@ -328,7 +330,7 @@ describe('Colorization', function () { operator("+"), numberLiteral("1"), stringLiteral("}...`"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("classifies substitution expressions with curly braces appropriately", () => { var pos = 0; @@ -349,7 +351,7 @@ describe('Colorization', function () { stringLiteral(track(" ", "`1`"), pos), punctuation(track(" ", "}"), pos), stringLiteral(track(" ", "}...`"), pos), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); // Adjusts 'pos' by accounting for the length of each portion of the string, // but only return the last given string @@ -364,22 +366,22 @@ describe('Colorization', function () { it("classifies partially written generics correctly.", function () { testLexicalClassification("Foo { @@ -400,7 +402,7 @@ describe('Colorization', function () { v = 2;\r\n\ >>>>>>> Branch - a\r\n\ }", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, keyword("class"), identifier("C"), punctuation("{"), @@ -412,7 +414,7 @@ describe('Colorization', function () { comment("=======\r\n v = 2;\r\n"), comment(">>>>>>> Branch - a"), punctuation("}"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); testLexicalClassification( "<<<<<<< HEAD\r\n\ @@ -420,7 +422,7 @@ class C { }\r\n\ =======\r\n\ class D { }\r\n\ >>>>>>> Branch - a\r\n", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, comment("<<<<<<< HEAD"), keyword("class"), identifier("C"), @@ -428,12 +430,12 @@ class D { }\r\n\ punctuation("}"), comment("=======\r\nclass D { }\r\n"), comment(">>>>>>> Branch - a"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); it("'of' keyword", function () { testLexicalClassification("for (var of of of) { }", - ts.EndOfLineState.Start, + ts.EndOfLineState.None, keyword("for"), punctuation("("), keyword("var"), @@ -443,7 +445,7 @@ class D { }\r\n\ punctuation(")"), punctuation("{"), punctuation("}"), - finalEndOfLineState(ts.EndOfLineState.Start)); + finalEndOfLineState(ts.EndOfLineState.None)); }); }); }); \ No newline at end of file